Comparing version 1.3.3 to 1.4.0
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.clearCache=clearCache;exports.getBrowser=getBrowser;exports.getLocale=getLocale;exports.getPlatform=getPlatform;exports.getTimeZone=getTimeZone;exports.globalVar=globalVar;exports.isGlobal=isGlobal;exports.setLocale=setLocale;exports.setPlatform=setPlatform;exports.setTimeZone=setTimeZone;exports.top=top;function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},_typeof(o)}function getPlatformValue(){try{if(typeof java.lang.Object!=="undefined"){return typeof process!=="undefined"?"trireme":"rhino"}}catch(e){}if(typeof global!=="undefined"&&global.process&&global.process.versions&&global.process.versions.node){return"nodejs"}else if(typeof Qt!=="undefined"){return"qt"}else if(typeof PalmSystem!=="undefined"){return typeof window!=="undefined"?"webos-webapp":"webos"}else if(typeof window!=="undefined"){return"browser"}else{return"unknown"}};function top(){var topScope;var platformValue=typeof platform!=="undefined"?platform:getPlatformValue();switch(platformValue){case"rhino":topScope=function(){return(typeof global==="undefined"?"undefined":_typeof(global))==="object"?global:this}();break;case"nodejs":case"qt":case"trireme":topScope=typeof global!=="undefined"?global:this;break;default:topScope=window;break}return topScope};function getPlatform(){var globalScope=top();if(!globalScope.platform){globalScope.platform=getPlatformValue()}return globalScope.platform};function setPlatform(plat){var globalScope=top();globalScope.platform=plat};function getBrowser(){var globalScope=top();if(getPlatform()==="browser"&&!globalScope.browser){if(navigator&&navigator.userAgent){if(navigator.userAgent.indexOf("Firefox")>-1){globalScope.browser="firefox"}else if(navigator.userAgent.search(/Opera|OPR/)>-1){globalScope.browser="opera"}else if(navigator.userAgent.indexOf("Chrome")>-1){globalScope.browser="chrome"}else if(navigator.userAgent.indexOf(" .NET")>-1){globalScope.browser="ie"}else if(navigator.userAgent.indexOf("Safari")>-1){globalScope.browser="safari"}else if(navigator.userAgent.indexOf("Edge")>-1){globalScope.browser="Edge"}else if(navigator.userAgent.search(/iPad|iPhone|iPod/)>-1){globalScope.browser="iOS"}}}return globalScope.browser};function globalVar(name){try{return top()[name]}catch(e){return undefined}};function isGlobal(name){return typeof globalVar(name)!=="undefined"};var locale;function parseLocale(str){if(!str)return str;var dot=str.indexOf(".");if(dot>-1){str=str.substring(0,dot)}if(str==="C")return"en-US";var parts=str.replace(/_/g,"-").split(/-/g);var localeParts=[];if(parts.length>0){if(parts[0].length===2||parts[0].length===3){localeParts.push(parts[0].toLowerCase());if(parts.length>1){if(parts[1].length===4){localeParts.push(parts[1][0].toUpperCase()+parts[1].substring(1).toLowerCase())}else if(parts[1].length===2||parts[1].length==3){localeParts.push(parts[1].toUpperCase())}if(parts.length>2){if(parts[2].length===2||parts[2].length==3){localeParts.push(parts[2].toUpperCase())}}}}}return localeParts.join("-")}function getLocale(){var globalScope=top();var lang,dot;if(typeof globalScope.locale!=="string"){var plat=getPlatform();switch(plat){case"browser":if(typeof navigator.language!=="undefined"){globalScope.locale=parseLocale(navigator.language)}if(!globalScope.locale){lang=typeof navigator.browserLanguage!=="undefined"?navigator.browserLanguage:typeof navigator.userLanguage!=="undefined"?navigator.userLanguage:typeof navigator.systemLanguage!=="undefined"?navigator.systemLanguage:undefined;globalScope.locale=parseLocale(lang)}break;case"webos-webapp":case"webos":if(typeof PalmSystem.locales!=="undefined"&&typeof PalmSystem.locales.UI!="undefined"&&PalmSystem.locales.UI.length>0){globalScope.locale=parseLocale(PalmSystem.locales.UI)}else if(typeof PalmSystem.locale!=="undefined"){globalScope.locale=parseLocale(PalmSystem.locale)}else{globalScope.locale=undefined}break;case"rhino":if(typeof environment!=="undefined"&&environment.user&&typeof environment.user.language==="string"&&environment.user.language.length>0){var l=[environment.user.language];if(typeof environment.user.country==="string"&&environment.user.country.length>0){l.push(environment.user.country)}globalScope.locale=l.join("-")}break;case"trireme":lang=process.env.LANG||process.env.LANGUAGE||process.env.LC_ALL;globalScope.locale=parseLocale(lang);break;case"nodejs":lang=global.process.env.LANG||global.process.env.LC_ALL;globalScope.locale=parseLocale(lang);break;case"qt":var locobj=Qt.locale();globalScope.locale=parseLocale(locobj.name||"en-US");break}globalScope.locale=typeof globalScope.locale==="string"&&globalScope.locale.length&&globalScope.locale!=="C"?globalScope.locale:"en-US";if(globalScope.locale==="en"){globalScope.locale="en-US"}}return globalScope.locale};function setLocale(locale){if(typeof locale!=="string"&&typeof locale!=="undefined"){return}var globalScope=top();globalScope.locale=typeof locale==="undefined"?locale:parseLocale(locale)};function getTimeZone(){var tz,globalScope=top();if(typeof globalScope.tz==="undefined"){if(typeof Intl!=="undefined"&&typeof Intl.DateTimeFormat!=="undefined"){var ro=new Intl.DateTimeFormat().resolvedOptions();var timeZone=ro.timeZone;if(timeZone&&timeZone!=="Etc/Unknown"){globalScope.tz=timeZone;return globalScope.tz}}var timezone;switch(getPlatform()){case"browser":var _navigator=navigator;timezone=_navigator.timezone;if(timezone&&timezone.length>0){tz=timezone}break;case"webos-webapp":case"webos":var _PalmSystem=PalmSystem;timezone=_PalmSystem.timezone;if(timezone&&timezone.length>0){tz=timezone}break;case"rhino":if(typeof environment.user.timezone!=="undefined"&&environment.user.timezone.length>0){tz=environment.user.timezone}break;case"nodejs":if(global.process.env){tz=global.process.env.TZ}break}globalScope.tz=tz||"local"}return globalScope.tz};function setTimeZone(zoneName){if(typeof zoneName!=="string"&&typeof zoneName!=="undefined"){return}var globalScope=top();globalScope.tz=zoneName};function clearCache(){var globalScope=top();globalScope.platform=globalScope.locale=globalScope.browser=globalScope.tz=undefined}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.clearCache=clearCache;exports.getBrowser=getBrowser;exports.getLocale=getLocale;exports.getPlatform=getPlatform;exports.getTimeZone=getTimeZone;exports.globalVar=globalVar;exports.isGlobal=isGlobal;exports.setLocale=setLocale;exports.setPlatform=setPlatform;exports.setTimeZone=setTimeZone;exports.top=top;function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},_typeof(o)}function getPlatformValue(){try{if(typeof java.lang.Object!=="undefined"){return typeof process!=="undefined"?"trireme":"rhino"}}catch(e){}if(typeof global!=="undefined"&&global.process&&global.process.versions&&global.process.versions.node){return"nodejs"}else if(typeof Qt!=="undefined"){return"qt"}else if(typeof PalmSystem!=="undefined"||typeof webOSSystem!=="undefined"){return typeof window!=="undefined"?"webos-webapp":"webos"}else if(typeof window!=="undefined"){return"browser"}else{return"unknown"}};function top(){var topScope;var platformValue=typeof platform!=="undefined"?platform:getPlatformValue();switch(platformValue){case"rhino":topScope=function(){return(typeof global==="undefined"?"undefined":_typeof(global))==="object"?global:this}();break;case"nodejs":case"qt":case"trireme":topScope=typeof global!=="undefined"?global:this;break;default:topScope=window;break}return topScope};function getPlatform(){var globalScope=top();if(!globalScope.platform){globalScope.platform=getPlatformValue()}return globalScope.platform};function setPlatform(plat){var globalScope=top();globalScope.platform=plat};function getBrowser(){var globalScope=top();if(getPlatform()==="browser"&&!globalScope.browser){if(navigator&&navigator.userAgent){if(navigator.userAgent.indexOf("Firefox")>-1){globalScope.browser="firefox"}else if(navigator.userAgent.search(/Opera|OPR/)>-1){globalScope.browser="opera"}else if(navigator.userAgent.indexOf("Chrome")>-1){globalScope.browser="chrome"}else if(navigator.userAgent.indexOf(" .NET")>-1){globalScope.browser="ie"}else if(navigator.userAgent.indexOf("Safari")>-1){globalScope.browser="safari"}else if(navigator.userAgent.indexOf("Edge")>-1){globalScope.browser="Edge"}else if(navigator.userAgent.search(/iPad|iPhone|iPod/)>-1){globalScope.browser="iOS"}}}return globalScope.browser};function globalVar(name){try{return top()[name]}catch(e){return undefined}};function isGlobal(name){return typeof globalVar(name)!=="undefined"};var locale;function parseLocale(str){if(!str)return str;var dot=str.indexOf(".");if(dot>-1){str=str.substring(0,dot)}if(str==="C")return"en-US";var parts=str.replace(/_/g,"-").split(/-/g);var localeParts=[];if(parts.length>0){if(parts[0].length===2||parts[0].length===3){localeParts.push(parts[0].toLowerCase());if(parts.length>1){if(parts[1].length===4){localeParts.push(parts[1][0].toUpperCase()+parts[1].substring(1).toLowerCase())}else if(parts[1].length===2||parts[1].length==3){localeParts.push(parts[1].toUpperCase())}if(parts.length>2){if(parts[2].length===2||parts[2].length==3){localeParts.push(parts[2].toUpperCase())}}}}}return localeParts.join("-")}function getLocale(){var globalScope=top();var lang,dot;if(typeof globalScope.locale!=="string"){var plat=getPlatform();switch(plat){case"browser":if(typeof navigator.language!=="undefined"){globalScope.locale=parseLocale(navigator.language)}if(!globalScope.locale){lang=typeof navigator.browserLanguage!=="undefined"?navigator.browserLanguage:typeof navigator.userLanguage!=="undefined"?navigator.userLanguage:typeof navigator.systemLanguage!=="undefined"?navigator.systemLanguage:undefined;globalScope.locale=parseLocale(lang)}break;case"webos-webapp":case"webos":if(typeof PalmSystem.locales!=="undefined"&&typeof PalmSystem.locales.UI!="undefined"&&PalmSystem.locales.UI.length>0){globalScope.locale=parseLocale(PalmSystem.locales.UI)}else if(typeof PalmSystem.locale!=="undefined"){globalScope.locale=parseLocale(PalmSystem.locale)}else if(typeof webOSSystem.locale!=="undefined"){ilib.locale=parseLocale(webOSSystem.locale)}else{globalScope.locale=undefined}break;case"rhino":if(typeof environment!=="undefined"&&environment.user&&typeof environment.user.language==="string"&&environment.user.language.length>0){var l=[environment.user.language];if(typeof environment.user.country==="string"&&environment.user.country.length>0){l.push(environment.user.country)}globalScope.locale=l.join("-")}break;case"trireme":lang=process.env.LANG||process.env.LANGUAGE||process.env.LC_ALL;globalScope.locale=parseLocale(lang);break;case"nodejs":lang=global.process.env.LANG||global.process.env.LC_ALL;globalScope.locale=parseLocale(lang);break;case"qt":var locobj=Qt.locale();globalScope.locale=parseLocale(locobj.name||"en-US");break}globalScope.locale=typeof globalScope.locale==="string"&&globalScope.locale.length&&globalScope.locale!=="C"?globalScope.locale:"en-US";if(globalScope.locale==="en"){globalScope.locale="en-US"}}return globalScope.locale};function setLocale(locale){if(typeof locale!=="string"&&typeof locale!=="undefined"){return}var globalScope=top();globalScope.locale=typeof locale==="undefined"?locale:parseLocale(locale)};function getTimeZone(){var tz,globalScope=top();if(typeof globalScope.tz==="undefined"){if(typeof Intl!=="undefined"&&typeof Intl.DateTimeFormat!=="undefined"){var ro=new Intl.DateTimeFormat().resolvedOptions();var _timeZone=ro.timeZone;if(_timeZone&&_timeZone!=="Etc/Unknown"){globalScope.tz=_timeZone;return globalScope.tz}}var timezone,timeZone;switch(getPlatform()){case"browser":var _navigator=navigator;timezone=_navigator.timezone;if(timezone&&timezone.length>0){tz=timezone}break;case"webos-webapp":case"webos":var _PalmSystem=PalmSystem;timezone=_PalmSystem.timezone;var _webOSSystem=webOSSystem;timeZone=_webOSSystem.timeZone;if(timezone&&timezone.length>0||timeZone&&timeZone.length>0){tz=timezone}break;case"rhino":if(typeof environment.user.timezone!=="undefined"&&environment.user.timezone.length>0){tz=environment.user.timezone}break;case"nodejs":if(global.process.env){tz=global.process.env.TZ}break}globalScope.tz=tz||"local"}return globalScope.tz};function setTimeZone(zoneName){if(typeof zoneName!=="string"&&typeof zoneName!=="undefined"){return}var globalScope=top();globalScope.tz=zoneName};function clearCache(){var globalScope=top();globalScope.platform=globalScope.locale=globalScope.browser=globalScope.tz=undefined}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "ilib-env", | ||
"version": "1.3.3", | ||
"version": "1.4.0", | ||
"main": "./lib/index.js", | ||
@@ -72,3 +72,4 @@ "module": "./src/index.js", | ||
"doc": "mkdir -p docs ; jsdoc2md -c jsdoc.json --separators --source src/* -m table > docs/ilibEnv.md", | ||
"doc:html": "jsdoc -c jsdoc.json" | ||
"doc:html": "jsdoc -c jsdoc.json", | ||
"prepare": "conditional-install" | ||
}, | ||
@@ -80,5 +81,5 @@ "devDependencies": { | ||
"@babel/runtime": "^7.23.5", | ||
"babel-loader": "^8.3.0", | ||
"babel-plugin-add-module-exports": "^1.0.4", | ||
"babel-plugin-module-resolver": "^5.0.0", | ||
"conditional-install": "^1.0.1", | ||
"docdash": "^2.0.2", | ||
@@ -101,8 +102,21 @@ "expect": "^29.7.0", | ||
"karma-jasmine": "^5.1.0", | ||
"karma-webpack": "^5.0.0", | ||
"load-grunt-tasks": "^5.1.0", | ||
"npm-run-all": "^4.1.5", | ||
"webpack": "^5.89.0", | ||
"webpack-cli": "^5.1.4" | ||
"npm-run-all": "^4.1.5" | ||
}, | ||
"conditionalDependencies": { | ||
"process.versions.node < v14.0.0": { | ||
"babel-loader": "^8.0.0", | ||
"jest": "^26.0.0", | ||
"karma-webpack": "^4.0.0", | ||
"webpack": "^4.0.0", | ||
"webpack-cli": "^4.0.0" | ||
}, | ||
"process.versions.node >= v14.0.0": { | ||
"babel-loader": "^9.0.0", | ||
"jest": "^29.7.0", | ||
"karma-webpack": "^5.0.0", | ||
"webpack": "^5.89.0", | ||
"webpack-cli": "^5.1.4" | ||
} | ||
} | ||
} |
@@ -189,3 +189,3 @@ # ilib-env | ||
Copyright © 2021-2023, JEDLSoft | ||
Copyright © 2021-2024, JEDLSoft | ||
@@ -207,2 +207,5 @@ Licensed under the Apache License, Version 2.0 (the "License"); | ||
### v1.4.0 | ||
* Update to detect webOS platform with webOSSystem value. | ||
### v1.3.3 | ||
@@ -209,0 +212,0 @@ |
/* | ||
* index.js - detect various things in the runtime environment | ||
* | ||
* Copyright © 2021-2023, JEDLSoft | ||
* Copyright © 2021-2024, JEDLSoft | ||
* | ||
@@ -38,3 +38,3 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
return "qt"; | ||
} else if (typeof(PalmSystem) !== 'undefined') { | ||
} else if ((typeof(PalmSystem) !== 'undefined')|| (typeof(webOSSystem) !== 'undefined')) { | ||
return (typeof(window) !== 'undefined') ? "webos-webapp" : "webos"; | ||
@@ -264,2 +264,4 @@ } else if (typeof(window) !== 'undefined') { | ||
globalScope.locale = parseLocale(PalmSystem.locale); | ||
} else if (typeof(webOSSystem.locale) !== 'undefined') { | ||
ilib.locale = parseLocale(webOSSystem.locale); | ||
} else { | ||
@@ -345,3 +347,3 @@ globalScope.locale = undefined; | ||
} | ||
let timezone; | ||
let timezone, timeZone; | ||
@@ -360,3 +362,4 @@ switch (getPlatform()) { | ||
({ timezone } = PalmSystem); | ||
if (timezone && timezone.length > 0) { | ||
({ timeZone } = webOSSystem); | ||
if ((timezone && timezone.length > 0) || (timeZone && timeZone.length > 0)) { | ||
tz = timezone; | ||
@@ -363,0 +366,0 @@ } |
Sorry, the diff of this file is not supported yet
74618
26
404
283