mentie 0.2.36 → 0.2.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/modules/environment.js +74 -1
- package/modules/logging.js +3 -1
- package/modules/validations.js +3 -1
- package/package.json +1 -1
package/modules/environment.js
CHANGED
|
@@ -77,6 +77,41 @@ env.node_loglevel = () => env.is_node() && process.env?.LOG_LEVEL
|
|
|
77
77
|
*/
|
|
78
78
|
env.loglevel = () => env.web_loglevel() || env.node_loglevel() || env.dev() ? 'info' : 'error'
|
|
79
79
|
|
|
80
|
+
/**
|
|
81
|
+
* Checks if the code is running in a web browser and the platform is Mac.
|
|
82
|
+
* @returns {boolean} True if the code is running in a web browser and the platform is Mac, otherwise false.
|
|
83
|
+
*/
|
|
84
|
+
env.is_mac = () => env.is_web() && navigator.userAgent?.toUpperCase().includes( 'MAC' )
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Checks if the code is running in a web browser and the platform is iPhone.
|
|
88
|
+
* @returns {boolean} True if the code is running in a web browser and the platform is iPhone, otherwise false.
|
|
89
|
+
*/
|
|
90
|
+
env.is_iphone = () => env.is_web() && navigator.userAgent?.toUpperCase().includes( 'IPHONE' )
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Checks if the code is running in a web browser and the platform is Android.
|
|
94
|
+
* @returns {boolean} True if the code is running in a web browser and the platform is Android, otherwise false.
|
|
95
|
+
*/
|
|
96
|
+
env.is_android = () => env.is_web() && navigator.userAgent?.toUpperCase().includes( 'ANDROID' )
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Checks if the code is running in a web browser and the platform is iOS.
|
|
100
|
+
* @returns {boolean} True if the code is running in a web browser and the platform is made by Apple
|
|
101
|
+
*/
|
|
102
|
+
env.is_apple = () => env.is_web() && navigator.userAgent?.toUpperCase().includes( 'MAC OS X' )
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Checks if the code is running in a web browser and the platform is Windows.
|
|
106
|
+
* @returns {boolean} True if the code is running in a web browser and the platform is Linux, otherwise false.
|
|
107
|
+
*/
|
|
108
|
+
env.is_linux = () => env.is_web() && navigator.userAgent?.toUpperCase().includes( 'LINUX' )
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Checks if the code is running in a web browser and the platform is Windows.
|
|
112
|
+
* @returns {boolean} True if the code is running in a web browser and the platform is Windows, otherwise false.
|
|
113
|
+
*/
|
|
114
|
+
env.is_windows = () => env.is_web() && navigator.userAgent?.toUpperCase().includes( 'WIN' )
|
|
80
115
|
|
|
81
116
|
/**
|
|
82
117
|
* Checks if the code is running in a web environment.
|
|
@@ -114,6 +149,36 @@ export const is_emulator = env.is_emulator()
|
|
|
114
149
|
*/
|
|
115
150
|
export const is_github_actions = typeof process !== 'undefined' && process.env?.GITHUB_ACTIONS == true
|
|
116
151
|
|
|
152
|
+
/**
|
|
153
|
+
* @returns {boolean} Returns true if the code is running on an Apple device, otherwise returns false.
|
|
154
|
+
*/
|
|
155
|
+
export const is_apple = env.is_apple()
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* @returns {boolean} Returns true if the code is running on an iPhone, otherwise returns false.
|
|
159
|
+
*/
|
|
160
|
+
export const is_iphone = env.is_iphone()
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* @returns {boolean} Returns true if the code is running on a Mac, otherwise returns false.
|
|
164
|
+
*/
|
|
165
|
+
export const is_mac = env.is_mac()
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* @returns {boolean} Returns true if the code is running on an Android device, otherwise returns false.
|
|
169
|
+
*/
|
|
170
|
+
export const is_android = env.is_android()
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* @returns {boolean} Returns true if the code is running on a Linux device, otherwise returns false.
|
|
174
|
+
*/
|
|
175
|
+
export const is_linux = env.is_linux()
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* @returns {boolean} Returns true if the code is running on a Windows device, otherwise returns false.
|
|
179
|
+
*/
|
|
180
|
+
export const is_windows = env.is_windows()
|
|
181
|
+
|
|
117
182
|
// ///////////////////////////////
|
|
118
183
|
// Mode and loglevel detection
|
|
119
184
|
// ///////////////////////////////
|
|
@@ -156,7 +221,15 @@ export const log_environment = logger => {
|
|
|
156
221
|
is_web,
|
|
157
222
|
loglevel: web_loglevel,
|
|
158
223
|
window: typeof window !== 'undefined' && window,
|
|
159
|
-
search: typeof location !== 'undefined' && location.search
|
|
224
|
+
search: typeof location !== 'undefined' && location.search,
|
|
225
|
+
platform: {
|
|
226
|
+
is_android,
|
|
227
|
+
is_apple,
|
|
228
|
+
is_iphone,
|
|
229
|
+
is_linux,
|
|
230
|
+
is_mac,
|
|
231
|
+
is_windows
|
|
232
|
+
}
|
|
160
233
|
},
|
|
161
234
|
node: {
|
|
162
235
|
is_node,
|
package/modules/logging.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import stringify from "safe-stable-stringify"
|
|
2
|
+
|
|
1
3
|
// Import environment data
|
|
2
4
|
import { dev, env } from "./environment.js"
|
|
3
5
|
|
|
@@ -68,7 +70,7 @@ const annotate_messages = messages => {
|
|
|
68
70
|
if( env.is_cypress() ) {
|
|
69
71
|
|
|
70
72
|
try {
|
|
71
|
-
messages = messages.map( message =>
|
|
73
|
+
messages = messages.map( message => stringify( message, null, 2 ) )
|
|
72
74
|
} catch {
|
|
73
75
|
// This fails if the JSON was something curcular, se we'll leave things as they are
|
|
74
76
|
}
|
package/modules/validations.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import stringify from "safe-stable-stringify"
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Regular expression for validating email addresses.
|
|
3
5
|
* @see {@link https://emailregex.com/}
|
|
@@ -82,7 +84,7 @@ export const shallow_compare_objects = ( obj1={}, obj2={}, include_originals=fal
|
|
|
82
84
|
const changes = keys.reduce( ( acc, key ) => {
|
|
83
85
|
|
|
84
86
|
// Check if the key is in both objects
|
|
85
|
-
if(
|
|
87
|
+
if( stringify( obj1[ key ] ) === stringify( obj2[ key ] ) ) return acc
|
|
86
88
|
|
|
87
89
|
// Generate from/to object
|
|
88
90
|
const changes = { from: obj1[ key ], to: obj2[ key ] }
|