├── .circleci └── config.yml ├── .editorconfig ├── .eslintrc.json ├── .gitignore ├── .npmignore ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE.md ├── LICENSE ├── README.md ├── bower.json ├── build ├── args.js ├── babel-options.js ├── paths.js ├── tasks │ ├── build.js │ ├── clean.js │ ├── dev.js │ ├── doc.js │ ├── lint.js │ ├── prepare-release.js │ └── test.js └── typescript-options.js ├── config.js ├── dist ├── amd │ ├── aurelia-loader.js │ └── index.js ├── aurelia-loader.d.ts ├── aurelia-loader.js ├── commonjs │ ├── aurelia-loader.js │ └── index.js ├── es2015 │ ├── aurelia-loader.js │ └── index.js ├── index.d.ts ├── native-modules │ ├── aurelia-loader.js │ └── index.js └── system │ ├── aurelia-loader.js │ └── index.js ├── doc ├── CHANGELOG.md └── api.json ├── gulpfile.js ├── karma.conf.js ├── package-lock.json ├── package.json ├── src ├── loader.js ├── template-dependency.js └── template-registry-entry.js ├── test ├── fixtures │ ├── plainHtml.html │ └── template.html └── loader.spec.js ├── tsconfig.json └── typings.json /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | 3 | map-1: &filter_only_develop 4 | filters: 5 | branches: 6 | only: develop 7 | 8 | map-2: &filter_only_tag 9 | filters: 10 | branches: 11 | ignore: /.*/ 12 | tags: 13 | only: /^v?[0-9]+(\.[0-9]+)*$/ 14 | 15 | orbs: 16 | v1: aurelia/v1@volatile 17 | 18 | workflows: 19 | main: 20 | jobs: 21 | - v1/build_test 22 | - v1/build_merge: 23 | <<: *filter_only_develop 24 | requires: 25 | - v1/build_test 26 | - v1/npm_publish: 27 | <<: *filter_only_tag 28 | name: npm_publish_dry 29 | args: "--dry-run" 30 | - request_publish_latest: 31 | <<: *filter_only_tag 32 | type: approval 33 | requires: 34 | - npm_publish_dry 35 | - v1/npm_publish: 36 | <<: *filter_only_tag 37 | name: npm_publish 38 | context: Aurelia 39 | requires: 40 | - request_publish_latest 41 | - v1/merge_back: 42 | <<: *filter_only_tag 43 | requires: 44 | - npm_publish 45 | 46 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | # Unix-style newlines with a newline ending every file 7 | [*] 8 | end_of_line = lf 9 | insert_final_newline = true 10 | 11 | # 2 space indentation 12 | [**.*] 13 | indent_style = space 14 | indent_size = 2 -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./node_modules/aurelia-tools/.eslintrc.json" 3 | } 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | jspm_packages 3 | bower_components 4 | .idea 5 | .DS_STORE 6 | build/reports 7 | dist 8 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | jspm_packages 2 | bower_components 3 | .idea 4 | build/reports 5 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | We'd love for you to contribute and to make this project even better than it is today! If this interests you, please begin by reading [our contributing guidelines](https://github.com/DurandalProject/about/blob/master/CONTRIBUTING.md). The contributing document will provide you with all the information you need to get started. Once you have read that, you will need to also [sign our CLA](http://goo.gl/forms/dI8QDDSyKR) before we can accept a Pull Request from you. More information on the process is included in the [contributor's guide](https://github.com/DurandalProject/about/blob/master/CONTRIBUTING.md). 4 | -------------------------------------------------------------------------------- /ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 19 | **I'm submitting a bug report** 20 | **I'm submitting a feature request** 21 | 22 | * **Library Version:** 23 | major.minor.patch-pre 24 | 25 | 26 | **Please tell us about your environment:** 27 | * **Operating System:** 28 | OSX 10.x|Linux (distro)|Windows [7|8|8.1|10] 29 | 30 | * **Node Version:** 31 | 6.2.0 32 | 36 | 37 | * **NPM Version:** 38 | 3.8.9 39 | 43 | 44 | * **JSPM OR Webpack AND Version** 45 | JSPM 0.16.32 | webpack 2.1.0-beta.17 46 | 52 | 53 | * **Browser:** 54 | all | Chrome XX | Firefox XX | Edge XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView 55 | 56 | * **Language:** 57 | all | TypeScript X.X | ESNext 58 | 59 | 60 | **Current behavior:** 61 | 62 | 63 | **Expected/desired behavior:** 64 | 71 | 72 | 73 | * **What is the expected behavior?** 74 | 75 | 76 | * **What is the motivation / use case for changing the behavior?** 77 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2010 - 2018 Blue Spire Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # aurelia-loader 2 | 3 | [![npm Version](https://img.shields.io/npm/v/aurelia-loader.svg)](https://www.npmjs.com/package/aurelia-loader) 4 | [![ZenHub](https://raw.githubusercontent.com/ZenHubIO/support/master/zenhub-badge.png)](https://zenhub.io) 5 | [![Join the chat at https://gitter.im/aurelia/discuss](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/aurelia/discuss?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 6 | [![CircleCI](https://circleci.com/gh/aurelia/aurelia-loader.svg?style=shield)](https://circleci.com/gh/aurelia/aurelia-loader) 7 | 8 | This library is part of the [Aurelia](http://www.aurelia.io/) platform and contains an abstract module which specifies an interface for loading modules and view templates. 9 | 10 | > To keep up to date on [Aurelia](http://www.aurelia.io/), please visit and subscribe to [the official blog](http://blog.aurelia.io/) and [our email list](http://eepurl.com/ces50j). We also invite you to [follow us on twitter](https://twitter.com/aureliaeffect). If you have questions, please [join our community on Gitter](https://gitter.im/aurelia/discuss) or use [stack overflow](http://stackoverflow.com/search?q=aurelia). Documentation can be found [in our developer hub](http://aurelia.io/hub.html). If you would like to have deeper insight into our development process, please install the [ZenHub](https://zenhub.io) Chrome or Firefox Extension and visit any of our repository's boards. 11 | 12 | ## Platform Support 13 | 14 | This library can be used in the **browser** only. 15 | 16 | ## Building The Code 17 | 18 | To build the code, follow these steps. 19 | 20 | 1. Ensure that [NodeJS](http://nodejs.org/) is installed. This provides the platform on which the build tooling runs. 21 | 2. From the project folder, execute the following command: 22 | 23 | ```shell 24 | npm install 25 | ``` 26 | 3. Ensure that [Gulp](http://gulpjs.com/) is installed. If you need to install it, use the following command: 27 | 28 | ```shell 29 | npm install -g gulp 30 | ``` 31 | 4. To build the code, you can now run: 32 | 33 | ```shell 34 | gulp build 35 | ``` 36 | 5. You will find the compiled code in the `dist` folder, available in three module formats: AMD, CommonJS and ES6. 37 | 38 | 6. See `gulpfile.js` for other tasks related to generating the docs and linting. 39 | 40 | ## Running The Tests 41 | 42 | To run the unit tests, first ensure that you have followed the steps above in order to install all dependencies and successfully build the library. Once you have done that, proceed with these additional steps: 43 | 44 | 1. Ensure that the [Karma](http://karma-runner.github.io/) CLI is installed. If you need to install it, use the following command: 45 | 46 | ```shell 47 | npm install -g karma-cli 48 | ``` 49 | 2. Ensure that [jspm](http://jspm.io/) is installed. If you need to install it, use the following commnand: 50 | 51 | ```shell 52 | npm install -g jspm 53 | ``` 54 | 3. Install the client-side dependencies with jspm: 55 | 56 | ```shell 57 | jspm install 58 | ``` 59 | 60 | 4. You can now run the tests with this command: 61 | 62 | ```shell 63 | karma start 64 | ``` 65 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aurelia-loader", 3 | "version": "1.0.3", 4 | "description": "An abstract module which specifies an interface for loading modules and view templates.", 5 | "keywords": [ 6 | "aurelia", 7 | "loader", 8 | "modules" 9 | ], 10 | "homepage": "http://aurelia.io", 11 | "main": "dist/commonjs/aurelia-loader.js", 12 | "moduleType": "node", 13 | "license": "MIT", 14 | "authors": [ 15 | "Rob Eisenberg (http://robeisenberg.com/)" 16 | ], 17 | "repository": { 18 | "type": "git", 19 | "url": "http://github.com/aurelia/loader" 20 | }, 21 | "dependencies": { 22 | "aurelia-metadata": "^1.0.0", 23 | "aurelia-path": "^1.0.0" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /build/args.js: -------------------------------------------------------------------------------- 1 | var yargs = require('yargs'); 2 | 3 | var argv = yargs.argv, 4 | validBumpTypes = "major|minor|patch|prerelease".split("|"), 5 | bump = (argv.bump || 'patch').toLowerCase(); 6 | 7 | if(validBumpTypes.indexOf(bump) === -1) { 8 | throw new Error('Unrecognized bump "' + bump + '".'); 9 | } 10 | 11 | module.exports = { 12 | bump: bump 13 | }; 14 | -------------------------------------------------------------------------------- /build/babel-options.js: -------------------------------------------------------------------------------- 1 | var path = require('path'); 2 | var paths = require('./paths'); 3 | 4 | exports.base = function() { 5 | var config = { 6 | filename: '', 7 | filenameRelative: '', 8 | sourceMap: true, 9 | sourceRoot: '', 10 | moduleRoot: path.resolve('src').replace(/\\/g, '/'), 11 | moduleIds: false, 12 | comments: false, 13 | compact: false, 14 | code: true, 15 | presets: [ 'es2015-loose', 'stage-1' ], 16 | plugins: [ 17 | 'syntax-flow', 18 | 'transform-decorators-legacy', 19 | ] 20 | }; 21 | if (!paths.useTypeScriptForDTS) { 22 | config.plugins.push( 23 | ['babel-dts-generator', { 24 | packageName: paths.packageName, 25 | typings: '', 26 | suppressModulePath: true, 27 | suppressComments: false, 28 | memberOutputFilter: /^_.*/, 29 | suppressAmbientDeclaration: true 30 | }] 31 | ); 32 | }; 33 | config.plugins.push('transform-flow-strip-types'); 34 | return config; 35 | } 36 | 37 | exports.commonjs = function() { 38 | var options = exports.base(); 39 | options.plugins.push('transform-es2015-modules-commonjs'); 40 | return options; 41 | }; 42 | 43 | exports.amd = function() { 44 | var options = exports.base(); 45 | options.plugins.push('transform-es2015-modules-amd'); 46 | return options; 47 | }; 48 | 49 | exports.system = function() { 50 | var options = exports.base(); 51 | options.plugins.push('transform-es2015-modules-systemjs'); 52 | return options; 53 | }; 54 | 55 | exports.es2015 = function() { 56 | var options = exports.base(); 57 | options.presets = ['stage-1'] 58 | return options; 59 | }; 60 | 61 | exports['native-modules'] = function() { 62 | var options = exports.base(); 63 | options.presets[0] = 'es2015-loose-native-modules'; 64 | return options; 65 | } 66 | -------------------------------------------------------------------------------- /build/paths.js: -------------------------------------------------------------------------------- 1 | var path = require('path'); 2 | var fs = require('fs'); 3 | 4 | // hide warning // 5 | var emitter = require('events'); 6 | emitter.defaultMaxListeners = 20; 7 | 8 | var appRoot = 'src/'; 9 | var pkg = JSON.parse(fs.readFileSync('./package.json', 'utf-8')); 10 | 11 | var paths = { 12 | root: appRoot, 13 | source: appRoot + '**/*.js', 14 | html: appRoot + '**/*.html', 15 | style: 'styles/**/*.css', 16 | output: 'dist/', 17 | doc:'./doc', 18 | e2eSpecsSrc: 'test/e2e/src/*.js', 19 | e2eSpecsDist: 'test/e2e/dist/', 20 | packageName: pkg.name, 21 | ignore: [], 22 | useTypeScriptForDTS: false, 23 | importsToAdd: [], 24 | sort: false 25 | }; 26 | 27 | paths.files = [ 28 | 'template-dependency.js', 29 | 'template-registry-entry.js', 30 | 'loader.js' 31 | ].map(function(file){ 32 | return paths.root + file; 33 | }); 34 | 35 | module.exports = paths; 36 | -------------------------------------------------------------------------------- /build/tasks/build.js: -------------------------------------------------------------------------------- 1 | var gulp = require('gulp'); 2 | var runSequence = require('run-sequence'); 3 | var to5 = require('gulp-babel'); 4 | var paths = require('../paths'); 5 | var compilerOptions = require('../babel-options'); 6 | var compilerTsOptions = require('../typescript-options'); 7 | var assign = Object.assign || require('object.assign'); 8 | var through2 = require('through2'); 9 | var concat = require('gulp-concat'); 10 | var insert = require('gulp-insert'); 11 | var rename = require('gulp-rename'); 12 | var tools = require('aurelia-tools'); 13 | var ts = require('gulp-typescript'); 14 | var gutil = require('gulp-util'); 15 | var gulpIgnore = require('gulp-ignore'); 16 | var merge = require('merge2'); 17 | var jsName = paths.packageName + '.js'; 18 | var compileToModules = ['es2015', 'commonjs', 'amd', 'system', 'native-modules']; 19 | 20 | function cleanGeneratedCode() { 21 | return through2.obj(function(file, enc, callback) { 22 | file.contents = new Buffer(tools.cleanGeneratedCode(file.contents.toString('utf8'))); 23 | this.push(file); 24 | return callback(); 25 | }); 26 | } 27 | 28 | gulp.task('build-index', function() { 29 | var importsToAdd = paths.importsToAdd.slice(); 30 | 31 | var src = gulp.src(paths.files); 32 | 33 | if (paths.sort) { 34 | src = src.pipe(tools.sortFiles()); 35 | } 36 | 37 | if (paths.ignore) { 38 | paths.ignore.forEach(function(filename){ 39 | src = src.pipe(gulpIgnore.exclude(filename)); 40 | }); 41 | } 42 | 43 | return src.pipe(through2.obj(function(file, enc, callback) { 44 | file.contents = new Buffer(tools.extractImports(file.contents.toString('utf8'), importsToAdd)); 45 | this.push(file); 46 | return callback(); 47 | })) 48 | .pipe(concat(jsName)) 49 | .pipe(insert.transform(function(contents) { 50 | return tools.createImportBlock(importsToAdd) + contents; 51 | })) 52 | .pipe(gulp.dest(paths.output)); 53 | }); 54 | 55 | function gulpFileFromString(filename, string) { 56 | var src = require('stream').Readable({ objectMode: true }); 57 | src._read = function() { 58 | this.push(new gutil.File({ cwd: paths.appRoot, base: paths.output, path: filename, contents: new Buffer(string) })) 59 | this.push(null) 60 | } 61 | return src; 62 | } 63 | 64 | function srcForBabel() { 65 | return merge( 66 | gulp.src(paths.output + jsName), 67 | gulpFileFromString(paths.output + 'index.js', "export * from './" + paths.packageName + "';") 68 | ); 69 | } 70 | 71 | function srcForTypeScript() { 72 | return gulp 73 | .src(paths.output + paths.packageName + '.js') 74 | .pipe(rename(function (path) { 75 | if (path.extname == '.js') { 76 | path.extname = '.ts'; 77 | } 78 | })); 79 | } 80 | 81 | compileToModules.forEach(function(moduleType){ 82 | gulp.task('build-babel-' + moduleType, function () { 83 | return srcForBabel() 84 | .pipe(to5(assign({}, compilerOptions[moduleType]()))) 85 | .pipe(cleanGeneratedCode()) 86 | .pipe(gulp.dest(paths.output + moduleType)); 87 | }); 88 | 89 | if (moduleType === 'native-modules') return; // typescript doesn't support the combination of: es5 + native modules 90 | 91 | gulp.task('build-ts-' + moduleType, function () { 92 | var tsProject = ts.createProject( 93 | compilerTsOptions({ module: moduleType, target: moduleType == 'es2015' ? 'es2015' : 'es5' }), ts.reporter.defaultReporter()); 94 | var tsResult = srcForTypeScript().pipe(ts(tsProject)); 95 | return tsResult.js 96 | .pipe(gulp.dest(paths.output + moduleType)); 97 | }); 98 | }); 99 | 100 | gulp.task('build-dts', function() { 101 | var tsProject = ts.createProject( 102 | compilerTsOptions({ removeComments: false, target: "es2015", module: "es2015" }), ts.reporter.defaultReporter()); 103 | var tsResult = srcForTypeScript().pipe(ts(tsProject)); 104 | return tsResult.dts 105 | .pipe(gulp.dest(paths.output)); 106 | }); 107 | 108 | gulp.task('build', function(callback) { 109 | return runSequence( 110 | 'clean', 111 | 'build-index', 112 | compileToModules 113 | .map(function(moduleType) { return 'build-babel-' + moduleType }) 114 | .concat(paths.useTypeScriptForDTS ? ['build-dts'] : []), 115 | callback 116 | ); 117 | }); 118 | 119 | gulp.task('build-ts', function(callback) { 120 | return runSequence( 121 | 'clean', 122 | 'build-index', 123 | 'build-babel-native-modules', 124 | compileToModules 125 | .filter(function(moduleType) { return moduleType !== 'native-modules' }) 126 | .map(function(moduleType) { return 'build-ts-' + moduleType }) 127 | .concat(paths.useTypeScriptForDTS ? ['build-dts'] : []), 128 | callback 129 | ); 130 | }); 131 | -------------------------------------------------------------------------------- /build/tasks/clean.js: -------------------------------------------------------------------------------- 1 | var gulp = require('gulp'); 2 | var paths = require('../paths'); 3 | var del = require('del'); 4 | var vinylPaths = require('vinyl-paths'); 5 | 6 | gulp.task('clean', function() { 7 | return gulp.src([paths.output]) 8 | .pipe(vinylPaths(del)); 9 | }); 10 | -------------------------------------------------------------------------------- /build/tasks/dev.js: -------------------------------------------------------------------------------- 1 | var gulp = require('gulp'); 2 | var tools = require('aurelia-tools'); 3 | 4 | gulp.task('update-own-deps', function(){ 5 | tools.updateOwnDependenciesFromLocalRepositories(); 6 | }); 7 | 8 | gulp.task('build-dev-env', function () { 9 | tools.buildDevEnv(); 10 | }); 11 | -------------------------------------------------------------------------------- /build/tasks/doc.js: -------------------------------------------------------------------------------- 1 | var gulp = require('gulp'); 2 | var paths = require('../paths'); 3 | var typedoc = require('gulp-typedoc'); 4 | var runSequence = require('run-sequence'); 5 | var through2 = require('through2'); 6 | 7 | gulp.task('doc-generate', function(){ 8 | return gulp.src([paths.output + paths.packageName + '.d.ts']) 9 | .pipe(typedoc({ 10 | target: 'es6', 11 | includeDeclarations: true, 12 | moduleResolution: 'node', 13 | json: paths.doc + '/api.json', 14 | name: paths.packageName + '-docs',  15 | mode: 'modules', 16 | excludeExternals: true, 17 | ignoreCompilerErrors: false, 18 | version: true 19 | })); 20 | }); 21 | 22 | gulp.task('doc-shape', function(){ 23 | return gulp.src([paths.doc + '/api.json']) 24 | .pipe(through2.obj(function(file, enc, callback) { 25 | var json = JSON.parse(file.contents.toString('utf8')).children[0]; 26 | 27 | json = { 28 | name: paths.packageName, 29 | children: json.children, 30 | groups: json.groups 31 | }; 32 | 33 | file.contents = new Buffer(JSON.stringify(json)); 34 | this.push(file); 35 | return callback(); 36 | })) 37 | .pipe(gulp.dest(paths.doc)); 38 | }); 39 | 40 | gulp.task('doc', function(callback){ 41 | return runSequence( 42 | 'doc-generate', 43 | 'doc-shape', 44 | callback 45 | ); 46 | }); 47 | -------------------------------------------------------------------------------- /build/tasks/lint.js: -------------------------------------------------------------------------------- 1 | var gulp = require('gulp'); 2 | var paths = require('../paths'); 3 | var eslint = require('gulp-eslint'); 4 | 5 | gulp.task('lint', function() { 6 | return gulp.src(paths.source) 7 | .pipe(eslint()) 8 | .pipe(eslint.format()) 9 | .pipe(eslint.failOnError()); 10 | }); 11 | -------------------------------------------------------------------------------- /build/tasks/prepare-release.js: -------------------------------------------------------------------------------- 1 | var gulp = require('gulp'); 2 | var runSequence = require('run-sequence'); 3 | var paths = require('../paths'); 4 | var fs = require('fs'); 5 | var bump = require('gulp-bump'); 6 | var args = require('../args'); 7 | var conventionalChangelog = require('gulp-conventional-changelog'); 8 | 9 | gulp.task('changelog', function () { 10 | return gulp.src(paths.doc + '/CHANGELOG.md', { 11 | buffer: false 12 | }).pipe(conventionalChangelog({ 13 | preset: 'angular' 14 | })) 15 | .pipe(gulp.dest(paths.doc)); 16 | }); 17 | 18 | gulp.task('bump-version', function(){ 19 | return gulp.src(['./package.json', './bower.json']) 20 | .pipe(bump({type:args.bump })) //major|minor|patch|prerelease 21 | .pipe(gulp.dest('./')); 22 | }); 23 | 24 | gulp.task('prepare-release', function(callback){ 25 | return runSequence( 26 | 'build', 27 | 'lint', 28 | 'bump-version', 29 | 'doc', 30 | 'changelog', 31 | callback 32 | ); 33 | }); 34 | -------------------------------------------------------------------------------- /build/tasks/test.js: -------------------------------------------------------------------------------- 1 | var gulp = require('gulp'); 2 | var Karma = require('karma').Server; 3 | 4 | /** 5 | * Run test once and exit 6 | */ 7 | gulp.task('test', function (done) { 8 | new Karma({ 9 | configFile: __dirname + '/../../karma.conf.js', 10 | singleRun: true 11 | }, done).start(); 12 | }); 13 | 14 | /** 15 | * Watch for file changes and re-run tests on each change 16 | */ 17 | gulp.task('tdd', function (done) { 18 | new Karma({ 19 | configFile: __dirname + '/../../karma.conf.js' 20 | }, done).start(); 21 | }); 22 | 23 | /** 24 | * Run test once with code coverage and exit 25 | */ 26 | gulp.task('cover', function (done) { 27 | new Karma({ 28 | configFile: __dirname + '/../../karma.conf.js', 29 | singleRun: true, 30 | reporters: ['coverage'], 31 | preprocessors: { 32 | 'test/**/*.js': ['babel'], 33 | 'src/**/*.js': ['babel', 'coverage'] 34 | }, 35 | coverageReporter: { 36 | type: 'html', 37 | dir: 'build/reports/coverage' 38 | } 39 | }, done).start(); 40 | }); 41 | -------------------------------------------------------------------------------- /build/typescript-options.js: -------------------------------------------------------------------------------- 1 | var tsconfig = require('../tsconfig.json'); 2 | var assign = Object.assign || require('object.assign'); 3 | 4 | module.exports = function(override) { 5 | return assign(tsconfig.compilerOptions, { 6 | "target": override && override.target || "es5", 7 | "typescript": require('typescript') 8 | }, override || {}); 9 | } 10 | -------------------------------------------------------------------------------- /config.js: -------------------------------------------------------------------------------- 1 | System.config({ 2 | defaultJSExtensions: true, 3 | transpiler: false, 4 | paths: { 5 | "github:*": "jspm_packages/github/*", 6 | "aurelia-loader/*": "dist/*.js", 7 | "npm:*": "jspm_packages/npm/*" 8 | }, 9 | 10 | map: { 11 | "aurelia-metadata": "npm:aurelia-metadata@1.0.0", 12 | "aurelia-path": "npm:aurelia-path@1.1.1", 13 | "npm:aurelia-metadata@1.0.0": { 14 | "aurelia-pal": "npm:aurelia-pal@1.0.0" 15 | } 16 | } 17 | }); 18 | -------------------------------------------------------------------------------- /dist/amd/aurelia-loader.js: -------------------------------------------------------------------------------- 1 | define(['exports', 'aurelia-path', 'aurelia-metadata'], function (exports, _aureliaPath, _aureliaMetadata) { 2 | 'use strict'; 3 | 4 | Object.defineProperty(exports, "__esModule", { 5 | value: true 6 | }); 7 | exports.Loader = exports.TemplateRegistryEntry = exports.TemplateDependency = undefined; 8 | 9 | var _createClass = function () { 10 | function defineProperties(target, props) { 11 | for (var i = 0; i < props.length; i++) { 12 | var descriptor = props[i]; 13 | descriptor.enumerable = descriptor.enumerable || false; 14 | descriptor.configurable = true; 15 | if ("value" in descriptor) descriptor.writable = true; 16 | Object.defineProperty(target, descriptor.key, descriptor); 17 | } 18 | } 19 | 20 | return function (Constructor, protoProps, staticProps) { 21 | if (protoProps) defineProperties(Constructor.prototype, protoProps); 22 | if (staticProps) defineProperties(Constructor, staticProps); 23 | return Constructor; 24 | }; 25 | }(); 26 | 27 | 28 | 29 | var TemplateDependency = exports.TemplateDependency = function TemplateDependency(src, name) { 30 | 31 | 32 | this.src = src; 33 | this.name = name; 34 | }; 35 | 36 | var TemplateRegistryEntry = exports.TemplateRegistryEntry = function () { 37 | function TemplateRegistryEntry(address) { 38 | 39 | 40 | this.templateIsLoaded = false; 41 | this.factoryIsReady = false; 42 | this.resources = null; 43 | this.dependencies = null; 44 | 45 | this.address = address; 46 | this.onReady = null; 47 | this._template = null; 48 | this._factory = null; 49 | } 50 | 51 | TemplateRegistryEntry.prototype.addDependency = function addDependency(src, name) { 52 | var finalSrc = typeof src === 'string' ? (0, _aureliaPath.relativeToFile)(src, this.address) : _aureliaMetadata.Origin.get(src).moduleId; 53 | 54 | this.dependencies.push(new TemplateDependency(finalSrc, name)); 55 | }; 56 | 57 | _createClass(TemplateRegistryEntry, [{ 58 | key: 'template', 59 | get: function get() { 60 | return this._template; 61 | }, 62 | set: function set(value) { 63 | var address = this.address; 64 | var requires = void 0; 65 | var current = void 0; 66 | var src = void 0; 67 | var dependencies = void 0; 68 | 69 | this._template = value; 70 | this.templateIsLoaded = true; 71 | 72 | requires = value.content.querySelectorAll('require'); 73 | dependencies = this.dependencies = new Array(requires.length); 74 | 75 | for (var i = 0, ii = requires.length; i < ii; ++i) { 76 | current = requires[i]; 77 | src = current.getAttribute('from'); 78 | 79 | if (!src) { 80 | throw new Error(' element in ' + address + ' has no "from" attribute.'); 81 | } 82 | 83 | dependencies[i] = new TemplateDependency((0, _aureliaPath.relativeToFile)(src, address), current.getAttribute('as')); 84 | 85 | if (current.parentNode) { 86 | current.parentNode.removeChild(current); 87 | } 88 | } 89 | } 90 | }, { 91 | key: 'factory', 92 | get: function get() { 93 | return this._factory; 94 | }, 95 | set: function set(value) { 96 | this._factory = value; 97 | this.factoryIsReady = true; 98 | } 99 | }]); 100 | 101 | return TemplateRegistryEntry; 102 | }(); 103 | 104 | var Loader = exports.Loader = function () { 105 | function Loader() { 106 | 107 | 108 | this.templateRegistry = {}; 109 | } 110 | 111 | Loader.prototype.map = function map(id, source) { 112 | throw new Error('Loaders must implement map(id, source).'); 113 | }; 114 | 115 | Loader.prototype.normalizeSync = function normalizeSync(moduleId, relativeTo) { 116 | throw new Error('Loaders must implement normalizeSync(moduleId, relativeTo).'); 117 | }; 118 | 119 | Loader.prototype.normalize = function normalize(moduleId, relativeTo) { 120 | throw new Error('Loaders must implement normalize(moduleId: string, relativeTo: string): Promise.'); 121 | }; 122 | 123 | Loader.prototype.loadModule = function loadModule(id) { 124 | throw new Error('Loaders must implement loadModule(id).'); 125 | }; 126 | 127 | Loader.prototype.loadAllModules = function loadAllModules(ids) { 128 | throw new Error('Loader must implement loadAllModules(ids).'); 129 | }; 130 | 131 | Loader.prototype.loadTemplate = function loadTemplate(url) { 132 | throw new Error('Loader must implement loadTemplate(url).'); 133 | }; 134 | 135 | Loader.prototype.loadText = function loadText(url) { 136 | throw new Error('Loader must implement loadText(url).'); 137 | }; 138 | 139 | Loader.prototype.applyPluginToUrl = function applyPluginToUrl(url, pluginName) { 140 | throw new Error('Loader must implement applyPluginToUrl(url, pluginName).'); 141 | }; 142 | 143 | Loader.prototype.addPlugin = function addPlugin(pluginName, implementation) { 144 | throw new Error('Loader must implement addPlugin(pluginName, implementation).'); 145 | }; 146 | 147 | Loader.prototype.getOrCreateTemplateRegistryEntry = function getOrCreateTemplateRegistryEntry(address) { 148 | return this.templateRegistry[address] || (this.templateRegistry[address] = new TemplateRegistryEntry(address)); 149 | }; 150 | 151 | return Loader; 152 | }(); 153 | }); -------------------------------------------------------------------------------- /dist/amd/index.js: -------------------------------------------------------------------------------- 1 | define(['exports', './aurelia-loader'], function (exports, _aureliaLoader) { 2 | 'use strict'; 3 | 4 | Object.defineProperty(exports, "__esModule", { 5 | value: true 6 | }); 7 | Object.keys(_aureliaLoader).forEach(function (key) { 8 | if (key === "default" || key === "__esModule") return; 9 | Object.defineProperty(exports, key, { 10 | enumerable: true, 11 | get: function () { 12 | return _aureliaLoader[key]; 13 | } 14 | }); 15 | }); 16 | }); -------------------------------------------------------------------------------- /dist/aurelia-loader.d.ts: -------------------------------------------------------------------------------- 1 | import { 2 | relativeToFile 3 | } from 'aurelia-path'; 4 | import { 5 | Origin 6 | } from 'aurelia-metadata'; 7 | 8 | /*eslint no-unused-vars:0*/ 9 | /** 10 | * Represents a plugin to the module loader. 11 | */ 12 | export declare interface LoaderPlugin { 13 | 14 | /** 15 | * Fetches the resource. 16 | * @param address The address of the resource. 17 | * @return A Promise for the requested resouce. 18 | */ 19 | fetch(address: string): Promise; 20 | } 21 | 22 | /** 23 | * Represents a dependency of a template. 24 | */ 25 | export declare class TemplateDependency { 26 | 27 | /** 28 | * The source of the dependency. 29 | */ 30 | src: string; 31 | 32 | /** 33 | * The local name of the src when used in the template. 34 | */ 35 | name: string; 36 | 37 | /** 38 | * Creates a template dependency. 39 | * @param src The source of the dependency. 40 | * @param name The local name of the src when used in the template. 41 | */ 42 | constructor(src: string, name?: string); 43 | } 44 | 45 | /** 46 | * Represents an entry in the template registry. 47 | */ 48 | export declare class TemplateRegistryEntry { 49 | 50 | /** 51 | * The address of the template that this entry represents. 52 | */ 53 | address: string; 54 | 55 | /** 56 | * Indicates whether or not the associated template is loaded . 57 | */ 58 | templateIsLoaded: boolean; 59 | 60 | /** 61 | * Indicates whether the factory is ready to be used to create instances of the associated template. 62 | */ 63 | factoryIsReady: boolean; 64 | 65 | /** 66 | * Sets the resources associated with this entry. 67 | */ 68 | resources: Object; 69 | 70 | /** 71 | * The dependencies of the associated template. Dependencies are not available until after the template is loaded. 72 | */ 73 | dependencies: TemplateDependency[]; 74 | 75 | /** 76 | * Creates an instance of TemplateRegistryEntry. 77 | * @param address The address of the template that this entry represents. 78 | */ 79 | constructor(address: string); 80 | 81 | /** 82 | * Gets the template for this registry entry. 83 | */ 84 | template: Element; 85 | 86 | /** 87 | * Gets the factory capable of creating instances of this template. 88 | */ 89 | factory: any; 90 | 91 | /** 92 | * Adds a dependency to this template registry entry. Cannot be called until after the template is set. 93 | * @param src The dependency instance or a relative path to its module. 94 | * @param name An optional local name by which this dependency is used in the template. 95 | */ 96 | addDependency(src: string | Function, name?: string): void; 97 | } 98 | 99 | /** 100 | * A generic resource loader, for loading modules, html, css and more. 101 | */ 102 | /** 103 | * A generic resource loader, for loading modules, html, css and more. 104 | */ 105 | export declare class Loader { 106 | 107 | /** 108 | * Creates an instance of Loader. 109 | */ 110 | constructor(); 111 | 112 | /** 113 | * Maps a module id to a source. 114 | * @param id The module id. 115 | * @param source The source to map the module to. 116 | */ 117 | map(id: string, source: string): void; 118 | 119 | /** 120 | * Normalizes a module id. 121 | * @param moduleId The module id to normalize. 122 | * @param relativeTo What the module id should be normalized relative to. 123 | * @return The normalized module id. 124 | */ 125 | normalizeSync(moduleId: string, relativeTo: string): string; 126 | 127 | /** 128 | * Normalizes a module id. 129 | * @param moduleId The module id to normalize. 130 | * @param relativeTo What the module id should be normalized relative to. 131 | * @return A promise for the normalized module id. 132 | */ 133 | normalize(moduleId: string, relativeTo: string): Promise; 134 | 135 | /** 136 | * Loads a module. 137 | * @param id The module id to normalize. 138 | * @return A Promise for the loaded module. 139 | */ 140 | loadModule(id: string): Promise; 141 | 142 | /** 143 | * Loads a collection of modules. 144 | * @param ids The set of module ids to load. 145 | * @return A Promise for an array of loaded modules. 146 | */ 147 | loadAllModules(ids: string[]): Promise; 148 | 149 | /** 150 | * Loads a template. 151 | * @param url The url of the template to load. 152 | * @return A Promise for a TemplateRegistryEntry containing the template. 153 | */ 154 | loadTemplate(url: string): Promise; 155 | 156 | /** 157 | * Loads a text-based resource. 158 | * @param url The url of the text file to load. 159 | * @return A Promise for text content. 160 | */ 161 | loadText(url: string): Promise; 162 | 163 | /** 164 | * Alters a module id so that it includes a plugin loader. 165 | * @param url The url of the module to load. 166 | * @param pluginName The plugin to apply to the module id. 167 | * @return The plugin-based module id. 168 | */ 169 | applyPluginToUrl(url: string, pluginName: string): string; 170 | 171 | /** 172 | * Registers a plugin with the loader. 173 | * @param pluginName The name of the plugin. 174 | * @param implementation The plugin implementation. 175 | */ 176 | addPlugin(pluginName: string, implementation: LoaderPlugin): void; 177 | 178 | /** 179 | * Gets or creates a TemplateRegistryEntry for the provided address. 180 | * @param address The address of the template. 181 | * @return The located or created TemplateRegistryEntry. 182 | */ 183 | getOrCreateTemplateRegistryEntry(address: string): TemplateRegistryEntry; 184 | } -------------------------------------------------------------------------------- /dist/aurelia-loader.js: -------------------------------------------------------------------------------- 1 | import {relativeToFile} from 'aurelia-path'; 2 | import {Origin} from 'aurelia-metadata'; 3 | 4 | /** 5 | * Represents a dependency of a template. 6 | */ 7 | export class TemplateDependency { 8 | /** 9 | * The source of the dependency. 10 | */ 11 | src: string; 12 | /** 13 | * The local name of the src when used in the template. 14 | */ 15 | name: string; 16 | 17 | /** 18 | * Creates a template dependency. 19 | * @param src The source of the dependency. 20 | * @param name The local name of the src when used in the template. 21 | */ 22 | constructor(src: string, name?: string) { 23 | this.src = src; 24 | this.name = name; 25 | } 26 | } 27 | 28 | /** 29 | * Represents an entry in the template registry. 30 | */ 31 | export class TemplateRegistryEntry { 32 | /** 33 | * The address of the template that this entry represents. 34 | */ 35 | address: string; 36 | 37 | /** 38 | * Indicates whether or not the associated template is loaded . 39 | */ 40 | templateIsLoaded: boolean = false; 41 | 42 | /** 43 | * Indicates whether the factory is ready to be used to create instances of the associated template. 44 | */ 45 | factoryIsReady: boolean = false; 46 | 47 | /** 48 | * Sets the resources associated with this entry. 49 | */ 50 | resources: Object = null; 51 | 52 | /** 53 | * The dependencies of the associated template. Dependencies are not available until after the template is loaded. 54 | */ 55 | dependencies: TemplateDependency[] = null; 56 | 57 | /** 58 | * Creates an instance of TemplateRegistryEntry. 59 | * @param address The address of the template that this entry represents. 60 | */ 61 | constructor(address: string) { 62 | this.address = address; 63 | this.onReady = null; 64 | this._template = null; 65 | this._factory = null; 66 | } 67 | 68 | /** 69 | * Gets the template for this registry entry. 70 | */ 71 | get template(): Element { 72 | return this._template; 73 | } 74 | 75 | /** 76 | * Sets the template for this registry entry. 77 | */ 78 | set template(value: Element) { 79 | let address = this.address; 80 | let requires; 81 | let current; 82 | let src; 83 | let dependencies; 84 | 85 | this._template = value; 86 | this.templateIsLoaded = true; 87 | 88 | requires = value.content.querySelectorAll('require'); 89 | dependencies = this.dependencies = new Array(requires.length); 90 | 91 | for (let i = 0, ii = requires.length; i < ii; ++i) { 92 | current = requires[i]; 93 | src = current.getAttribute('from'); 94 | 95 | if (!src) { 96 | throw new Error(` element in ${address} has no "from" attribute.`); 97 | } 98 | 99 | dependencies[i] = new TemplateDependency( 100 | relativeToFile(src, address), 101 | current.getAttribute('as') 102 | ); 103 | 104 | if (current.parentNode) { 105 | current.parentNode.removeChild(current); 106 | } 107 | } 108 | } 109 | 110 | /** 111 | * Gets the factory capable of creating instances of this template. 112 | */ 113 | get factory() { 114 | return this._factory; 115 | } 116 | 117 | /** 118 | * Sets the factory capable of creating instances of this template. 119 | */ 120 | set factory(value) { 121 | this._factory = value; 122 | this.factoryIsReady = true; 123 | } 124 | 125 | /** 126 | * Adds a dependency to this template registry entry. Cannot be called until after the template is set. 127 | * @param src The dependency instance or a relative path to its module. 128 | * @param name An optional local name by which this dependency is used in the template. 129 | */ 130 | addDependency(src: string|Function, name?: string): void { 131 | let finalSrc = typeof src === 'string' 132 | ? relativeToFile(src, this.address) 133 | : Origin.get(src).moduleId; 134 | 135 | this.dependencies.push(new TemplateDependency(finalSrc, name)); 136 | } 137 | } 138 | 139 | /*eslint no-unused-vars:0*/ 140 | /** 141 | * Represents a plugin to the module loader. 142 | */ 143 | interface LoaderPlugin { 144 | /** 145 | * Fetches the resource. 146 | * @param address The address of the resource. 147 | * @return A Promise for the requested resouce. 148 | */ 149 | fetch(address: string): Promise; 150 | } 151 | 152 | /** 153 | * A generic resource loader, for loading modules, html, css and more. 154 | */ 155 | export class Loader { 156 | /** 157 | * Creates an instance of Loader. 158 | */ 159 | constructor() { 160 | this.templateRegistry = {}; 161 | } 162 | 163 | /** 164 | * Maps a module id to a source. 165 | * @param id The module id. 166 | * @param source The source to map the module to. 167 | */ 168 | map(id: string, source: string): void { 169 | throw new Error('Loaders must implement map(id, source).'); 170 | } 171 | 172 | /** 173 | * Normalizes a module id. 174 | * @param moduleId The module id to normalize. 175 | * @param relativeTo What the module id should be normalized relative to. 176 | * @return The normalized module id. 177 | */ 178 | normalizeSync(moduleId: string, relativeTo: string): string { 179 | throw new Error('Loaders must implement normalizeSync(moduleId, relativeTo).'); 180 | } 181 | 182 | /** 183 | * Normalizes a module id. 184 | * @param moduleId The module id to normalize. 185 | * @param relativeTo What the module id should be normalized relative to. 186 | * @return A promise for the normalized module id. 187 | */ 188 | normalize(moduleId: string, relativeTo: string): Promise { 189 | throw new Error('Loaders must implement normalize(moduleId: string, relativeTo: string): Promise.'); 190 | } 191 | 192 | /** 193 | * Loads a module. 194 | * @param id The module id to normalize. 195 | * @return A Promise for the loaded module. 196 | */ 197 | loadModule(id: string): Promise { 198 | throw new Error('Loaders must implement loadModule(id).'); 199 | } 200 | 201 | /** 202 | * Loads a collection of modules. 203 | * @param ids The set of module ids to load. 204 | * @return A Promise for an array of loaded modules. 205 | */ 206 | loadAllModules(ids: string[]): Promise { 207 | throw new Error('Loader must implement loadAllModules(ids).'); 208 | } 209 | 210 | /** 211 | * Loads a template. 212 | * @param url The url of the template to load. 213 | * @return A Promise for a TemplateRegistryEntry containing the template. 214 | */ 215 | loadTemplate(url: string): Promise { 216 | throw new Error('Loader must implement loadTemplate(url).'); 217 | } 218 | 219 | /** 220 | * Loads a text-based resource. 221 | * @param url The url of the text file to load. 222 | * @return A Promise for text content. 223 | */ 224 | loadText(url: string): Promise { 225 | throw new Error('Loader must implement loadText(url).'); 226 | } 227 | 228 | /** 229 | * Alters a module id so that it includes a plugin loader. 230 | * @param url The url of the module to load. 231 | * @param pluginName The plugin to apply to the module id. 232 | * @return The plugin-based module id. 233 | */ 234 | applyPluginToUrl(url: string, pluginName: string): string { 235 | throw new Error('Loader must implement applyPluginToUrl(url, pluginName).'); 236 | } 237 | 238 | /** 239 | * Registers a plugin with the loader. 240 | * @param pluginName The name of the plugin. 241 | * @param implementation The plugin implementation. 242 | */ 243 | addPlugin(pluginName: string, implementation: LoaderPlugin): void { 244 | throw new Error('Loader must implement addPlugin(pluginName, implementation).'); 245 | } 246 | 247 | /** 248 | * Gets or creates a TemplateRegistryEntry for the provided address. 249 | * @param address The address of the template. 250 | * @return The located or created TemplateRegistryEntry. 251 | */ 252 | getOrCreateTemplateRegistryEntry(address: string): TemplateRegistryEntry { 253 | return this.templateRegistry[address] || (this.templateRegistry[address] = new TemplateRegistryEntry(address)); 254 | } 255 | } 256 | -------------------------------------------------------------------------------- /dist/commonjs/aurelia-loader.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: true 5 | }); 6 | exports.Loader = exports.TemplateRegistryEntry = exports.TemplateDependency = undefined; 7 | 8 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 9 | 10 | var _aureliaPath = require('aurelia-path'); 11 | 12 | var _aureliaMetadata = require('aurelia-metadata'); 13 | 14 | 15 | 16 | var TemplateDependency = exports.TemplateDependency = function TemplateDependency(src, name) { 17 | 18 | 19 | this.src = src; 20 | this.name = name; 21 | }; 22 | 23 | var TemplateRegistryEntry = exports.TemplateRegistryEntry = function () { 24 | function TemplateRegistryEntry(address) { 25 | 26 | 27 | this.templateIsLoaded = false; 28 | this.factoryIsReady = false; 29 | this.resources = null; 30 | this.dependencies = null; 31 | 32 | this.address = address; 33 | this.onReady = null; 34 | this._template = null; 35 | this._factory = null; 36 | } 37 | 38 | TemplateRegistryEntry.prototype.addDependency = function addDependency(src, name) { 39 | var finalSrc = typeof src === 'string' ? (0, _aureliaPath.relativeToFile)(src, this.address) : _aureliaMetadata.Origin.get(src).moduleId; 40 | 41 | this.dependencies.push(new TemplateDependency(finalSrc, name)); 42 | }; 43 | 44 | _createClass(TemplateRegistryEntry, [{ 45 | key: 'template', 46 | get: function get() { 47 | return this._template; 48 | }, 49 | set: function set(value) { 50 | var address = this.address; 51 | var requires = void 0; 52 | var current = void 0; 53 | var src = void 0; 54 | var dependencies = void 0; 55 | 56 | this._template = value; 57 | this.templateIsLoaded = true; 58 | 59 | requires = value.content.querySelectorAll('require'); 60 | dependencies = this.dependencies = new Array(requires.length); 61 | 62 | for (var i = 0, ii = requires.length; i < ii; ++i) { 63 | current = requires[i]; 64 | src = current.getAttribute('from'); 65 | 66 | if (!src) { 67 | throw new Error(' element in ' + address + ' has no "from" attribute.'); 68 | } 69 | 70 | dependencies[i] = new TemplateDependency((0, _aureliaPath.relativeToFile)(src, address), current.getAttribute('as')); 71 | 72 | if (current.parentNode) { 73 | current.parentNode.removeChild(current); 74 | } 75 | } 76 | } 77 | }, { 78 | key: 'factory', 79 | get: function get() { 80 | return this._factory; 81 | }, 82 | set: function set(value) { 83 | this._factory = value; 84 | this.factoryIsReady = true; 85 | } 86 | }]); 87 | 88 | return TemplateRegistryEntry; 89 | }(); 90 | 91 | var Loader = exports.Loader = function () { 92 | function Loader() { 93 | 94 | 95 | this.templateRegistry = {}; 96 | } 97 | 98 | Loader.prototype.map = function map(id, source) { 99 | throw new Error('Loaders must implement map(id, source).'); 100 | }; 101 | 102 | Loader.prototype.normalizeSync = function normalizeSync(moduleId, relativeTo) { 103 | throw new Error('Loaders must implement normalizeSync(moduleId, relativeTo).'); 104 | }; 105 | 106 | Loader.prototype.normalize = function normalize(moduleId, relativeTo) { 107 | throw new Error('Loaders must implement normalize(moduleId: string, relativeTo: string): Promise.'); 108 | }; 109 | 110 | Loader.prototype.loadModule = function loadModule(id) { 111 | throw new Error('Loaders must implement loadModule(id).'); 112 | }; 113 | 114 | Loader.prototype.loadAllModules = function loadAllModules(ids) { 115 | throw new Error('Loader must implement loadAllModules(ids).'); 116 | }; 117 | 118 | Loader.prototype.loadTemplate = function loadTemplate(url) { 119 | throw new Error('Loader must implement loadTemplate(url).'); 120 | }; 121 | 122 | Loader.prototype.loadText = function loadText(url) { 123 | throw new Error('Loader must implement loadText(url).'); 124 | }; 125 | 126 | Loader.prototype.applyPluginToUrl = function applyPluginToUrl(url, pluginName) { 127 | throw new Error('Loader must implement applyPluginToUrl(url, pluginName).'); 128 | }; 129 | 130 | Loader.prototype.addPlugin = function addPlugin(pluginName, implementation) { 131 | throw new Error('Loader must implement addPlugin(pluginName, implementation).'); 132 | }; 133 | 134 | Loader.prototype.getOrCreateTemplateRegistryEntry = function getOrCreateTemplateRegistryEntry(address) { 135 | return this.templateRegistry[address] || (this.templateRegistry[address] = new TemplateRegistryEntry(address)); 136 | }; 137 | 138 | return Loader; 139 | }(); -------------------------------------------------------------------------------- /dist/commonjs/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: true 5 | }); 6 | 7 | var _aureliaLoader = require('./aurelia-loader'); 8 | 9 | Object.keys(_aureliaLoader).forEach(function (key) { 10 | if (key === "default" || key === "__esModule") return; 11 | Object.defineProperty(exports, key, { 12 | enumerable: true, 13 | get: function get() { 14 | return _aureliaLoader[key]; 15 | } 16 | }); 17 | }); -------------------------------------------------------------------------------- /dist/es2015/aurelia-loader.js: -------------------------------------------------------------------------------- 1 | import { relativeToFile } from 'aurelia-path'; 2 | import { Origin } from 'aurelia-metadata'; 3 | 4 | export let TemplateDependency = class TemplateDependency { 5 | constructor(src, name) { 6 | this.src = src; 7 | this.name = name; 8 | } 9 | }; 10 | 11 | export let TemplateRegistryEntry = class TemplateRegistryEntry { 12 | constructor(address) { 13 | this.templateIsLoaded = false; 14 | this.factoryIsReady = false; 15 | this.resources = null; 16 | this.dependencies = null; 17 | 18 | this.address = address; 19 | this.onReady = null; 20 | this._template = null; 21 | this._factory = null; 22 | } 23 | 24 | get template() { 25 | return this._template; 26 | } 27 | 28 | set template(value) { 29 | let address = this.address; 30 | let requires; 31 | let current; 32 | let src; 33 | let dependencies; 34 | 35 | this._template = value; 36 | this.templateIsLoaded = true; 37 | 38 | requires = value.content.querySelectorAll('require'); 39 | dependencies = this.dependencies = new Array(requires.length); 40 | 41 | for (let i = 0, ii = requires.length; i < ii; ++i) { 42 | current = requires[i]; 43 | src = current.getAttribute('from'); 44 | 45 | if (!src) { 46 | throw new Error(` element in ${address} has no "from" attribute.`); 47 | } 48 | 49 | dependencies[i] = new TemplateDependency(relativeToFile(src, address), current.getAttribute('as')); 50 | 51 | if (current.parentNode) { 52 | current.parentNode.removeChild(current); 53 | } 54 | } 55 | } 56 | 57 | get factory() { 58 | return this._factory; 59 | } 60 | 61 | set factory(value) { 62 | this._factory = value; 63 | this.factoryIsReady = true; 64 | } 65 | 66 | addDependency(src, name) { 67 | let finalSrc = typeof src === 'string' ? relativeToFile(src, this.address) : Origin.get(src).moduleId; 68 | 69 | this.dependencies.push(new TemplateDependency(finalSrc, name)); 70 | } 71 | }; 72 | 73 | export let Loader = class Loader { 74 | constructor() { 75 | this.templateRegistry = {}; 76 | } 77 | 78 | map(id, source) { 79 | throw new Error('Loaders must implement map(id, source).'); 80 | } 81 | 82 | normalizeSync(moduleId, relativeTo) { 83 | throw new Error('Loaders must implement normalizeSync(moduleId, relativeTo).'); 84 | } 85 | 86 | normalize(moduleId, relativeTo) { 87 | throw new Error('Loaders must implement normalize(moduleId: string, relativeTo: string): Promise.'); 88 | } 89 | 90 | loadModule(id) { 91 | throw new Error('Loaders must implement loadModule(id).'); 92 | } 93 | 94 | loadAllModules(ids) { 95 | throw new Error('Loader must implement loadAllModules(ids).'); 96 | } 97 | 98 | loadTemplate(url) { 99 | throw new Error('Loader must implement loadTemplate(url).'); 100 | } 101 | 102 | loadText(url) { 103 | throw new Error('Loader must implement loadText(url).'); 104 | } 105 | 106 | applyPluginToUrl(url, pluginName) { 107 | throw new Error('Loader must implement applyPluginToUrl(url, pluginName).'); 108 | } 109 | 110 | addPlugin(pluginName, implementation) { 111 | throw new Error('Loader must implement addPlugin(pluginName, implementation).'); 112 | } 113 | 114 | getOrCreateTemplateRegistryEntry(address) { 115 | return this.templateRegistry[address] || (this.templateRegistry[address] = new TemplateRegistryEntry(address)); 116 | } 117 | }; -------------------------------------------------------------------------------- /dist/es2015/index.js: -------------------------------------------------------------------------------- 1 | export * from './aurelia-loader'; -------------------------------------------------------------------------------- /dist/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from 'aurelia-loader/aurelia-loader'; -------------------------------------------------------------------------------- /dist/native-modules/aurelia-loader.js: -------------------------------------------------------------------------------- 1 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 2 | 3 | 4 | 5 | import { relativeToFile } from 'aurelia-path'; 6 | import { Origin } from 'aurelia-metadata'; 7 | 8 | export var TemplateDependency = function TemplateDependency(src, name) { 9 | 10 | 11 | this.src = src; 12 | this.name = name; 13 | }; 14 | 15 | export var TemplateRegistryEntry = function () { 16 | function TemplateRegistryEntry(address) { 17 | 18 | 19 | this.templateIsLoaded = false; 20 | this.factoryIsReady = false; 21 | this.resources = null; 22 | this.dependencies = null; 23 | 24 | this.address = address; 25 | this.onReady = null; 26 | this._template = null; 27 | this._factory = null; 28 | } 29 | 30 | TemplateRegistryEntry.prototype.addDependency = function addDependency(src, name) { 31 | var finalSrc = typeof src === 'string' ? relativeToFile(src, this.address) : Origin.get(src).moduleId; 32 | 33 | this.dependencies.push(new TemplateDependency(finalSrc, name)); 34 | }; 35 | 36 | _createClass(TemplateRegistryEntry, [{ 37 | key: 'template', 38 | get: function get() { 39 | return this._template; 40 | }, 41 | set: function set(value) { 42 | var address = this.address; 43 | var requires = void 0; 44 | var current = void 0; 45 | var src = void 0; 46 | var dependencies = void 0; 47 | 48 | this._template = value; 49 | this.templateIsLoaded = true; 50 | 51 | requires = value.content.querySelectorAll('require'); 52 | dependencies = this.dependencies = new Array(requires.length); 53 | 54 | for (var i = 0, ii = requires.length; i < ii; ++i) { 55 | current = requires[i]; 56 | src = current.getAttribute('from'); 57 | 58 | if (!src) { 59 | throw new Error(' element in ' + address + ' has no "from" attribute.'); 60 | } 61 | 62 | dependencies[i] = new TemplateDependency(relativeToFile(src, address), current.getAttribute('as')); 63 | 64 | if (current.parentNode) { 65 | current.parentNode.removeChild(current); 66 | } 67 | } 68 | } 69 | }, { 70 | key: 'factory', 71 | get: function get() { 72 | return this._factory; 73 | }, 74 | set: function set(value) { 75 | this._factory = value; 76 | this.factoryIsReady = true; 77 | } 78 | }]); 79 | 80 | return TemplateRegistryEntry; 81 | }(); 82 | 83 | export var Loader = function () { 84 | function Loader() { 85 | 86 | 87 | this.templateRegistry = {}; 88 | } 89 | 90 | Loader.prototype.map = function map(id, source) { 91 | throw new Error('Loaders must implement map(id, source).'); 92 | }; 93 | 94 | Loader.prototype.normalizeSync = function normalizeSync(moduleId, relativeTo) { 95 | throw new Error('Loaders must implement normalizeSync(moduleId, relativeTo).'); 96 | }; 97 | 98 | Loader.prototype.normalize = function normalize(moduleId, relativeTo) { 99 | throw new Error('Loaders must implement normalize(moduleId: string, relativeTo: string): Promise.'); 100 | }; 101 | 102 | Loader.prototype.loadModule = function loadModule(id) { 103 | throw new Error('Loaders must implement loadModule(id).'); 104 | }; 105 | 106 | Loader.prototype.loadAllModules = function loadAllModules(ids) { 107 | throw new Error('Loader must implement loadAllModules(ids).'); 108 | }; 109 | 110 | Loader.prototype.loadTemplate = function loadTemplate(url) { 111 | throw new Error('Loader must implement loadTemplate(url).'); 112 | }; 113 | 114 | Loader.prototype.loadText = function loadText(url) { 115 | throw new Error('Loader must implement loadText(url).'); 116 | }; 117 | 118 | Loader.prototype.applyPluginToUrl = function applyPluginToUrl(url, pluginName) { 119 | throw new Error('Loader must implement applyPluginToUrl(url, pluginName).'); 120 | }; 121 | 122 | Loader.prototype.addPlugin = function addPlugin(pluginName, implementation) { 123 | throw new Error('Loader must implement addPlugin(pluginName, implementation).'); 124 | }; 125 | 126 | Loader.prototype.getOrCreateTemplateRegistryEntry = function getOrCreateTemplateRegistryEntry(address) { 127 | return this.templateRegistry[address] || (this.templateRegistry[address] = new TemplateRegistryEntry(address)); 128 | }; 129 | 130 | return Loader; 131 | }(); -------------------------------------------------------------------------------- /dist/native-modules/index.js: -------------------------------------------------------------------------------- 1 | export * from './aurelia-loader'; -------------------------------------------------------------------------------- /dist/system/aurelia-loader.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | System.register(['aurelia-path', 'aurelia-metadata'], function (_export, _context) { 4 | "use strict"; 5 | 6 | var relativeToFile, Origin, _createClass, TemplateDependency, TemplateRegistryEntry, Loader; 7 | 8 | 9 | 10 | return { 11 | setters: [function (_aureliaPath) { 12 | relativeToFile = _aureliaPath.relativeToFile; 13 | }, function (_aureliaMetadata) { 14 | Origin = _aureliaMetadata.Origin; 15 | }], 16 | execute: function () { 17 | _createClass = function () { 18 | function defineProperties(target, props) { 19 | for (var i = 0; i < props.length; i++) { 20 | var descriptor = props[i]; 21 | descriptor.enumerable = descriptor.enumerable || false; 22 | descriptor.configurable = true; 23 | if ("value" in descriptor) descriptor.writable = true; 24 | Object.defineProperty(target, descriptor.key, descriptor); 25 | } 26 | } 27 | 28 | return function (Constructor, protoProps, staticProps) { 29 | if (protoProps) defineProperties(Constructor.prototype, protoProps); 30 | if (staticProps) defineProperties(Constructor, staticProps); 31 | return Constructor; 32 | }; 33 | }(); 34 | 35 | _export('TemplateDependency', TemplateDependency = function TemplateDependency(src, name) { 36 | 37 | 38 | this.src = src; 39 | this.name = name; 40 | }); 41 | 42 | _export('TemplateDependency', TemplateDependency); 43 | 44 | _export('TemplateRegistryEntry', TemplateRegistryEntry = function () { 45 | function TemplateRegistryEntry(address) { 46 | 47 | 48 | this.templateIsLoaded = false; 49 | this.factoryIsReady = false; 50 | this.resources = null; 51 | this.dependencies = null; 52 | 53 | this.address = address; 54 | this.onReady = null; 55 | this._template = null; 56 | this._factory = null; 57 | } 58 | 59 | TemplateRegistryEntry.prototype.addDependency = function addDependency(src, name) { 60 | var finalSrc = typeof src === 'string' ? relativeToFile(src, this.address) : Origin.get(src).moduleId; 61 | 62 | this.dependencies.push(new TemplateDependency(finalSrc, name)); 63 | }; 64 | 65 | _createClass(TemplateRegistryEntry, [{ 66 | key: 'template', 67 | get: function get() { 68 | return this._template; 69 | }, 70 | set: function set(value) { 71 | var address = this.address; 72 | var requires = void 0; 73 | var current = void 0; 74 | var src = void 0; 75 | var dependencies = void 0; 76 | 77 | this._template = value; 78 | this.templateIsLoaded = true; 79 | 80 | requires = value.content.querySelectorAll('require'); 81 | dependencies = this.dependencies = new Array(requires.length); 82 | 83 | for (var i = 0, ii = requires.length; i < ii; ++i) { 84 | current = requires[i]; 85 | src = current.getAttribute('from'); 86 | 87 | if (!src) { 88 | throw new Error(' element in ' + address + ' has no "from" attribute.'); 89 | } 90 | 91 | dependencies[i] = new TemplateDependency(relativeToFile(src, address), current.getAttribute('as')); 92 | 93 | if (current.parentNode) { 94 | current.parentNode.removeChild(current); 95 | } 96 | } 97 | } 98 | }, { 99 | key: 'factory', 100 | get: function get() { 101 | return this._factory; 102 | }, 103 | set: function set(value) { 104 | this._factory = value; 105 | this.factoryIsReady = true; 106 | } 107 | }]); 108 | 109 | return TemplateRegistryEntry; 110 | }()); 111 | 112 | _export('TemplateRegistryEntry', TemplateRegistryEntry); 113 | 114 | _export('Loader', Loader = function () { 115 | function Loader() { 116 | 117 | 118 | this.templateRegistry = {}; 119 | } 120 | 121 | Loader.prototype.map = function map(id, source) { 122 | throw new Error('Loaders must implement map(id, source).'); 123 | }; 124 | 125 | Loader.prototype.normalizeSync = function normalizeSync(moduleId, relativeTo) { 126 | throw new Error('Loaders must implement normalizeSync(moduleId, relativeTo).'); 127 | }; 128 | 129 | Loader.prototype.normalize = function normalize(moduleId, relativeTo) { 130 | throw new Error('Loaders must implement normalize(moduleId: string, relativeTo: string): Promise.'); 131 | }; 132 | 133 | Loader.prototype.loadModule = function loadModule(id) { 134 | throw new Error('Loaders must implement loadModule(id).'); 135 | }; 136 | 137 | Loader.prototype.loadAllModules = function loadAllModules(ids) { 138 | throw new Error('Loader must implement loadAllModules(ids).'); 139 | }; 140 | 141 | Loader.prototype.loadTemplate = function loadTemplate(url) { 142 | throw new Error('Loader must implement loadTemplate(url).'); 143 | }; 144 | 145 | Loader.prototype.loadText = function loadText(url) { 146 | throw new Error('Loader must implement loadText(url).'); 147 | }; 148 | 149 | Loader.prototype.applyPluginToUrl = function applyPluginToUrl(url, pluginName) { 150 | throw new Error('Loader must implement applyPluginToUrl(url, pluginName).'); 151 | }; 152 | 153 | Loader.prototype.addPlugin = function addPlugin(pluginName, implementation) { 154 | throw new Error('Loader must implement addPlugin(pluginName, implementation).'); 155 | }; 156 | 157 | Loader.prototype.getOrCreateTemplateRegistryEntry = function getOrCreateTemplateRegistryEntry(address) { 158 | return this.templateRegistry[address] || (this.templateRegistry[address] = new TemplateRegistryEntry(address)); 159 | }; 160 | 161 | return Loader; 162 | }()); 163 | 164 | _export('Loader', Loader); 165 | } 166 | }; 167 | }); -------------------------------------------------------------------------------- /dist/system/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | System.register(['./aurelia-loader'], function (_export, _context) { 4 | "use strict"; 5 | 6 | return { 7 | setters: [function (_aureliaLoader) { 8 | var _exportObj = {}; 9 | 10 | for (var _key in _aureliaLoader) { 11 | if (_key !== "default" && _key !== "__esModule") _exportObj[_key] = _aureliaLoader[_key]; 12 | } 13 | 14 | _export(_exportObj); 15 | }], 16 | execute: function () {} 17 | }; 18 | }); -------------------------------------------------------------------------------- /doc/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | ## [1.0.3](https://github.com/aurelia/loader/compare/1.0.1...1.0.3) (2019-03-27) 3 | 4 | 5 | ### Bug Fixes 6 | 7 | * **all:** change es2015 back to native-modules ([64d4751](https://github.com/aurelia/loader/commit/64d4751)) 8 | 9 | 10 | 11 | 12 | ## [1.0.2](https://github.com/aurelia/loader/compare/1.0.1...1.0.2) (2019-02-04) 13 | 14 | 15 | ### Bug Fixes 16 | 17 | * **all:** change es2015 back to native-modules ([64d4751](https://github.com/aurelia/loader/commit/64d4751)) 18 | 19 | 20 | 21 | 22 | ## [1.0.1](https://github.com/aurelia/loader/compare/1.0.0...1.0.1) (2019-01-18) 23 | 24 | * Add module to package.json. 25 | 26 | 27 | # [1.0.0](https://github.com/aurelia/loader/compare/1.0.0-rc.1.0.0...v1.0.0) (2016-07-27) 28 | 29 | 30 | 31 | 32 | # [1.0.0-rc.1.0.0](https://github.com/aurelia/loader/compare/1.0.0-beta.2.0.1...v1.0.0-rc.1.0.0) (2016-06-22) 33 | 34 | 35 | 36 | ### 1.0.0-beta.1.2.1 (2016-05-10) 37 | 38 | 39 | ### 1.0.0-beta.1.2.0(2016-03-22) 40 | 41 | * Update to Babel 6 42 | 43 | ### 1.0.0-beta.1.1.1 (2016-02-08) 44 | 45 | 46 | ### 1.0.0-beta.1.1.0 (2016-01-29) 47 | 48 | * update jspm metadata; core-js; aurelia-deps 49 | 50 | ### 1.0.0-beta.1.0.1 (2016-01-08) 51 | 52 | 53 | #### Bug Fixes 54 | 55 | * **loader:** remove un-need core-js import ([aec5fa20](http://github.com/aurelia/loader/commit/aec5fa20eaefbce8b48383056e86459ce01b5bcf)) 56 | 57 | 58 | #### Features 59 | 60 | * **loader:** add normalize api ([e5d5a9e5](http://github.com/aurelia/loader/commit/e5d5a9e551f8bf4ba1fc7a140fd787bc45cad3d9)) 61 | 62 | 63 | ### 1.0.0-beta.1 (2015-11-16) 64 | 65 | 66 | ## 0.11.0 (2015-11-09) 67 | 68 | 69 | #### Bug Fixes 70 | 71 | * **template-registry-entry:** add onReady so its defined in ctor for perf ([33148ea4](http://github.com/aurelia/loader/commit/33148ea4b841dcb39f3217768c8cbe0ed174329f)) 72 | 73 | 74 | #### Features 75 | 76 | * **all:** improved and locked down loader apis ([1174f436](http://github.com/aurelia/loader/commit/1174f436d33dbcd3dc70166cf4d31c9a90259fdf)) 77 | 78 | 79 | ## 0.10.0 (2015-10-13) 80 | 81 | 82 | #### Bug Fixes 83 | 84 | * **all:** 85 | * update compiler and core-js imports ([a62dd4c3](http://github.com/aurelia/loader/commit/a62dd4c3a82ee9fba11f910a4ae3d0146f6c7ccb)) 86 | * properly export the TemplateRegistryEntry ([4c60c8f7](http://github.com/aurelia/loader/commit/4c60c8f77b53f1a34ab7a1825305d81d99d4b7d6)) 87 | * **bower:** correct semver ranges ([430ba151](http://github.com/aurelia/loader/commit/430ba151e80add2bf57d049b773535788e706771)) 88 | * **bower.json:** incorrect reference to webcomponentsjs ([682ed683](http://github.com/aurelia/loader/commit/682ed68351dfb5817d5a007de62512af3de63842)) 89 | * **build:** 90 | * update linting, testing and tools ([3cba198f](http://github.com/aurelia/loader/commit/3cba198f9faedbbcd39a91f7dc212ef4e2236e0f)) 91 | * add missing bower bump ([7b0a109d](http://github.com/aurelia/loader/commit/7b0a109da46d64d5aa39730068f8c4b598fc66e0)) 92 | * **loadTemplate:** refactor base url handling ([7cf42acf](http://github.com/aurelia/loader/commit/7cf42acfdf598ed1bb399cb3cda1a98c9b2b2beb)) 93 | * **loader:** 94 | * correct core-js import syntax ([95cc96b7](http://github.com/aurelia/loader/commit/95cc96b79763e81d562c4565b09006e6e918ec1b)) 95 | * correct the LoaderPlugin interface defintion ([cd07a012](http://github.com/aurelia/loader/commit/cd07a012974149970e21d0599993823c7203f0f0)) 96 | * change some types ([3b212821](http://github.com/aurelia/loader/commit/3b21282147f2bb663b6929dd56a64af15dc21e28)) 97 | * Use correct import for core-js We were previously using `import core from core-j ([70e18d0f](http://github.com/aurelia/loader/commit/70e18d0f0108d4b11588b86c6b4ba964e6410cd9)) 98 | * async problem with bundles views ([3b300e84](http://github.com/aurelia/loader/commit/3b300e845eb71494f5505d9212aae738ed7094a7), closes [#12](http://github.com/aurelia/loader/issues/12)) 99 | * throw exception when no template found at view url ([b4cfe513](http://github.com/aurelia/loader/commit/b4cfe513dd91451d0ddf0b7f7f43f073f647939f)) 100 | * **package:** 101 | * change jspm directories ([64a8443b](http://github.com/aurelia/loader/commit/64a8443b6e1b4134393972448d431566108c8aa1)) 102 | * update dependencies ([f468bb26](http://github.com/aurelia/loader/commit/f468bb263c3254e3b87fce07e671afeed4e74f67)) 103 | * update dependencies ([0ca68f2d](http://github.com/aurelia/loader/commit/0ca68f2d0be882593f3f109b10546a3021f86d92)) 104 | * update dependencies to latest versions ([bc8d5c7d](http://github.com/aurelia/loader/commit/bc8d5c7d7247107579d08d434d996de976fa0c28)) 105 | * add missing polyfills ([178f6b08](http://github.com/aurelia/loader/commit/178f6b085deed728e71d72f20dbfde9f41287e1c)) 106 | * **template-registry-entry:** 107 | * correct types ([c10a7e4f](http://github.com/aurelia/loader/commit/c10a7e4fe844a76211b99867b67fedffac234bd2)) 108 | * getElementsByTagName not available on document fragments ([c0d98338](http://github.com/aurelia/loader/commit/c0d983381ace9ef4fcbbda1d826bb3bdca1fdf43)) 109 | * **template-registry0entry:** changed property from id to address ([91cc7a0f](http://github.com/aurelia/loader/commit/91cc7a0f919edf7e7a5e59dedd3dd2b9c668aa4f)) 110 | 111 | 112 | #### Features 113 | 114 | * **all:** 115 | * remove html imports and add generic loader plugin api ([95c9fc5e](http://github.com/aurelia/loader/commit/95c9fc5e2ad23fa9251234f4667d35e5a4786211)) 116 | * add more type info ([5e778549](http://github.com/aurelia/loader/commit/5e778549d5b126bcb263c82216f51d042d6afcd5)) 117 | * new template registry and global loader ([99ec5e2e](http://github.com/aurelia/loader/commit/99ec5e2edf5e4dd3f1c52d42cc413f66608710cf)) 118 | * **build:** update compile, switch to register modules, switch to core-js ([5b830212](http://github.com/aurelia/loader/commit/5b8302120909bbc6fbc0941ec4256299204c6e80)) 119 | * **docs:** generate api.json from .d.ts file ([57db0717](http://github.com/aurelia/loader/commit/57db071749e41e4a74d878a61abecf0dea2afd0c)) 120 | * **loader:** 121 | * add map and normalizeSync methods ([8afe34fa](http://github.com/aurelia/loader/commit/8afe34fa57ca07b69adabdeb6d2b678e9e87730b)) 122 | * add support for view bundles ([8f2c45d6](http://github.com/aurelia/loader/commit/8f2c45d6780d66bcb290cc3cfdec1b8b0eaa9fc4)) 123 | * add text loading abstraction ([3dcd1c2f](http://github.com/aurelia/loader/commit/3dcd1c2faa72ce00eeb3222382092ec578833bf8), closes [#8](http://github.com/aurelia/loader/issues/8)) 124 | * **template-registry-entry:** allow dynamically adding dependencies ([78bf4984](http://github.com/aurelia/loader/commit/78bf498447c439d936422c2e6b74e72f1d9f9ac3)) 125 | * **views:** 126 | * view imports are now done with ([2e68de3c](http://github.com/aurelia/loader/commit/2e68de3c4d4063abd602af157e13e3dccda16bdf)) 127 | * view imports are now done with ([43b04172](http://github.com/aurelia/loader/commit/43b0417262578ac0578407c1b5e5880ba3351d45)) 128 | 129 | 130 | ## 0.9.0 (2015-09-04) 131 | 132 | 133 | #### Bug Fixes 134 | 135 | * **build:** update linting, testing and tools ([3cba198f](http://github.com/aurelia/loader/commit/3cba198f9faedbbcd39a91f7dc212ef4e2236e0f)) 136 | * **loader:** correct the LoaderPlugin interface defintion ([cd07a012](http://github.com/aurelia/loader/commit/cd07a012974149970e21d0599993823c7203f0f0)) 137 | * **template-registry0entry:** changed property from id to address ([91cc7a0f](http://github.com/aurelia/loader/commit/91cc7a0f919edf7e7a5e59dedd3dd2b9c668aa4f)) 138 | 139 | 140 | #### Features 141 | 142 | * **all:** remove html imports and add generic loader plugin api ([95c9fc5e](http://github.com/aurelia/loader/commit/95c9fc5e2ad23fa9251234f4667d35e5a4786211)) 143 | * **docs:** generate api.json from .d.ts file ([57db0717](http://github.com/aurelia/loader/commit/57db071749e41e4a74d878a61abecf0dea2afd0c)) 144 | 145 | 146 | ### 0.8.7 (2015-08-14) 147 | 148 | 149 | #### Bug Fixes 150 | 151 | * **template-registry-entry:** correct types ([c10a7e4f](http://github.com/aurelia/loader/commit/c10a7e4fe844a76211b99867b67fedffac234bd2)) 152 | 153 | 154 | ### 0.8.6 (2015-08-14) 155 | 156 | 157 | #### Bug Fixes 158 | 159 | * **loader:** change some types ([3b212821](http://github.com/aurelia/loader/commit/3b21282147f2bb663b6929dd56a64af15dc21e28)) 160 | 161 | 162 | ### 0.8.5 (2015-08-14) 163 | 164 | #### Bug Fixes 165 | 166 | * **loader:** Fix typos in type info 167 | 168 | ### 0.8.4 (2015-08-14) 169 | 170 | 171 | #### Bug Fixes 172 | 173 | * **loader:** Use correct import for core-js We were previously using `import core from core-j ([70e18d0f](http://github.com/aurelia/loader/commit/70e18d0f0108d4b11588b86c6b4ba964e6410cd9)) 174 | 175 | 176 | #### Features 177 | 178 | * **all:** add more type info ([5e778549](http://github.com/aurelia/loader/commit/5e778549d5b126bcb263c82216f51d042d6afcd5)) 179 | 180 | 181 | ### 0.8.3 (2015-07-29) 182 | 183 | * improve output file name 184 | 185 | ### 0.8.2 (2015-07-16) 186 | 187 | 188 | #### Features 189 | 190 | * **template-registry-entry:** allow dynamically adding dependencies ([78bf4984](http://github.com/aurelia/loader/commit/78bf498447c439d936422c2e6b74e72f1d9f9ac3)) 191 | 192 | 193 | ### 0.8.1 (2015-07-13) 194 | 195 | 196 | #### Bug Fixes 197 | 198 | * **loader:** async problem with bundles views ([3b300e84](http://github.com/aurelia/loader/commit/3b300e845eb71494f5505d9212aae738ed7094a7), closes [#12](http://github.com/aurelia/loader/issues/12)) 199 | 200 | 201 | ## 0.8.0 (2015-07-02) 202 | 203 | 204 | ## 0.7.0 (2015-06-08) 205 | 206 | 207 | #### Features 208 | 209 | * **loader:** add support for view bundles ([8f2c45d6](http://github.com/aurelia/loader/commit/8f2c45d6780d66bcb290cc3cfdec1b8b0eaa9fc4)) 210 | 211 | 212 | ## 0.6.0 (2015-04-30) 213 | 214 | 215 | #### Bug Fixes 216 | 217 | * **bower.json:** incorrect reference to webcomponentsjs ([682ed683](http://github.com/aurelia/loader/commit/682ed68351dfb5817d5a007de62512af3de63842)) 218 | 219 | 220 | #### Features 221 | 222 | * **loader:** add text loading abstraction ([3dcd1c2f](http://github.com/aurelia/loader/commit/3dcd1c2faa72ce00eeb3222382092ec578833bf8), closes [#8](http://github.com/aurelia/loader/issues/8)) 223 | 224 | 225 | ## 0.5.0 (2015-04-09) 226 | 227 | 228 | #### Bug Fixes 229 | 230 | * **all:** update compiler and core-js imports ([a62dd4c3](http://github.com/aurelia/loader/commit/a62dd4c3a82ee9fba11f910a4ae3d0146f6c7ccb)) 231 | * **template-registry-entry:** getElementsByTagName not available on document fragments ([c0d98338](http://github.com/aurelia/loader/commit/c0d983381ace9ef4fcbbda1d826bb3bdca1fdf43)) 232 | 233 | 234 | ## 0.4.0 (2015-03-24) 235 | 236 | 237 | #### Bug Fixes 238 | 239 | * **all:** properly export the TemplateRegistryEntry ([4c60c8f7](http://github.com/aurelia/loader/commit/4c60c8f77b53f1a34ab7a1825305d81d99d4b7d6)) 240 | 241 | 242 | #### Features 243 | 244 | * **all:** new template registry and global loader ([99ec5e2e](http://github.com/aurelia/loader/commit/99ec5e2edf5e4dd3f1c52d42cc413f66608710cf)) 245 | * **views:** 246 | * view imports are now done with ([2e68de3c](http://github.com/aurelia/loader/commit/2e68de3c4d4063abd602af157e13e3dccda16bdf)) 247 | * view imports are now done with ([43b04172](http://github.com/aurelia/loader/commit/43b0417262578ac0578407c1b5e5880ba3351d45)) 248 | 249 | 250 | ### 0.3.5 (2015-02-28) 251 | 252 | 253 | #### Bug Fixes 254 | 255 | * **package:** change jspm directories ([64a8443b](http://github.com/aurelia/loader/commit/64a8443b6e1b4134393972448d431566108c8aa1)) 256 | 257 | 258 | ### 0.3.4 (2015-02-27) 259 | 260 | 261 | #### Bug Fixes 262 | 263 | * **build:** add missing bower bump ([7b0a109d](http://github.com/aurelia/loader/commit/7b0a109da46d64d5aa39730068f8c4b598fc66e0)) 264 | * **package:** update dependencies ([f468bb26](http://github.com/aurelia/loader/commit/f468bb263c3254e3b87fce07e671afeed4e74f67)) 265 | 266 | 267 | ### 0.3.3 (2015-01-24) 268 | 269 | 270 | #### Bug Fixes 271 | 272 | * **bower:** correct semver ranges ([430ba151](http://github.com/aurelia/loader/commit/430ba151e80add2bf57d049b773535788e706771)) 273 | 274 | 275 | ### 0.3.2 (2015-01-22) 276 | 277 | 278 | #### Bug Fixes 279 | 280 | * **package:** update dependencies ([0ca68f2d](http://github.com/aurelia/loader/commit/0ca68f2d0be882593f3f109b10546a3021f86d92)) 281 | 282 | 283 | ### 0.3.1 (2015-01-12) 284 | 285 | * Update compiled output. 286 | 287 | ## 0.3.0 (2015-01-06) 288 | 289 | 290 | #### Features 291 | 292 | * **build:** update compile, switch to register modules, switch to core-js ([5b830212](http://github.com/aurelia/loader/commit/5b8302120909bbc6fbc0941ec4256299204c6e80)) 293 | 294 | 295 | ## 0.2.0 (2014-12-17) 296 | 297 | 298 | #### Bug Fixes 299 | 300 | * **loadTemplate:** refactor base url handling ([7cf42acf](http://github.com/aurelia/loader/commit/7cf42acfdf598ed1bb399cb3cda1a98c9b2b2beb)) 301 | * **package:** update dependencies to latest versions ([bc8d5c7d](http://github.com/aurelia/loader/commit/bc8d5c7d7247107579d08d434d996de976fa0c28)) 302 | 303 | 304 | ### 0.1.1 (2014-12-11) 305 | 306 | 307 | #### Bug Fixes 308 | 309 | * **loader:** throw exception when no template found at view url ([b4cfe513](http://github.com/aurelia/loader/commit/b4cfe513dd91451d0ddf0b7f7f43f073f647939f)) 310 | 311 | 312 | ## 0.1.0 (2014-12-11) 313 | 314 | 315 | #### Bug Fixes 316 | 317 | * **package:** add missing polyfills ([178f6b08](http://github.com/aurelia/loader/commit/178f6b085deed728e71d72f20dbfde9f41287e1c)) 318 | -------------------------------------------------------------------------------- /doc/api.json: -------------------------------------------------------------------------------- 1 | {"name":"aurelia-loader","children":[{"id":28,"name":"Loader","kind":128,"kindString":"Class","flags":{"isExported":true},"comment":{"shortText":"A generic resource loader, for loading modules, html, css and more."},"children":[{"id":29,"name":"constructor","kind":512,"kindString":"Constructor","flags":{"isExported":true},"comment":{"shortText":"Creates an instance of Loader."},"signatures":[{"id":30,"name":"new Loader","kind":16384,"kindString":"Constructor signature","flags":{},"comment":{"shortText":"Creates an instance of Loader."},"type":{"type":"reference","name":"Loader","id":28}}],"sources":[{"fileName":"aurelia-loader.d.ts","line":105,"character":29}]},{"id":59,"name":"addPlugin","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":60,"name":"addPlugin","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Registers a plugin with the loader."},"parameters":[{"id":61,"name":"pluginName","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The name of the plugin."},"type":{"type":"instrinct","name":"string"}},{"id":62,"name":"implementation","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The plugin implementation.\n"},"type":{"type":"reference","name":"LoaderPlugin","id":2}}],"type":{"type":"instrinct","name":"void"}}],"sources":[{"fileName":"aurelia-loader.d.ts","line":176,"character":11}]},{"id":55,"name":"applyPluginToUrl","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":56,"name":"applyPluginToUrl","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Alters a module id so that it includes a plugin loader.","returns":"The plugin-based module id.\n"},"parameters":[{"id":57,"name":"url","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The url of the module to load."},"type":{"type":"instrinct","name":"string"}},{"id":58,"name":"pluginName","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The plugin to apply to the module id."},"type":{"type":"instrinct","name":"string"}}],"type":{"type":"instrinct","name":"string"}}],"sources":[{"fileName":"aurelia-loader.d.ts","line":169,"character":18}]},{"id":63,"name":"getOrCreateTemplateRegistryEntry","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":64,"name":"getOrCreateTemplateRegistryEntry","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Gets or creates a TemplateRegistryEntry for the provided address.","returns":"The located or created TemplateRegistryEntry.\n"},"parameters":[{"id":65,"name":"address","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The address of the template."},"type":{"type":"instrinct","name":"string"}}],"type":{"type":"reference","name":"TemplateRegistryEntry","id":13}}],"sources":[{"fileName":"aurelia-loader.d.ts","line":183,"character":34}]},{"id":46,"name":"loadAllModules","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":47,"name":"loadAllModules","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Loads a collection of modules.","returns":"A Promise for an array of loaded modules.\n"},"parameters":[{"id":48,"name":"ids","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The set of module ids to load."},"type":{"type":"instrinct","isArray":true,"name":"string"}}],"type":{"type":"reference","name":"Promise","typeArguments":[{"type":"instrinct","isArray":true,"name":"any"}]}}],"sources":[{"fileName":"aurelia-loader.d.ts","line":147,"character":16}]},{"id":43,"name":"loadModule","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":44,"name":"loadModule","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Loads a module.","returns":"A Promise for the loaded module.\n"},"parameters":[{"id":45,"name":"id","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The module id to normalize."},"type":{"type":"instrinct","name":"string"}}],"type":{"type":"reference","name":"Promise","typeArguments":[{"type":"instrinct","name":"any"}]}}],"sources":[{"fileName":"aurelia-loader.d.ts","line":140,"character":12}]},{"id":49,"name":"loadTemplate","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":50,"name":"loadTemplate","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Loads a template.","returns":"A Promise for a TemplateRegistryEntry containing the template.\n"},"parameters":[{"id":51,"name":"url","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The url of the template to load."},"type":{"type":"instrinct","name":"string"}}],"type":{"type":"reference","name":"Promise","typeArguments":[{"type":"reference","name":"TemplateRegistryEntry","id":13}]}}],"sources":[{"fileName":"aurelia-loader.d.ts","line":154,"character":14}]},{"id":52,"name":"loadText","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":53,"name":"loadText","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Loads a text-based resource.","returns":"A Promise for text content.\n"},"parameters":[{"id":54,"name":"url","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The url of the text file to load."},"type":{"type":"instrinct","name":"string"}}],"type":{"type":"reference","name":"Promise","typeArguments":[{"type":"instrinct","name":"string"}]}}],"sources":[{"fileName":"aurelia-loader.d.ts","line":161,"character":10}]},{"id":31,"name":"map","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":32,"name":"map","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Maps a module id to a source."},"parameters":[{"id":33,"name":"id","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The module id."},"type":{"type":"instrinct","name":"string"}},{"id":34,"name":"source","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The source to map the module to.\n"},"type":{"type":"instrinct","name":"string"}}],"type":{"type":"instrinct","name":"void"}}],"sources":[{"fileName":"aurelia-loader.d.ts","line":117,"character":5}]},{"id":39,"name":"normalize","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":40,"name":"normalize","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Normalizes a module id.","returns":"A promise for the normalized module id.\n"},"parameters":[{"id":41,"name":"moduleId","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The module id to normalize."},"type":{"type":"instrinct","name":"string"}},{"id":42,"name":"relativeTo","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"What the module id should be normalized relative to."},"type":{"type":"instrinct","name":"string"}}],"type":{"type":"reference","name":"Promise","typeArguments":[{"type":"instrinct","name":"string"}]}}],"sources":[{"fileName":"aurelia-loader.d.ts","line":133,"character":11}]},{"id":35,"name":"normalizeSync","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":36,"name":"normalizeSync","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Normalizes a module id.","returns":"The normalized module id.\n"},"parameters":[{"id":37,"name":"moduleId","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The module id to normalize."},"type":{"type":"instrinct","name":"string"}},{"id":38,"name":"relativeTo","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"What the module id should be normalized relative to."},"type":{"type":"instrinct","name":"string"}}],"type":{"type":"instrinct","name":"string"}}],"sources":[{"fileName":"aurelia-loader.d.ts","line":125,"character":15}]}],"groups":[{"title":"Constructors","kind":512,"children":[29]},{"title":"Methods","kind":2048,"children":[59,55,63,46,43,49,52,31,39,35]}],"sources":[{"fileName":"aurelia-loader.d.ts","line":105,"character":27}]},{"id":6,"name":"TemplateDependency","kind":128,"kindString":"Class","flags":{"isExported":true},"comment":{"shortText":"Represents a dependency of a template."},"children":[{"id":9,"name":"constructor","kind":512,"kindString":"Constructor","flags":{"isExported":true},"comment":{"shortText":"Creates a template dependency."},"signatures":[{"id":10,"name":"new TemplateDependency","kind":16384,"kindString":"Constructor signature","flags":{},"comment":{"shortText":"Creates a template dependency."},"parameters":[{"id":11,"name":"src","kind":32768,"kindString":"Parameter","flags":{},"comment":{"shortText":"The source of the dependency."},"type":{"type":"instrinct","name":"string"}},{"id":12,"name":"name","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"comment":{"shortText":"The local name of the src when used in the template.\n"},"type":{"type":"instrinct","name":"string"}}],"type":{"type":"reference","name":"TemplateDependency","id":6}}],"sources":[{"fileName":"aurelia-loader.d.ts","line":35,"character":15}]},{"id":8,"name":"name","kind":1024,"kindString":"Property","flags":{"isExported":true},"comment":{"shortText":"The local name of the src when used in the template."},"sources":[{"fileName":"aurelia-loader.d.ts","line":35,"character":6}],"type":{"type":"instrinct","name":"string"}},{"id":7,"name":"src","kind":1024,"kindString":"Property","flags":{"isExported":true},"comment":{"shortText":"The source of the dependency."},"sources":[{"fileName":"aurelia-loader.d.ts","line":30,"character":5}],"type":{"type":"instrinct","name":"string"}}],"groups":[{"title":"Constructors","kind":512,"children":[9]},{"title":"Properties","kind":1024,"children":[8,7]}],"sources":[{"fileName":"aurelia-loader.d.ts","line":25,"character":39}]},{"id":13,"name":"TemplateRegistryEntry","kind":128,"kindString":"Class","flags":{"isExported":true},"comment":{"shortText":"Represents an entry in the template registry."},"children":[{"id":19,"name":"constructor","kind":512,"kindString":"Constructor","flags":{"isExported":true},"comment":{"shortText":"Creates an instance of TemplateRegistryEntry."},"signatures":[{"id":20,"name":"new TemplateRegistryEntry","kind":16384,"kindString":"Constructor signature","flags":{},"comment":{"shortText":"Creates an instance of TemplateRegistryEntry."},"parameters":[{"id":21,"name":"address","kind":32768,"kindString":"Parameter","flags":{},"comment":{"shortText":"The address of the template that this entry represents.\n"},"type":{"type":"instrinct","name":"string"}}],"type":{"type":"reference","name":"TemplateRegistryEntry","id":13}}],"sources":[{"fileName":"aurelia-loader.d.ts","line":73,"character":37}]},{"id":14,"name":"address","kind":1024,"kindString":"Property","flags":{"isExported":true},"comment":{"shortText":"The address of the template that this entry represents."},"sources":[{"fileName":"aurelia-loader.d.ts","line":53,"character":9}],"type":{"type":"instrinct","name":"string"}},{"id":18,"name":"dependencies","kind":1024,"kindString":"Property","flags":{"isExported":true},"comment":{"shortText":"The dependencies of the associated template. Dependencies are not available until after the template is loaded."},"sources":[{"fileName":"aurelia-loader.d.ts","line":73,"character":14}],"type":{"type":"reference","isArray":true,"name":"TemplateDependency","id":6}},{"id":23,"name":"factory","kind":1024,"kindString":"Property","flags":{"isExported":true},"comment":{"shortText":"Gets the factory capable of creating instances of this template."},"sources":[{"fileName":"aurelia-loader.d.ts","line":89,"character":9}],"type":{"type":"instrinct","name":"any"}},{"id":16,"name":"factoryIsReady","kind":1024,"kindString":"Property","flags":{"isExported":true},"comment":{"shortText":"Indicates whether the factory is ready to be used to create instances of the associated template."},"sources":[{"fileName":"aurelia-loader.d.ts","line":63,"character":16}],"type":{"type":"instrinct","name":"boolean"}},{"id":17,"name":"resources","kind":1024,"kindString":"Property","flags":{"isExported":true},"comment":{"shortText":"Sets the resources associated with this entry."},"sources":[{"fileName":"aurelia-loader.d.ts","line":68,"character":11}],"type":{"type":"reference","name":"Object"}},{"id":22,"name":"template","kind":1024,"kindString":"Property","flags":{"isExported":true},"comment":{"shortText":"Gets the template for this registry entry."},"sources":[{"fileName":"aurelia-loader.d.ts","line":84,"character":10}],"type":{"type":"reference","name":"Element"}},{"id":15,"name":"templateIsLoaded","kind":1024,"kindString":"Property","flags":{"isExported":true},"comment":{"shortText":"Indicates whether or not the associated template is loaded ."},"sources":[{"fileName":"aurelia-loader.d.ts","line":58,"character":18}],"type":{"type":"instrinct","name":"boolean"}},{"id":24,"name":"addDependency","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":25,"name":"addDependency","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Adds a dependency to this template registry entry. Cannot be called until after the template is set."},"parameters":[{"id":26,"name":"src","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The dependency instance or a relative path to its module."},"type":{"type":"union","types":[{"type":"instrinct","name":"string"},{"type":"reference","name":"Function"}]}},{"id":27,"name":"name","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"comment":{"text":"An optional local name by which this dependency is used in the template.\n"},"type":{"type":"instrinct","name":"string"}}],"type":{"type":"instrinct","name":"void"}}],"sources":[{"fileName":"aurelia-loader.d.ts","line":96,"character":15}]}],"groups":[{"title":"Constructors","kind":512,"children":[19]},{"title":"Properties","kind":1024,"children":[14,18,23,16,17,22,15]},{"title":"Methods","kind":2048,"children":[24]}],"sources":[{"fileName":"aurelia-loader.d.ts","line":48,"character":42}]},{"id":2,"name":"LoaderPlugin","kind":256,"kindString":"Interface","flags":{"isExported":true},"comment":{"shortText":"Represents a plugin to the module loader."},"children":[{"id":3,"name":"fetch","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":4,"name":"fetch","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Fetches the resource.","returns":"A Promise for the requested resouce.\n"},"parameters":[{"id":5,"name":"address","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The address of the resource."},"type":{"type":"instrinct","name":"string"}}],"type":{"type":"reference","name":"Promise","typeArguments":[{"type":"instrinct","name":"any"}]}}],"sources":[{"fileName":"aurelia-loader.d.ts","line":19,"character":7}]}],"groups":[{"title":"Methods","kind":2048,"children":[3]}],"sources":[{"fileName":"aurelia-loader.d.ts","line":12,"character":37}]}],"groups":[{"title":"Classes","kind":128,"children":[28,6,13]},{"title":"Interfaces","kind":256,"children":[2]}]} -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | require('require-dir')('build/tasks'); 2 | -------------------------------------------------------------------------------- /karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration 2 | // Generated on Fri Dec 05 2014 16:49:29 GMT-0500 (EST) 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | 7 | // base path that will be used to resolve all patterns (eg. files, exclude) 8 | basePath: '', 9 | 10 | 11 | // frameworks to use 12 | // available frameworks: https://npmjs.org/browse/keyword/karma-adapter 13 | frameworks: ['jspm', 'jasmine'], 14 | 15 | jspm: { 16 | // Edit this to your needs 17 | loadFiles: ['src/**/*.js', 'test/**/*.js'] 18 | }, 19 | 20 | 21 | // list of files / patterns to load in the browser 22 | files: [ 23 | {pattern: 'test/fixtures/*', included: false} 24 | ], 25 | 26 | 27 | // list of files to exclude 28 | exclude: [], 29 | 30 | 31 | // preprocess matching files before serving them to the browser 32 | // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor 33 | preprocessors: { 34 | 'test/**/*.js': ['babel'], 35 | 'src/**/*.js': ['babel'] 36 | }, 37 | 'babelPreprocessor': { 38 | options: { 39 | sourceMap: 'inline', 40 | presets: [ 'es2015-loose', 'stage-1'], 41 | plugins: [ 42 | 'syntax-flow', 43 | 'transform-decorators-legacy', 44 | 'transform-flow-strip-types' 45 | ] 46 | } 47 | }, 48 | 49 | 50 | // test results reporter to use 51 | // possible values: 'dots', 'progress' 52 | // available reporters: https://npmjs.org/browse/keyword/karma-reporter 53 | reporters: ['progress'], 54 | 55 | 56 | // web server port 57 | port: 9876, 58 | 59 | 60 | // enable / disable colors in the output (reporters and logs) 61 | colors: true, 62 | 63 | 64 | // level of logging 65 | // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG 66 | logLevel: config.LOG_INFO, 67 | 68 | 69 | // enable / disable watching file and executing tests whenever any file changes 70 | autoWatch: true, 71 | 72 | 73 | // start these browsers 74 | // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher 75 | browsers: ['Chrome'], 76 | 77 | 78 | // Continuous Integration mode 79 | // if true, Karma captures browsers, runs the tests and exits 80 | singleRun: false 81 | }); 82 | }; 83 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aurelia-loader", 3 | "version": "1.0.3", 4 | "description": "An abstract module which specifies an interface for loading modules and view templates.", 5 | "keywords": [ 6 | "aurelia", 7 | "loader", 8 | "modules" 9 | ], 10 | "homepage": "http://aurelia.io", 11 | "bugs": { 12 | "url": "https://github.com/aurelia/loader/issues" 13 | }, 14 | "license": "MIT", 15 | "author": "Rob Eisenberg (http://robeisenberg.com/)", 16 | "main": "dist/commonjs/aurelia-loader.js", 17 | "module": "dist/native-modules/aurelia-loader.js", 18 | "typings": "dist/aurelia-loader.d.ts", 19 | "repository": { 20 | "type": "git", 21 | "url": "http://github.com/aurelia/loader" 22 | }, 23 | "scripts": { 24 | "test": "karma start --single-run", 25 | "build": "gulp build", 26 | "cut-release": "gulp prepare-release" 27 | }, 28 | "files": [ 29 | "dist", 30 | "doc", 31 | "src", 32 | "typings.json", 33 | "README.md", 34 | "LICENSE" 35 | ], 36 | "jspm": { 37 | "registry": "npm", 38 | "main": "aurelia-loader", 39 | "format": "amd", 40 | "directories": { 41 | "dist": "dist/amd" 42 | }, 43 | "dependencies": { 44 | "aurelia-metadata": "^1.0.0", 45 | "aurelia-path": "^1.0.0" 46 | }, 47 | "devDependencies": {} 48 | }, 49 | "dependencies": { 50 | "aurelia-metadata": "^1.0.0", 51 | "aurelia-path": "^1.0.0" 52 | }, 53 | "devDependencies": { 54 | "aurelia-tools": "^0.2.4", 55 | "babel-dts-generator": "^0.6.1", 56 | "babel-eslint": "^6.1.2", 57 | "babel-plugin-syntax-flow": "^6.8.0", 58 | "babel-plugin-transform-decorators-legacy": "^1.3.4", 59 | "babel-plugin-transform-es2015-modules-amd": "^6.8.0", 60 | "babel-plugin-transform-es2015-modules-commonjs": "^6.11.5", 61 | "babel-plugin-transform-es2015-modules-systemjs": "^6.11.6", 62 | "babel-plugin-transform-flow-strip-types": "^6.8.0", 63 | "babel-preset-es2015": "^6.9.0", 64 | "babel-preset-es2015-loose": "^7.0.0", 65 | "babel-preset-es2015-loose-native-modules": "^1.0.0", 66 | "babel-preset-stage-1": "^6.5.0", 67 | "del": "^2.2.1", 68 | "gulp": "^3.9.1", 69 | "gulp-babel": "^6.1.2", 70 | "gulp-bump": "^2.2.0", 71 | "gulp-concat": "^2.6.0", 72 | "gulp-conventional-changelog": "^1.1.0", 73 | "gulp-eslint": "^3.0.1", 74 | "gulp-ignore": "^2.0.1", 75 | "gulp-insert": "^0.5.0", 76 | "gulp-rename": "^1.2.2", 77 | "gulp-typedoc": "^2.0.0", 78 | "gulp-typedoc-extractor": "^0.0.8", 79 | "gulp-typescript": "^2.13.6", 80 | "gulp-util": "^3.0.7", 81 | "jasmine-core": "^2.4.1", 82 | "jspm": "^0.16.53", 83 | "karma": "^1.1.2", 84 | "karma-babel-preprocessor": "^6.0.1", 85 | "karma-chrome-launcher": "^1.0.1", 86 | "karma-coverage": "^1.1.1", 87 | "karma-jasmine": "^1.0.2", 88 | "karma-jspm": "^2.2.0", 89 | "merge2": "^1.0.2", 90 | "object.assign": "^4.0.4", 91 | "require-dir": "^0.3.0", 92 | "run-sequence": "^1.2.2", 93 | "through2": "^2.0.1", 94 | "typedoc": "^0.4.4", 95 | "typescript": "^1.9.0-dev.20160622-1.0", 96 | "vinyl": "^1.1.1", 97 | "vinyl-paths": "^2.1.0", 98 | "yargs": "^4.8.1" 99 | }, 100 | "aurelia": { 101 | "documentation": { 102 | "articles": [] 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /src/loader.js: -------------------------------------------------------------------------------- 1 | /*eslint no-unused-vars:0*/ 2 | import {TemplateRegistryEntry} from './template-registry-entry'; 3 | 4 | /** 5 | * Represents a plugin to the module loader. 6 | */ 7 | interface LoaderPlugin { 8 | /** 9 | * Fetches the resource. 10 | * @param address The address of the resource. 11 | * @return A Promise for the requested resouce. 12 | */ 13 | fetch(address: string): Promise; 14 | } 15 | 16 | /** 17 | * A generic resource loader, for loading modules, html, css and more. 18 | */ 19 | export class Loader { 20 | /** 21 | * Creates an instance of Loader. 22 | */ 23 | constructor() { 24 | this.templateRegistry = {}; 25 | } 26 | 27 | /** 28 | * Maps a module id to a source. 29 | * @param id The module id. 30 | * @param source The source to map the module to. 31 | */ 32 | map(id: string, source: string): void { 33 | throw new Error('Loaders must implement map(id, source).'); 34 | } 35 | 36 | /** 37 | * Normalizes a module id. 38 | * @param moduleId The module id to normalize. 39 | * @param relativeTo What the module id should be normalized relative to. 40 | * @return The normalized module id. 41 | */ 42 | normalizeSync(moduleId: string, relativeTo: string): string { 43 | throw new Error('Loaders must implement normalizeSync(moduleId, relativeTo).'); 44 | } 45 | 46 | /** 47 | * Normalizes a module id. 48 | * @param moduleId The module id to normalize. 49 | * @param relativeTo What the module id should be normalized relative to. 50 | * @return A promise for the normalized module id. 51 | */ 52 | normalize(moduleId: string, relativeTo: string): Promise { 53 | throw new Error('Loaders must implement normalize(moduleId: string, relativeTo: string): Promise.'); 54 | } 55 | 56 | /** 57 | * Loads a module. 58 | * @param id The module id to normalize. 59 | * @return A Promise for the loaded module. 60 | */ 61 | loadModule(id: string): Promise { 62 | throw new Error('Loaders must implement loadModule(id).'); 63 | } 64 | 65 | /** 66 | * Loads a collection of modules. 67 | * @param ids The set of module ids to load. 68 | * @return A Promise for an array of loaded modules. 69 | */ 70 | loadAllModules(ids: string[]): Promise { 71 | throw new Error('Loader must implement loadAllModules(ids).'); 72 | } 73 | 74 | /** 75 | * Loads a template. 76 | * @param url The url of the template to load. 77 | * @return A Promise for a TemplateRegistryEntry containing the template. 78 | */ 79 | loadTemplate(url: string): Promise { 80 | throw new Error('Loader must implement loadTemplate(url).'); 81 | } 82 | 83 | /** 84 | * Loads a text-based resource. 85 | * @param url The url of the text file to load. 86 | * @return A Promise for text content. 87 | */ 88 | loadText(url: string): Promise { 89 | throw new Error('Loader must implement loadText(url).'); 90 | } 91 | 92 | /** 93 | * Alters a module id so that it includes a plugin loader. 94 | * @param url The url of the module to load. 95 | * @param pluginName The plugin to apply to the module id. 96 | * @return The plugin-based module id. 97 | */ 98 | applyPluginToUrl(url: string, pluginName: string): string { 99 | throw new Error('Loader must implement applyPluginToUrl(url, pluginName).'); 100 | } 101 | 102 | /** 103 | * Registers a plugin with the loader. 104 | * @param pluginName The name of the plugin. 105 | * @param implementation The plugin implementation. 106 | */ 107 | addPlugin(pluginName: string, implementation: LoaderPlugin): void { 108 | throw new Error('Loader must implement addPlugin(pluginName, implementation).'); 109 | } 110 | 111 | /** 112 | * Gets or creates a TemplateRegistryEntry for the provided address. 113 | * @param address The address of the template. 114 | * @return The located or created TemplateRegistryEntry. 115 | */ 116 | getOrCreateTemplateRegistryEntry(address: string): TemplateRegistryEntry { 117 | return this.templateRegistry[address] || (this.templateRegistry[address] = new TemplateRegistryEntry(address)); 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /src/template-dependency.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Represents a dependency of a template. 3 | */ 4 | export class TemplateDependency { 5 | /** 6 | * The source of the dependency. 7 | */ 8 | src: string; 9 | /** 10 | * The local name of the src when used in the template. 11 | */ 12 | name: string; 13 | 14 | /** 15 | * Creates a template dependency. 16 | * @param src The source of the dependency. 17 | * @param name The local name of the src when used in the template. 18 | */ 19 | constructor(src: string, name?: string) { 20 | this.src = src; 21 | this.name = name; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/template-registry-entry.js: -------------------------------------------------------------------------------- 1 | import {relativeToFile} from 'aurelia-path'; 2 | import {Origin} from 'aurelia-metadata'; 3 | import {TemplateDependency} from './template-dependency'; 4 | 5 | /** 6 | * Represents an entry in the template registry. 7 | */ 8 | export class TemplateRegistryEntry { 9 | /** 10 | * The address of the template that this entry represents. 11 | */ 12 | address: string; 13 | 14 | /** 15 | * Indicates whether or not the associated template is loaded . 16 | */ 17 | templateIsLoaded: boolean = false; 18 | 19 | /** 20 | * Indicates whether the factory is ready to be used to create instances of the associated template. 21 | */ 22 | factoryIsReady: boolean = false; 23 | 24 | /** 25 | * Sets the resources associated with this entry. 26 | */ 27 | resources: Object = null; 28 | 29 | /** 30 | * The dependencies of the associated template. Dependencies are not available until after the template is loaded. 31 | */ 32 | dependencies: TemplateDependency[] = null; 33 | 34 | /** 35 | * Creates an instance of TemplateRegistryEntry. 36 | * @param address The address of the template that this entry represents. 37 | */ 38 | constructor(address: string) { 39 | this.address = address; 40 | this.onReady = null; 41 | this._template = null; 42 | this._factory = null; 43 | } 44 | 45 | /** 46 | * Gets the template for this registry entry. 47 | */ 48 | get template(): Element { 49 | return this._template; 50 | } 51 | 52 | /** 53 | * Sets the template for this registry entry. 54 | */ 55 | set template(value: Element) { 56 | let address = this.address; 57 | let requires; 58 | let current; 59 | let src; 60 | let dependencies; 61 | 62 | this._template = value; 63 | this.templateIsLoaded = true; 64 | 65 | requires = value.content.querySelectorAll('require'); 66 | dependencies = this.dependencies = new Array(requires.length); 67 | 68 | for (let i = 0, ii = requires.length; i < ii; ++i) { 69 | current = requires[i]; 70 | src = current.getAttribute('from'); 71 | 72 | if (!src) { 73 | throw new Error(` element in ${address} has no "from" attribute.`); 74 | } 75 | 76 | dependencies[i] = new TemplateDependency( 77 | relativeToFile(src, address), 78 | current.getAttribute('as') 79 | ); 80 | 81 | if (current.parentNode) { 82 | current.parentNode.removeChild(current); 83 | } 84 | } 85 | } 86 | 87 | /** 88 | * Gets the factory capable of creating instances of this template. 89 | */ 90 | get factory() { 91 | return this._factory; 92 | } 93 | 94 | /** 95 | * Sets the factory capable of creating instances of this template. 96 | */ 97 | set factory(value) { 98 | this._factory = value; 99 | this.factoryIsReady = true; 100 | } 101 | 102 | /** 103 | * Adds a dependency to this template registry entry. Cannot be called until after the template is set. 104 | * @param src The dependency instance or a relative path to its module. 105 | * @param name An optional local name by which this dependency is used in the template. 106 | */ 107 | addDependency(src: string|Function, name?: string): void { 108 | let finalSrc = typeof src === 'string' 109 | ? relativeToFile(src, this.address) 110 | : Origin.get(src).moduleId; 111 | 112 | this.dependencies.push(new TemplateDependency(finalSrc, name)); 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /test/fixtures/plainHtml.html: -------------------------------------------------------------------------------- 1 |

