diff --git a/Resources/package.json b/Resources/package.json index 0d2e198..828361e 100755 --- a/Resources/package.json +++ b/Resources/package.json @@ -34,8 +34,8 @@ "google-closure-library": "^20220104.0.0", "gulp": "^4.0.2", "gulp-rename": "^2.0.0", - "gulp-uglify": "^3.0.2", "gulp-typescript": "^6.0.0-alpha.1", + "gulp-uglify": "^3.0.2", "gulp-wrap": "^0.15.0", "jasmine": "^4.0.2", "tsd": "^0.19.1", @@ -47,8 +47,5 @@ "test": "npm run build && npm run test:types && phantomjs js/run_jsunit.js js/router_test.html", "test:types": "tsd", "prepublish": "npm run build" - }, - "dependencies": { - "webpack-inject-plugin": "^1.5.5" } } diff --git a/Resources/public/js/router.js b/Resources/public/js/router.js index 0d1c911..30d79dd 100644 --- a/Resources/public/js/router.js +++ b/Resources/public/js/router.js @@ -1,22 +1,22 @@ -(function (root, factory) { - var routing = factory(); - if (typeof define === 'function' && define.amd) { - // AMD. Register as an anonymous module. - define([], routing.Routing); - } else if (typeof module === 'object' && module.exports) { - // Node. Does not work with strict CommonJS, but - // only CommonJS-like environments that support module.exports, - // like Node. - module.exports = routing.Routing; - } else { - // Browser globals (root is window) - root.Routing = routing.Routing; - root.fos = { - Router: routing.Router - }; - } -}(this, function () { - var exports = {}; +(function (root, factory) { + var routing = factory(); + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define([], routing.Routing); + } else if (typeof module === 'object' && module.exports) { + // Node. Does not work with strict CommonJS, but + // only CommonJS-like environments that support module.exports, + // like Node. + module.exports = routing.Routing; + } else { + // Browser globals (root is window) + root.Routing = routing.Routing; + root.fos = { + Router: routing.Router + }; + } +}(this, function () { + var exports = {}; "use strict"; exports.__esModule = true; exports.Routing = exports.Router = void 0; @@ -277,7 +277,7 @@ var Router = /** @class */ (function () { exports.Router = Router; exports.Routing = new Router(); exports["default"] = exports.Routing; - - - return { Router: exports.Router, Routing: exports.Routing }; -})); \ No newline at end of file + + + return { Router: exports.Router, Routing: exports.Routing }; +})); \ No newline at end of file diff --git a/Resources/public/js/router.min.js b/Resources/public/js/router.min.js index 50f2442..02793a9 100644 --- a/Resources/public/js/router.min.js +++ b/Resources/public/js/router.min.js @@ -1 +1 @@ -!function(e){(t={}).__esModule=!0,t.Routing=t.Router=void 0,o=function(){function l(e,t){this.context_=e||{base_url:"",prefix:"",host:"",port:"",scheme:"",locale:""},this.setRoutes(t||{})}return l.getInstance=function(){return t.Routing},l.setData=function(e){l.getInstance().setRoutingData(e)},l.prototype.setRoutingData=function(e){this.setBaseUrl(e.base_url),this.setRoutes(e.routes),void 0!==e.prefix&&this.setPrefix(e.prefix),void 0!==e.port&&this.setPort(e.port),void 0!==e.locale&&this.setLocale(e.locale),this.setHost(e.host),void 0!==e.scheme&&this.setScheme(e.scheme)},l.prototype.setRoutes=function(e){this.routes_=Object.freeze(e)},l.prototype.getRoutes=function(){return this.routes_},l.prototype.setBaseUrl=function(e){this.context_.base_url=e},l.prototype.getBaseUrl=function(){return this.context_.base_url},l.prototype.setPrefix=function(e){this.context_.prefix=e},l.prototype.setScheme=function(e){this.context_.scheme=e},l.prototype.getScheme=function(){return this.context_.scheme},l.prototype.setHost=function(e){this.context_.host=e},l.prototype.getHost=function(){return this.context_.host},l.prototype.setPort=function(e){this.context_.port=e},l.prototype.getPort=function(){return this.context_.port},l.prototype.setLocale=function(e){this.context_.locale=e},l.prototype.getLocale=function(){return this.context_.locale},l.prototype.buildQueryParams=function(o,e,n){var t,r=this,s=new RegExp(/\[\]$/);if(e instanceof Array)e.forEach(function(e,t){s.test(o)?n(o,e):r.buildQueryParams(o+"["+("object"==typeof e?t:"")+"]",e,n)});else if("object"==typeof e)for(t in e)this.buildQueryParams(o+"["+t+"]",e[t],n);else n(o,e)},l.prototype.getRoute=function(e){var t,o=[this.context_.prefix+e,e+"."+this.context_.locale,this.context_.prefix+e+"."+this.context_.locale,e];for(t in o)if(o[t]in this.routes_)return this.routes_[o[t]];throw new Error('The route "'+e+'" does not exist.')},l.prototype.generate=function(r,e,p){var t,s=this.getRoute(r),i=e||{},u=Object.assign({},i),c="",a=!0,o="",e=void 0===this.getPort()||null===this.getPort()?"":this.getPort();if(s.tokens.forEach(function(e){if("text"===e[0]&&"string"==typeof e[1])return c=l.encodePathComponent(e[1])+c,void(a=!1);if("variable"!==e[0])throw new Error('The token type "'+e[0]+'" is not supported.');6===e.length&&!0===e[5]&&(a=!1);var t=s.defaults&&!Array.isArray(s.defaults)&&"string"==typeof e[3]&&e[3]in s.defaults;if(!1===a||!t||"string"==typeof e[3]&&e[3]in i&&!Array.isArray(s.defaults)&&i[e[3]]!=s.defaults[e[3]]){var o,n=void 0;if("string"==typeof e[3]&&e[3]in i)n=i[e[3]],delete u[e[3]];else{if("string"!=typeof e[3]||!t||Array.isArray(s.defaults)){if(a)return;throw new Error('The route "'+r+'" requires the parameter "'+e[3]+'".')}n=s.defaults[e[3]]}(!0===n||!1===n||""===n)&&a||(o=l.encodePathComponent(n),c=e[1]+(o="null"===o&&null===n?"":o)+c),a=!1}else t&&"string"==typeof e[3]&&e[3]in u&&delete u[e[3]]}),""===c&&(c="/"),s.hosttokens.forEach(function(e){var t;"text"!==e[0]?"variable"===e[0]&&(e[3]in i?(t=i[e[3]],delete u[e[3]]):s.defaults&&!Array.isArray(s.defaults)&&e[3]in s.defaults&&(t=s.defaults[e[3]]),o=e[1]+t+o):o=e[1]+o}),c=this.context_.base_url+c,s.requirements&&"_scheme"in s.requirements&&this.getScheme()!=s.requirements._scheme?(t=o||this.getHost(),c=s.requirements._scheme+"://"+t+(-1 { - return 'import Routing from "fos-router";' + - 'import routes from '+JSON.stringify(this.finalTarget)+';' + - 'Routing.setRoutingData(routes);'; - }).apply(compiler); + new webpack.BannerPlugin({ + entryOnly: true, + include: this.finalTarget ? this.finalTarget + ".js" : /\.js$/, + raw: true, + banner: + 'import Routing from "fos-router";' + + "import routes from " + + JSON.stringify(this.finalTarget) + + ";" + + "Routing.setRoutingData(routes);", + }).apply(compiler); } }