diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 925d28e1..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,70 +0,0 @@ -# Defaults for all jobs - -defaults: &defaults - working_directory: ~/repo - docker: - - image: aureliaeffect/circleci-v1:latest - -# Variables -var_1: &cache_key aurelia-{{ .Branch }}-{{ checksum "package.json" }}{{ checksum "package-lock.json" }} - -version: 2 -jobs: - install: - <<: *defaults - steps: - - checkout - - run: npm ci - - run: jspm install - - run: git checkout -- package.json - - save_cache: - key: *cache_key - paths: - - node_modules - - jspm_packages - - build: - <<: *defaults - steps: - - checkout - - restore_cache: - key: *cache_key - - run: gulp build - - store_artifacts: - path: ./dist - - unit_tests: - <<: *defaults - steps: - - checkout - - restore_cache: - key: *cache_key - - run: gulp cover - - run: codecov -f ./build/reports/coverage/coverage-final.json - - store_test_results: - path: ./build/reports/coverage - - store_artifacts: - path: ./build/reports/coverage - - lint: - <<: *defaults - steps: - - checkout - - restore_cache: - key: *cache_key - - run: gulp lint - -workflows: - version: 2 - default_workflow: - jobs: - - install - - build: - requires: - - install - - unit_tests: - requires: - - install - - lint: - requires: - - install diff --git a/config.js b/config.js deleted file mode 100644 index 64dbe68c..00000000 --- a/config.js +++ /dev/null @@ -1,96 +0,0 @@ -System.config({ - defaultJSExtensions: true, - paths: { - "github:*": "jspm_packages/github/*", - "aurelia-router/*": "dist/*.js", - "npm:*": "jspm_packages/npm/*" - }, - - map: { - "aurelia-dependency-injection": "npm:aurelia-dependency-injection@1.0.0", - "aurelia-event-aggregator": "npm:aurelia-event-aggregator@1.0.0", - "aurelia-history": "npm:aurelia-history@1.0.0", - "aurelia-logging": "npm:aurelia-logging@1.0.0", - "aurelia-pal-browser": "npm:aurelia-pal-browser@1.0.0", - "aurelia-path": "npm:aurelia-path@1.1.1", - "aurelia-route-recognizer": "npm:aurelia-route-recognizer@1.2.0", - "babel": "npm:babel-core@5.8.38", - "babel-runtime": "npm:babel-runtime@5.8.38", - "core-js": "npm:core-js@2.4.1", - "github:jspm/nodelibs-assert@0.1.0": { - "assert": "npm:assert@1.4.1" - }, - "github:jspm/nodelibs-buffer@0.1.0": { - "buffer": "npm:buffer@3.6.0" - }, - "github:jspm/nodelibs-path@0.1.0": { - "path-browserify": "npm:path-browserify@0.0.0" - }, - "github:jspm/nodelibs-process@0.1.2": { - "process": "npm:process@0.11.6" - }, - "github:jspm/nodelibs-util@0.1.0": { - "util": "npm:util@0.10.3" - }, - "github:jspm/nodelibs-vm@0.1.0": { - "vm-browserify": "npm:vm-browserify@0.0.4" - }, - "npm:assert@1.4.1": { - "assert": "github:jspm/nodelibs-assert@0.1.0", - "buffer": "github:jspm/nodelibs-buffer@0.1.0", - "process": "github:jspm/nodelibs-process@0.1.2", - "util": "npm:util@0.10.3" - }, - "npm:aurelia-dependency-injection@1.0.0": { - "aurelia-metadata": "npm:aurelia-metadata@1.0.0", - "aurelia-pal": "npm:aurelia-pal@1.0.0" - }, - "npm:aurelia-event-aggregator@1.0.0": { - "aurelia-logging": "npm:aurelia-logging@1.0.0" - }, - "npm:aurelia-metadata@1.0.0": { - "aurelia-pal": "npm:aurelia-pal@1.0.0" - }, - "npm:aurelia-pal-browser@1.0.0": { - "aurelia-pal": "npm:aurelia-pal@1.0.0" - }, - "npm:aurelia-route-recognizer@1.2.0": { - "aurelia-path": "npm:aurelia-path@1.1.1" - }, - "npm:babel-runtime@5.8.38": { - "process": "github:jspm/nodelibs-process@0.1.2" - }, - "npm:buffer@3.6.0": { - "base64-js": "npm:base64-js@0.0.8", - "child_process": "github:jspm/nodelibs-child_process@0.1.0", - "fs": "github:jspm/nodelibs-fs@0.1.2", - "ieee754": "npm:ieee754@1.1.6", - "isarray": "npm:isarray@1.0.0", - "process": "github:jspm/nodelibs-process@0.1.2" - }, - "npm:core-js@2.4.1": { - "fs": "github:jspm/nodelibs-fs@0.1.2", - "path": "github:jspm/nodelibs-path@0.1.0", - "process": "github:jspm/nodelibs-process@0.1.2", - "systemjs-json": "github:systemjs/plugin-json@0.1.2" - }, - "npm:inherits@2.0.1": { - "util": "github:jspm/nodelibs-util@0.1.0" - }, - "npm:path-browserify@0.0.0": { - "process": "github:jspm/nodelibs-process@0.1.2" - }, - "npm:process@0.11.6": { - "assert": "github:jspm/nodelibs-assert@0.1.0", - "fs": "github:jspm/nodelibs-fs@0.1.2", - "vm": "github:jspm/nodelibs-vm@0.1.0" - }, - "npm:util@0.10.3": { - "inherits": "npm:inherits@2.0.1", - "process": "github:jspm/nodelibs-process@0.1.2" - }, - "npm:vm-browserify@0.0.4": { - "indexof": "npm:indexof@0.0.1" - } - } -}); diff --git a/gulpfile.js b/gulpfile.js deleted file mode 100644 index 978fd983..00000000 --- a/gulpfile.js +++ /dev/null @@ -1 +0,0 @@ -require('require-dir')('build/tasks'); diff --git a/package-lock.json b/package-lock.json index 42b7622b..43ad47ab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,9 +17,9 @@ "dev": true }, "@types/node": { - "version": "8.0.31", - "resolved": "https://registry.npmjs.org/@types/node/-/node-8.0.31.tgz", - "integrity": "sha1-2a9hCTz0v8nwZso03gF1ASz7DOk=", + "version": "11.12.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-11.12.2.tgz", + "integrity": "sha512-c82MtnqWB/CqqK7/zit74Ob8H1dBdV7bK+BcErwtXbe0+nUGkgzq5NTDmRW/pAv2lFtmeNmW95b0zK2hxpeklg==", "dev": true }, "@webassemblyjs/ast": { @@ -2305,9 +2305,9 @@ "dev": true }, "estree-walker": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.5.2.tgz", - "integrity": "sha512-XpCnW/AE10ws/kDAs37cngSkvgIR8aN3G0MS85m7dUpuK2EREo9VJ00uvw6Dg/hXEpfsE1I1TvJOJr+Z+TL+ig==", + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.0.tgz", + "integrity": "sha512-peq1RfVAVzr3PU/jL31RaOjUKLoZJpObQWJJ+LgfcxDUifyLZ1RjPQZTl0pzj2uJ45b7A7XpyppXvxdEqzo4rw==", "dev": true }, "esutils": { @@ -2427,6 +2427,27 @@ "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", "dev": true }, + "extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", + "dev": true, + "requires": { + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" + }, + "dependencies": { + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "dev": true, + "requires": { + "is-plain-object": "^2.0.4" + } + } + } + }, "extglob": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz", @@ -2590,6 +2611,17 @@ "null-check": "^1.0.0" } }, + "fs-extra": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz", + "integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, "fs-write-stream-atomic": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/fs-write-stream-atomic/-/fs-write-stream-atomic-1.0.10.tgz", @@ -3237,6 +3269,12 @@ } } }, + "graceful-fs": { + "version": "4.1.15", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", + "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==", + "dev": true + }, "gulp-watch": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/gulp-watch/-/gulp-watch-5.0.1.tgz", @@ -3763,9 +3801,9 @@ } }, "jasmine-core": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-2.8.0.tgz", - "integrity": "sha1-vMl5rh+f0FcB5F5S5l06XWPxok4=", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-3.3.0.tgz", + "integrity": "sha512-3/xSmG/d35hf80BEN66Y6g9Ca5l/Isdeg/j6zvbTYlTzeKinzmaTM4p9am5kYqOmE05D7s1t8FGjzdSnbUbceA==", "dev": true }, "js-tokens": { @@ -3809,15 +3847,6 @@ "dev": true, "requires": { "graceful-fs": "^4.1.6" - }, - "dependencies": { - "graceful-fs": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", - "dev": true, - "optional": true - } } }, "karma": { @@ -5377,63 +5406,337 @@ } }, "rollup": { - "version": "0.64.1", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-0.64.1.tgz", - "integrity": "sha512-+ThdVXrvonJdOTzyybMBipP0uz605Z8AnzWVY3rf+cSGnLO7uNkJBlN+9jXqWOomkvumXfm/esmBpA5d53qm7g==", + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.7.4.tgz", + "integrity": "sha512-nc86fETLHdozhRWlW/uNVIQ7ODuA1vU2/L8znAxP9TNMx1NA6GTth3llqoxxCle2kkyui+OfGzbKaQxD60NJjA==", "dev": true, "requires": { "@types/estree": "0.0.39", - "@types/node": "*" + "@types/node": "^11.11.6", + "acorn": "^6.1.1" + }, + "dependencies": { + "acorn": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.1.1.tgz", + "integrity": "sha512-jPTiwtOxaHNaAPg/dmrJ/beuzLRnXtB0kQPQ8JpotKJgTB6rX6c8mlf315941pyjBSaPg8NHXS9fhP4u17DpGA==", + "dev": true + } } }, "rollup-plugin-typescript2": { - "version": "0.16.1", - "resolved": "https://registry.npmjs.org/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.16.1.tgz", - "integrity": "sha512-7x4NcMv8OR/Z6WskCv1QpvYUvHtuZ1jp1LFw16pEzNiY0d2Nm7z7SNUmPE7Vt2HRtQsigEksuYD8O4xi6enV7A==", + "version": "0.20.1", + "resolved": "https://registry.npmjs.org/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.20.1.tgz", + "integrity": "sha512-uxA5JQNOfmJ9rsO0yJKTObb1t4nNYUexCg9zxhEKF+NzZwljYWdfgrA06UzA24cOk8fQjGEe7Q5+Vge2vFlnnw==", "dev": true, "requires": { - "fs-extra": "5.0.0", - "resolve": "1.8.1", - "rollup-pluginutils": "2.3.0", + "fs-extra": "7.0.1", + "resolve": "1.10.0", + "rollup-pluginutils": "2.4.1", "tslib": "1.9.3" }, "dependencies": { - "fs-extra": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-5.0.0.tgz", - "integrity": "sha512-66Pm4RYbjzdyeuqudYqhFiNBbCIuI9kgRqLPSHIlXHidW8NIQtVdkM1yeZ4lXwuhbTETv3EUGMNHAAw6hiundQ==", - "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - } - }, - "graceful-fs": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", "dev": true }, "resolve": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.8.1.tgz", - "integrity": "sha512-AicPrAC7Qu1JxPCZ9ZgCZlY35QgFnNqc+0LtbRNxnVw4TXvjQ72wnuL9JQcEBgXkI9JM8MsT9kaQoHcpCRJOYA==", + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.10.0.tgz", + "integrity": "sha512-3sUr9aq5OfSg2S9pNtPA9hL1FVEAjvfOC4leW0SNf/mpnaakz2a9femSd6LqAww2RaFctwyf1lCqnTHuF1rxDg==", "dev": true, "requires": { - "path-parse": "^1.0.5" + "path-parse": "^1.0.6" } } } }, "rollup-pluginutils": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.3.0.tgz", - "integrity": "sha512-xB6hsRsjdJdIYWEyYUJy/3ki5g69wrf0luHPGNK3ZSocV6HLNfio59l3dZ3TL4xUwEKgROhFi9jOCt6c5gfUWw==", + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.4.1.tgz", + "integrity": "sha512-wesMQ9/172IJDIW/lYWm0vW0LiKe5Ekjws481R7z9WTRtmO59cqyM/2uUlxvf6yzm/fElFmHUobeQOYz46dZJw==", "dev": true, "requires": { - "estree-walker": "^0.5.2", - "micromatch": "^2.3.11" + "estree-walker": "^0.6.0", + "micromatch": "^3.1.10" + }, + "dependencies": { + "arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", + "dev": true + }, + "array-unique": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", + "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", + "dev": true + }, + "braces": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", + "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", + "dev": true, + "requires": { + "arr-flatten": "^1.1.0", + "array-unique": "^0.3.2", + "extend-shallow": "^2.0.1", + "fill-range": "^4.0.0", + "isobject": "^3.0.1", + "repeat-element": "^1.1.2", + "snapdragon": "^0.8.1", + "snapdragon-node": "^2.0.1", + "split-string": "^3.0.2", + "to-regex": "^3.0.1" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "expand-brackets": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", + "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", + "dev": true, + "requires": { + "debug": "^2.3.3", + "define-property": "^0.2.5", + "extend-shallow": "^2.0.1", + "posix-character-classes": "^0.1.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + }, + "is-accessor-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", + "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "is-data-descriptor": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", + "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "is-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", + "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^0.1.6", + "is-data-descriptor": "^0.1.4", + "kind-of": "^5.0.0" + } + }, + "kind-of": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", + "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", + "dev": true + } + } + }, + "extglob": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", + "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", + "dev": true, + "requires": { + "array-unique": "^0.3.2", + "define-property": "^1.0.0", + "expand-brackets": "^2.1.4", + "extend-shallow": "^2.0.1", + "fragment-cache": "^0.2.1", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "^1.0.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "fill-range": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", + "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", + "dev": true, + "requires": { + "extend-shallow": "^2.0.1", + "is-number": "^3.0.0", + "repeat-string": "^1.6.1", + "to-regex-range": "^2.1.0" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + }, + "is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true + }, + "kind-of": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", + "dev": true + }, + "micromatch": { + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", + "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", + "dev": true, + "requires": { + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "braces": "^2.3.1", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "extglob": "^2.0.4", + "fragment-cache": "^0.2.1", + "kind-of": "^6.0.2", + "nanomatch": "^1.2.9", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.2" + } + } } }, "run-queue": { @@ -6594,9 +6897,9 @@ "dev": true }, "typescript": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.0.1.tgz", - "integrity": "sha512-zQIMOmC+372pC/CCVLqnQ0zSBiY7HHodU7mpQdjiZddek4GMj31I3dUJ7gAs9o65X7mnRma6OokOkc6f9jjfBg==", + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.4.1.tgz", + "integrity": "sha512-3NSMb2VzDQm8oBTLH6Nj55VVtUEpe/rgkIzMir0qVoLyjDZlnMBva0U6vDiV3IH+sl/Yu6oP5QwsAQtHPmDd2Q==", "dev": true }, "uglifyjs-webpack-plugin": { @@ -6705,9 +7008,9 @@ } }, "universalify": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.1.tgz", - "integrity": "sha1-+nG63UQ3r0wUiEHjs7Fl+enlkLc=", + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", "dev": true }, "unpipe": { diff --git a/package.json b/package.json index 6ccede2e..3c70c417 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,7 @@ "aurelia-tools": "0.2.4", "dts-bundle-generator": "^1.6.1", "gulp-watch": "^5.0.1", - "jasmine-core": "^2.4.1", + "jasmine-core": "^3.3.0", "karma": "^3.0.0", "karma-chrome-launcher": "^2.2.0", "karma-jasmine": "^1.1.2", @@ -78,26 +78,16 @@ "karma-sourcemap-loader": "^0.3.7", "karma-webpack": "^3.0.0", "rimraf": "^2.6.2", - "rollup": "^0.64.1", - "rollup-plugin-typescript2": "^0.16.1", + "rollup": "^1.7.4", + "rollup-plugin-typescript2": "^0.20.1", "ts-loader": "^4.4.2", "tslib": "^1.9.3", "tslint": "^5.11.0", - "typescript": "^3.0.1", + "typescript": "^3.4.1", "webpack": "^4.16.5", "yargs": "^4.8.1" }, "peerDependencies": { "aurelia-history": "^1.1.0" - }, - "aurelia": { - "documentation": { - "articles": [ - { - "title": "Router Configuration", - "href": "doc/article/en-US/router-configuration.md" - } - ] - } } } diff --git a/src/activation.ts b/src/activation.ts index 51b76ddf..a86d0eef 100644 --- a/src/activation.ts +++ b/src/activation.ts @@ -5,25 +5,25 @@ import { activationStrategy } from './navigation-plan'; import { Router } from './router'; export class CanDeactivatePreviousStep { - run(navigationInstruction: NavigationInstruction, next: Next) { + run(navigationInstruction: NavigationInstruction, next: Next): Promise { return processDeactivatable(navigationInstruction, 'canDeactivate', next); } } export class CanActivateNextStep { - run(navigationInstruction: NavigationInstruction, next: Next) { + run(navigationInstruction: NavigationInstruction, next: Next): Promise { return processActivatable(navigationInstruction, 'canActivate', next); } } export class DeactivatePreviousStep { - run(navigationInstruction: NavigationInstruction, next: Next) { + run(navigationInstruction: NavigationInstruction, next: Next): Promise { return processDeactivatable(navigationInstruction, 'deactivate', next, true); } } export class ActivateNextStep { - run(navigationInstruction: NavigationInstruction, next: Next) { + run(navigationInstruction: NavigationInstruction, next: Next): Promise { return processActivatable(navigationInstruction, 'activate', next, true); } } @@ -38,7 +38,7 @@ function processDeactivatable( next: Next, ignoreResult?: boolean ): Promise { - const plan = navigationInstruction.plan; + let plan: Record = navigationInstruction.plan; let infos = findDeactivatable(plan, callbackName); let i = infos.length; // query from inside out @@ -173,7 +173,7 @@ function findActivatable( list: IActivatableInfo[] = [], router?: Router ): IActivatableInfo[] { - let plan = navigationInstruction.plan; + let plan: Record = navigationInstruction.plan; Object .keys(plan) diff --git a/src/aurelia-router.ts b/src/aurelia-router.ts index 07f3320b..07b1a0f2 100644 --- a/src/aurelia-router.ts +++ b/src/aurelia-router.ts @@ -10,11 +10,13 @@ export { NavigationResult, Next, PipelineResult, - PipelineStep, - ViewPort, - ViewPortPlan, - ViewPortInstruction, - ViewPortComponent + PipelineStep + // following are excluded and wait for more proper chance to be introduced for stronger typings story + // this is to avoid any typings issue for a long delayed release + // ViewPort, + // ViewPortPlan, + // ViewPortInstruction, + // ViewPortComponent } from './interfaces'; export { ActivateNextStep, diff --git a/src/interfaces.ts b/src/interfaces.ts index 68f77209..9c1bfc78 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -14,8 +14,30 @@ declare module 'aurelia-dependency-injection' { } } -export type RouteCommand = { redirect: string } | { moduleId: string } | { viewModel: string }; -export type RouteConfigSpecifier = string | RouteCommand | ((instruction: NavigationInstruction) => string | RouteCommand | Promise); +/** + * A configuration object that describes a route for redirection + */ +export interface RedirectConfig { + /** + * path that will be redirected to. This is relative to currently in process router + */ + redirect: string; +} + +/** + * A more generic RouteConfig for unknown route. Either a redirect config or a `RouteConfig` + * Redirect config is generally used in `mapUnknownRoutes` of `RouterConfiguration` + */ +export type RouteOrRedirectConfig = RouteConfig | RedirectConfig; + +/** + * A RouteConfig specifier. Could be a string, or an object with `RouteConfig` interface shape, + * or could be an object with redirect interface shape + */ +export type RouteConfigSpecifier = + string + | RouteOrRedirectConfig + | ((instruction: NavigationInstruction) => string | RouteOrRedirectConfig | Promise); /** * A configuration object that describes a route. diff --git a/src/navigation-instruction.ts b/src/navigation-instruction.ts index 8f1f88d0..7ebdb18d 100644 --- a/src/navigation-instruction.ts +++ b/src/navigation-instruction.ts @@ -15,12 +15,17 @@ export interface NavigationInstructionInit { plan?: Record; } +/** + * A pipeline step for instructing a piepline to commit changes on a navigation instruction + */ export class CommitChangesStep { - run(navigationInstruction: NavigationInstruction, next: Function) { - return navigationInstruction._commitChanges(true).then(() => { - navigationInstruction._updateTitle(); - return next(); - }); + run(navigationInstruction: NavigationInstruction, next: Function): Promise { + return navigationInstruction + ._commitChanges(/*wait to swap?*/true) + .then(() => { + navigationInstruction._updateTitle(); + return next(); + }); } } @@ -68,14 +73,17 @@ export class NavigationInstruction { /** * viewPort instructions to used activation. */ - viewPortInstructions: Record; + viewPortInstructions: Record; /** * The router instance. */ router: Router; - plan: Record = null; + /** + * Current built viewport plan of this nav instruction + */ + plan: Record = null; options: Record = {}; @@ -112,8 +120,10 @@ export class NavigationInstruction { */ getAllInstructions(): Array { let instructions: NavigationInstruction[] = [this]; - for (let key in this.viewPortInstructions) { - let childInstruction = this.viewPortInstructions[key].childNavigationInstruction; + let viewPortInstructions: Record = this.viewPortInstructions; + + for (let key in viewPortInstructions) { + let childInstruction = viewPortInstructions[key].childNavigationInstruction; if (childInstruction) { instructions.push(...childInstruction.getAllInstructions()); } @@ -134,14 +144,15 @@ export class NavigationInstruction { * Adds a viewPort instruction. */ addViewPortInstruction(name: string, strategy: ActivationStrategyType, moduleId: string, component: any): ViewPortInstruction { - const config: RouteConfig = Object.assign({}, this.lifecycleArgs[1], { currentViewPort: name }); + const lifecycleArgs = this.lifecycleArgs; + const config: RouteConfig = Object.assign({}, lifecycleArgs[1], { currentViewPort: name }); const viewportInstruction = this.viewPortInstructions[name] = { name: name, strategy: strategy, moduleId: moduleId, component: component, childRouter: component.childRouter, - lifecycleArgs: [].concat(this.lifecycleArgs[0], config, this.lifecycleArgs[2]) as LifecycleArguments + lifecycleArgs: [].concat(lifecycleArgs[0], config, lifecycleArgs[2]) as LifecycleArguments }; return viewportInstruction; @@ -162,9 +173,10 @@ export class NavigationInstruction { getWildcardPath(): string { let wildcardName = this.getWildCardName(); let path = this.params[wildcardName] || ''; + let queryString = this.queryString; - if (this.queryString) { - path += '?' + this.queryString; + if (queryString) { + path += '?' + queryString; } return path; @@ -174,6 +186,7 @@ export class NavigationInstruction { * Gets the instruction's base URL, accounting for wildcard route parameters. */ getBaseUrl(): string { + let $encodeURI = encodeURI; let fragment = decodeURI(this.fragment); if (fragment === '') { @@ -187,17 +200,17 @@ export class NavigationInstruction { } if (!this.params) { - return encodeURI(fragment); + return $encodeURI(fragment); } let wildcardName = this.getWildCardName(); let path = this.params[wildcardName] || ''; if (!path) { - return encodeURI(fragment); + return $encodeURI(fragment); } - return encodeURI(fragment.substr(0, fragment.lastIndexOf(path))); + return $encodeURI(fragment.substr(0, fragment.lastIndexOf(path))); } /**@internal */ @@ -205,8 +218,9 @@ export class NavigationInstruction { let router = this.router; router.currentInstruction = this; - if (this.previousInstruction) { - this.previousInstruction.config.navModel.isActive = false; + const previousInstruction = this.previousInstruction; + if (previousInstruction) { + previousInstruction.config.navModel.isActive = false; } this.config.navModel.isActive = true; @@ -215,34 +229,36 @@ export class NavigationInstruction { let loads: Promise[] = []; let delaySwaps: ISwapPlan[] = []; + let viewPortInstructions: Record = this.viewPortInstructions; - for (let viewPortName in this.viewPortInstructions) { - let viewPortInstruction = this.viewPortInstructions[viewPortName]; + for (let viewPortName in viewPortInstructions) { + let viewPortInstruction = viewPortInstructions[viewPortName]; let viewPort = router.viewPorts[viewPortName]; if (!viewPort) { throw new Error(`There was no router-view found in the view for ${viewPortInstruction.moduleId}.`); } + let child_nav_instruction = viewPortInstruction.childNavigationInstruction; if (viewPortInstruction.strategy === activationStrategy.replace) { - if (viewPortInstruction.childNavigationInstruction && viewPortInstruction.childNavigationInstruction.parentCatchHandler) { - loads.push(viewPortInstruction.childNavigationInstruction._commitChanges(waitToSwap)); + if (child_nav_instruction && child_nav_instruction.parentCatchHandler) { + loads.push(child_nav_instruction._commitChanges(waitToSwap)); } else { if (waitToSwap) { delaySwaps.push({ viewPort, viewPortInstruction }); } - loads.push(viewPort - .process(viewPortInstruction, waitToSwap) - .then(() => { - if (viewPortInstruction.childNavigationInstruction) { - return viewPortInstruction.childNavigationInstruction._commitChanges(waitToSwap); - } - return Promise.resolve(); - })); + loads.push( + viewPort + .process(viewPortInstruction, waitToSwap) + .then(() => child_nav_instruction + ? child_nav_instruction._commitChanges(waitToSwap) + : Promise.resolve() + ) + ); } } else { - if (viewPortInstruction.childNavigationInstruction) { - loads.push(viewPortInstruction.childNavigationInstruction._commitChanges(waitToSwap)); + if (child_nav_instruction) { + loads.push(child_nav_instruction._commitChanges(waitToSwap)); } } } @@ -258,9 +274,10 @@ export class NavigationInstruction { /**@internal */ _updateTitle(): void { - let title = this._buildTitle(this.router.titleSeparator); + let router = this.router; + let title = this._buildTitle(router.titleSeparator); if (title) { - this.router.history.setTitle(title); + router.history.setTitle(title); } } @@ -268,16 +285,20 @@ export class NavigationInstruction { _buildTitle(separator: string = ' | '): string { let title = ''; let childTitles = []; + let navModelTitle = this.config.navModel.title; + let instructionRouter = this.router; + let viewPortInstructions: Record = this.viewPortInstructions; - if (this.config.navModel.title) { - title = this.router.transformTitle(this.config.navModel.title); + if (navModelTitle) { + title = instructionRouter.transformTitle(navModelTitle); } - for (let viewPortName in this.viewPortInstructions) { - let viewPortInstruction = this.viewPortInstructions[viewPortName]; + for (let viewPortName in viewPortInstructions) { + let viewPortInstruction = viewPortInstructions[viewPortName]; + let child_nav_instruction = viewPortInstruction.childNavigationInstruction; - if (viewPortInstruction.childNavigationInstruction) { - let childTitle = viewPortInstruction.childNavigationInstruction._buildTitle(separator); + if (child_nav_instruction) { + let childTitle = child_nav_instruction._buildTitle(separator); if (childTitle) { childTitles.push(childTitle); } @@ -288,18 +309,18 @@ export class NavigationInstruction { title = childTitles.join(separator) + (title ? separator : '') + title; } - if (this.router.title) { - title += (title ? separator : '') + this.router.transformTitle(this.router.title); + if (instructionRouter.title) { + title += (title ? separator : '') + instructionRouter.transformTitle(instructionRouter.title); } return title; } } -function prune(instruction: NavigationInstruction) { +const prune = (instruction: NavigationInstruction): void => { instruction.previousInstruction = null; instruction.plan = null; -} +}; interface ISwapPlan { viewPort: ViewPort; diff --git a/src/navigation-plan.ts b/src/navigation-plan.ts index ee33d287..c73b2bbc 100644 --- a/src/navigation-plan.ts +++ b/src/navigation-plan.ts @@ -105,7 +105,7 @@ export function _buildNavigationPlan( const task: Promise = prevViewPortInstruction .childRouter ._createNavigationInstruction(path, instruction) - .then(childInstruction => { + .then((childInstruction: any) => { viewPortPlan.childNavigationInstruction = childInstruction; return _buildNavigationPlan( diff --git a/src/pipeline-provider.ts b/src/pipeline-provider.ts index 8dbd48d3..4b1c34ba 100644 --- a/src/pipeline-provider.ts +++ b/src/pipeline-provider.ts @@ -12,7 +12,7 @@ import { import { PipelineStep, StepRunnerFunction, IPipelineSlot } from './interfaces'; -class PipelineSlot { +class PipelineSlot implements IPipelineSlot { /**@internal */ container: Container; @@ -39,6 +39,7 @@ class PipelineSlot { */ export class PipelineProvider { + /**@internal */ static inject() { return [Container]; } /**@internal */ container: Container; diff --git a/src/route-loading.ts b/src/route-loading.ts index 032d9f02..31f2b7e3 100644 --- a/src/route-loading.ts +++ b/src/route-loading.ts @@ -20,7 +20,9 @@ export class RouteLoader { /** * Load a route config based on its viewmodel / view configuration */ - loadRoute(router: Router, config: RouteConfig, navigationInstruction: NavigationInstruction): Promise { + // return typing: return typings used to be never + // as it was a throw. Changing it to Promise should not cause any issues + loadRoute(router: Router, config: RouteConfig, navigationInstruction: NavigationInstruction): Promise { throw new Error('Route loaders must implement "loadRoute(router, config, navigationInstruction)".'); } } @@ -71,7 +73,7 @@ export const determineWhatToLoad = ( navigationInstruction: NavigationInstruction, toLoad: ILoadingPlan[] = [] ): ILoadingPlan[] => { - let plan = navigationInstruction.plan; + let plan: Record = navigationInstruction.plan; for (let viewPortName in plan) { let viewPortPlan = plan[viewPortName]; @@ -145,6 +147,7 @@ export const loadRoute = ( /** * Load a routed-component based on navigation instruction and route config + * @internal exported for unit testing only */ export const loadComponent = ( routeLoader: RouteLoader, @@ -156,7 +159,12 @@ export const loadComponent = ( return Promise.resolve() .then(() => routeLoader.loadRoute(router, config, navigationInstruction)) - .then((component) => { + .then( + /** + * @param component an object carrying information about loaded route + * typically contains information about view model, childContainer, view and router + */ + (component: ViewPortComponent) => { let { viewModel, childContainer } = component; component.router = router; component.config = config; diff --git a/src/router-configuration.ts b/src/router-configuration.ts index 6dfd2f4f..184846f4 100644 --- a/src/router-configuration.ts +++ b/src/router-configuration.ts @@ -1,4 +1,4 @@ -import { RouteConfig, PipelineStep, RouteConfigSpecifier, ViewPortInstruction } from './interfaces'; +import { RouteConfig, PipelineStep, RouteConfigSpecifier } from './interfaces'; import { _ensureArrayWithSingleRoutePerConfig } from './util'; import { Router } from './router'; import { NavigationInstruction } from './navigation-instruction'; @@ -22,7 +22,7 @@ export class RouterConfiguration { title: string; titleSeparator: string; unknownRouteConfig: RouteConfigSpecifier; - viewPortDefaults: Record>; + viewPortDefaults: Record; /**@internal */ _fallbackRoute: string; @@ -177,7 +177,7 @@ export class RouterConfiguration { } if (this.unknownRouteConfig) { - router.handleUnknownRoutes(this.unknownRouteConfig as any); + router.handleUnknownRoutes(this.unknownRouteConfig); } if (this._fallbackRoute) { diff --git a/src/router.ts b/src/router.ts index 68136c3f..aa2b4211 100644 --- a/src/router.ts +++ b/src/router.ts @@ -152,7 +152,7 @@ export class Router { /** * The defaults used when a viewport lacks specified content */ - viewPortDefaults: Record> = {}; + viewPortDefaults: Record = {}; /**@internal */ catchAllHandler: (instruction: NavigationInstruction) => NavigationInstruction | Promise; @@ -430,7 +430,9 @@ export class Router { config.navModel = navModel; - if ((navModel.order || navModel.order === 0) && this.navigation.indexOf(navModel) === -1) { + let navigation = this.navigation; + + if ((navModel.order || navModel.order === 0) && navigation.indexOf(navModel) === -1) { if ((!navModel.href && navModel.href !== '') && (state.types.dynamics || state.types.stars)) { throw new Error('Invalid route config for "' + config.route + '" : dynamic routes must specify an "href:" to be included in the navigation model.'); } @@ -439,9 +441,15 @@ export class Router { navModel.order = ++this._fallbackOrder; } - this.navigation.push(navModel); + navigation.push(navModel); // this is a potential error / inconsistency between browsers - this.navigation = this.navigation.sort((a, b) => a.order - b.order); + // + // MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort + // If compareFunction(a, b) returns 0, leave a and b unchanged with respect to each other, + // but sorted with respect to all different elements. + // Note: the ECMAscript standard does not guarantee this behaviour, + // and thus not all browsers (e.g. Mozilla versions dating back to at least 2003) respect this. + navigation.sort((a, b) => a.order - b.order); } } @@ -468,14 +476,14 @@ export class Router { * * @param config The moduleId, or a function that selects the moduleId, or a [[RouteConfig]]. */ - handleUnknownRoutes(config?: string | Function | RouteConfig): void { + handleUnknownRoutes(config?: RouteConfigSpecifier): void { if (!config) { throw new Error('Invalid unknown route handler'); } this.catchAllHandler = instruction => { return this - ._createRouteConfig(config as RouteConfigSpecifier, instruction) + ._createRouteConfig(config, instruction) .then(c => { instruction.config = c; return instruction; @@ -487,12 +495,14 @@ export class Router { * Updates the document title using the current navigation instruction. */ updateTitle(): void { - if (this.parent) { - return this.parent.updateTitle(); + let parentRouter = this.parent; + if (parentRouter) { + return parentRouter.updateTitle(); } - if (this.currentInstruction) { - this.currentInstruction._updateTitle(); + let currentInstruction = this.currentInstruction; + if (currentInstruction) { + currentInstruction._updateTitle(); } return undefined; } @@ -519,7 +529,9 @@ export class Router { * populate a view port for which no module is specified. The default is * an empty view/view-model pair. */ - useViewPortDefaults(viewPortDefaults: Record>) { + useViewPortDefaults($viewPortDefaults: Record) { + // a workaround to have strong typings while not requiring to expose interface ViewPortInstruction + let viewPortDefaults: Record = $viewPortDefaults; for (let viewPortName in viewPortDefaults) { let viewPortConfig = viewPortDefaults[viewPortName]; this.viewPortDefaults[viewPortName] = { @@ -530,8 +542,9 @@ export class Router { /**@internal */ _refreshBaseUrl(): void { - if (this.parent) { - this.baseUrl = generateBaseUrl(this.parent, this.parent.currentInstruction); + let parentRouter = this.parent; + if (parentRouter) { + this.baseUrl = generateBaseUrl(parentRouter, parentRouter.currentInstruction); } } @@ -638,11 +651,9 @@ export class Router { /** * @internal */ - _createRouteConfig( - config: RouteConfigSpecifier, - instruction: NavigationInstruction - ) { - return Promise.resolve(config) + _createRouteConfig(config: RouteConfigSpecifier, instruction: NavigationInstruction): Promise { + return Promise + .resolve(config) .then((c: any) => { if (typeof c === 'string') { return { moduleId: c } as RouteConfig; @@ -652,6 +663,9 @@ export class Router { return c; }) + // typing here could be either RouteConfig or RedirectConfig + // but temporarily treat both as RouteConfig + // todo: improve typings precision .then((c: string | RouteConfig) => typeof c === 'string' ? { moduleId: c } as RouteConfig : c) .then((c: RouteConfig) => { c.route = instruction.params.path;