Just some html

2 | -------------------------------------------------------------------------------- /test/fixtures/template.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /test/loader.spec.js: -------------------------------------------------------------------------------- 1 | import {Loader} from '../src/loader'; 2 | 3 | 4 | describe("the abstract loader", () => { 5 | 6 | describe("instance", () => { 7 | var loader; 8 | 9 | beforeEach(() => loader = new Loader()); 10 | 11 | describe("abstract method", () => { 12 | it('loadModule() should throw when called', () => { 13 | expect(loader.loadModule).toThrow(); 14 | }); 15 | 16 | it('loadAllModules() should throw when called', () => { 17 | expect(loader.loadAllModules).toThrow(); 18 | }); 19 | 20 | it('loadTemplate() should throw when called', () => { 21 | expect(loader.loadTemplate).toThrow(); 22 | }); 23 | 24 | it('loadText() should throw when called', () => { 25 | expect(loader.loadText).toThrow(); 26 | }); 27 | 28 | it('applyPluginToUrl() should throw when called', () => { 29 | expect(loader.applyPluginToUrl).toThrow(); 30 | }); 31 | 32 | it('addPlugin() should throw when called', () => { 33 | expect(loader.addPlugin).toThrow(); 34 | }); 35 | }); 36 | }); 37 | }); 38 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2015", 4 | "module": "es2015", 5 | "experimentalDecorators": true, 6 | "emitDecoratorMetadata": false, 7 | "moduleResolution": "node", 8 | "stripInternal": true, 9 | "preserveConstEnums": true, 10 | "listFiles": true, 11 | "declaration": true, 12 | "removeComments": true, 13 | "lib": ["es2015", "dom"] 14 | }, 15 | "exclude": [ 16 | "node_modules", 17 | "dist", 18 | "build", 19 | "doc", 20 | "test", 21 | "config.js", 22 | "gulpfile.js", 23 | "karma.conf.js" 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aurelia-loader", 3 | "main": "dist/aurelia-loader.d.ts" 4 | } 5 | --------------------------------------------------------------------------------