diff options
author | Artur <artur@vaadin.com> | 2017-04-24 12:04:15 +0300 |
---|---|---|
committer | Ilia Motornyi <elmot@vaadin.com> | 2017-04-24 11:04:15 +0200 |
commit | bb46fff4376095fb52443973577767026807a7ea (patch) | |
tree | 815dcd357f856174e52c21d554e1b1f9b98fad22 /shared | |
parent | 70a3a105b22a01ee1114b40e50c18cdd5b194e50 (diff) | |
download | vaadin-framework-bb46fff4376095fb52443973577767026807a7ea.tar.gz vaadin-framework-bb46fff4376095fb52443973577767026807a7ea.zip |
Add support for frontend:// using separate es5 and es6 folders
Diffstat (limited to 'shared')
3 files changed, 78 insertions, 1 deletions
diff --git a/shared/src/main/java/com/vaadin/shared/ApplicationConstants.java b/shared/src/main/java/com/vaadin/shared/ApplicationConstants.java index 17ef828ba5..286cd07760 100644 --- a/shared/src/main/java/com/vaadin/shared/ApplicationConstants.java +++ b/shared/src/main/java/com/vaadin/shared/ApplicationConstants.java @@ -45,6 +45,8 @@ public class ApplicationConstants implements Serializable { public static final String PUBLISHED_PROTOCOL_NAME = "published"; public static final String PUBLISHED_PROTOCOL_PREFIX = PUBLISHED_PROTOCOL_NAME + "://"; + public static final String FRONTEND_PROTOCOL_PREFIX = "frontend://"; + /** * Prefix used for theme resource URLs * @@ -98,6 +100,16 @@ public class ApplicationConstants implements Serializable { public static final String VAADIN_DIR_URL = "vaadinDir"; /** + * Configuration parameter giving the (in some cases relative) URL to the + * frontend resource folder from where frontend files are served (this is + * what frontend:// should resolve to). + * <p> + * By default, this is "vaadin://es6" ("vaadin://es5" for browsers which + * does not support ES6). + */ + public static final String FRONTEND_URL = "frontendUrl"; + + /** * The name of the javascript containing the bootstrap code. The file is * located in the VAADIN directory. * @@ -184,4 +196,30 @@ public class ApplicationConstants implements Serializable { */ public static final String CONTENT_TYPE_TEXT_HTML_UTF_8 = "text/html; charset=utf-8"; + /** + * Configuration name for the {@literal frontend://} URL when using a + * browser which is not ES6 compatible (i.e. IE11 or Safari 9). + */ + public static final String FRONTEND_URL_ES5 = "frontend.url.es5"; + + /** + * Configuration name for the {@literal frontend://} URL when using an ES6 + * compatible browser. + */ + public static final String FRONTEND_URL_ES6 = "frontend.url.es6"; + + /** + * Default value of the configuration of the build URL of ES6 web + * components. + */ + public static final String FRONTEND_URL_ES6_DEFAULT_VALUE = VAADIN_PROTOCOL_PREFIX + + "frontend/es6/"; + + /** + * Default value of the configuration of the build URL of ES5 web + * components. + */ + public static final String FRONTEND_URL_ES5_DEFAULT_VALUE = VAADIN_PROTOCOL_PREFIX + + "frontend/es5/"; + } diff --git a/shared/src/main/java/com/vaadin/shared/VBrowserDetails.java b/shared/src/main/java/com/vaadin/shared/VBrowserDetails.java index 99dac478bc..c3c1baa582 100644 --- a/shared/src/main/java/com/vaadin/shared/VBrowserDetails.java +++ b/shared/src/main/java/com/vaadin/shared/VBrowserDetails.java @@ -149,7 +149,8 @@ public class VBrowserDetails implements Serializable { parseVersionString(tmp); } } else if (isTrident) { - // See https://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx#TriToken + // See + // https://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx#TriToken setIEMode((int) browserEngineVersion + 4); } else { String ieVersionString = userAgent @@ -585,4 +586,23 @@ public class VBrowserDetails implements Serializable { return false; } + public boolean isEs6Supported() { + if (isTooOldToFunctionProperly()) { + return false; + } + + // assumes evergreen browsers support ES6 + if (isChrome() || isFirefox() || isOpera() || isEdge()) { + return true; + } + + // Safari > 9 + if (isSafari() && getBrowserMajorVersion() > 9) { + return true; + } + + // IE11 and Safari 9 + return false; + } + } diff --git a/shared/src/main/java/com/vaadin/shared/VaadinUriResolver.java b/shared/src/main/java/com/vaadin/shared/VaadinUriResolver.java index 5755c686bf..6c02028d8b 100644 --- a/shared/src/main/java/com/vaadin/shared/VaadinUriResolver.java +++ b/shared/src/main/java/com/vaadin/shared/VaadinUriResolver.java @@ -45,6 +45,9 @@ public abstract class VaadinUriResolver implements Serializable { * RequestHandler} instances.</li> * <li><code>vaadin://</code> - resolves to the location of static resouces * in the VAADIN directory</li> + * <li><code>frontend://</code> - resolves to the location of frontend + * (Bower and similar) resources, which might vary depending on the used + * browser</li> * </ul> * Any other URI protocols, such as <code>http://</code> or * <code>https://</code> are passed through this method unmodified. @@ -58,6 +61,13 @@ public abstract class VaadinUriResolver implements Serializable { if (vaadinUri == null) { return null; } + if (vaadinUri + .startsWith(ApplicationConstants.FRONTEND_PROTOCOL_PREFIX)) { + final String frontendUrl = getFrontendUrl(); + vaadinUri = frontendUrl + vaadinUri.substring( + ApplicationConstants.FRONTEND_PROTOCOL_PREFIX.length()); + } + if (vaadinUri.startsWith(ApplicationConstants.THEME_PROTOCOL_PREFIX)) { final String themeUri = getThemeUri(); vaadinUri = themeUri + vaadinUri.substring(7); @@ -172,4 +182,13 @@ public abstract class VaadinUriResolver implements Serializable { */ protected abstract String encodeQueryStringParameterValue( String parameterValue); + + /** + * Returns the URL pointing to the folder containing frontend files, either + * for ES5 (if browser does not support ES6) or ES6 (most browsers). + * + * @return the absolute or relative URL to the frontend files, ending with a + * slash '/' + */ + protected abstract String getFrontendUrl(); } |