@magicpixel/rn-mp-client-sdk 0.12.0 → 1.13.0
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/lib/commonjs/common/app-types.js.map +1 -1
- package/lib/commonjs/common/constants.js +5 -26
- package/lib/commonjs/common/constants.js.map +1 -1
- package/lib/commonjs/common/data-store.js +36 -117
- package/lib/commonjs/common/data-store.js.map +1 -1
- package/lib/commonjs/common/event-bus.js +3 -10
- package/lib/commonjs/common/event-bus.js.map +1 -1
- package/lib/commonjs/common/logger.js +9 -18
- package/lib/commonjs/common/logger.js.map +1 -1
- package/lib/commonjs/common/network-service.js +4 -21
- package/lib/commonjs/common/network-service.js.map +1 -1
- package/lib/commonjs/common/reporter.js +8 -31
- package/lib/commonjs/common/reporter.js.map +1 -1
- package/lib/commonjs/common/utils.js +64 -65
- package/lib/commonjs/common/utils.js.map +1 -1
- package/lib/commonjs/coverage/lcov-report/block-navigation.js +6 -19
- package/lib/commonjs/coverage/lcov-report/block-navigation.js.map +1 -1
- package/lib/commonjs/coverage/lcov-report/prettify.js +2 -182
- package/lib/commonjs/coverage/lcov-report/prettify.js.map +1 -1
- package/lib/commonjs/coverage/lcov-report/sorter.js +64 -94
- package/lib/commonjs/coverage/lcov-report/sorter.js.map +1 -1
- package/lib/commonjs/eedl/eedl.js +207 -84
- package/lib/commonjs/eedl/eedl.js.map +1 -1
- package/lib/commonjs/index.js +104 -95
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/geo-api-response.js +2 -0
- package/lib/commonjs/models/geo-api-response.js.map +1 -0
- package/lib/commonjs/models/mp-client-sdk.js +3 -11
- package/lib/commonjs/models/mp-client-sdk.js.map +1 -1
- package/lib/commonjs/processors/data-element.processor.js +85 -80
- package/lib/commonjs/processors/data-element.processor.js.map +1 -1
- package/lib/commonjs/processors/geo-location.processor.js +70 -0
- package/lib/commonjs/processors/geo-location.processor.js.map +1 -0
- package/lib/commonjs/processors/qc.processor.js +2 -25
- package/lib/commonjs/processors/qc.processor.js.map +1 -1
- package/lib/commonjs/processors/tag.processor.js +17 -86
- package/lib/commonjs/processors/tag.processor.js.map +1 -1
- package/lib/commonjs/processors/trans-function.processor.js +5 -23
- package/lib/commonjs/processors/trans-function.processor.js.map +1 -1
- package/lib/commonjs/processors/visit-id.processor.js +4 -50
- package/lib/commonjs/processors/visit-id.processor.js.map +1 -1
- package/lib/module/common/app-types.js.map +1 -1
- package/lib/module/common/constants.js +4 -22
- package/lib/module/common/constants.js.map +1 -1
- package/lib/module/common/data-store.js +35 -108
- package/lib/module/common/data-store.js.map +1 -1
- package/lib/module/common/event-bus.js +3 -6
- package/lib/module/common/event-bus.js.map +1 -1
- package/lib/module/common/logger.js +9 -16
- package/lib/module/common/logger.js.map +1 -1
- package/lib/module/common/network-service.js +4 -11
- package/lib/module/common/network-service.js.map +1 -1
- package/lib/module/common/reporter.js +8 -19
- package/lib/module/common/reporter.js.map +1 -1
- package/lib/module/common/utils.js +63 -56
- package/lib/module/common/utils.js.map +1 -1
- package/lib/module/coverage/lcov-report/block-navigation.js +6 -19
- package/lib/module/coverage/lcov-report/block-navigation.js.map +1 -1
- package/lib/module/coverage/lcov-report/prettify.js +2 -182
- package/lib/module/coverage/lcov-report/prettify.js.map +1 -1
- package/lib/module/coverage/lcov-report/sorter.js +64 -94
- package/lib/module/coverage/lcov-report/sorter.js.map +1 -1
- package/lib/module/eedl/eedl.js +206 -76
- package/lib/module/eedl/eedl.js.map +1 -1
- package/lib/module/index.js +102 -57
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/geo-api-response.js +2 -0
- package/lib/module/models/geo-api-response.js.map +1 -0
- package/lib/module/models/mp-client-sdk.js +0 -5
- package/lib/module/models/mp-client-sdk.js.map +1 -1
- package/lib/module/processors/data-element.processor.js +82 -71
- package/lib/module/processors/data-element.processor.js.map +1 -1
- package/lib/module/processors/geo-location.processor.js +63 -0
- package/lib/module/processors/geo-location.processor.js.map +1 -0
- package/lib/module/processors/qc.processor.js +2 -11
- package/lib/module/processors/qc.processor.js.map +1 -1
- package/lib/module/processors/tag.processor.js +17 -57
- package/lib/module/processors/tag.processor.js.map +1 -1
- package/lib/module/processors/trans-function.processor.js +5 -12
- package/lib/module/processors/trans-function.processor.js.map +1 -1
- package/lib/module/processors/visit-id.processor.js +4 -27
- package/lib/module/processors/visit-id.processor.js.map +1 -1
- package/lib/typescript/common/app-types.d.ts +3 -0
- package/lib/typescript/common/constants.d.ts +1 -0
- package/lib/typescript/common/data-store.d.ts +8 -0
- package/lib/typescript/common/utils.d.ts +19 -0
- package/lib/typescript/eedl/eedl.d.ts +16 -5
- package/lib/typescript/index.d.ts +53 -0
- package/lib/typescript/models/geo-api-response.d.ts +12 -0
- package/lib/typescript/processors/data-element.processor.d.ts +10 -1
- package/lib/typescript/processors/geo-location.processor.d.ts +10 -0
- package/package.json +25 -15
- package/src/common/app-types.ts +3 -0
- package/src/common/constants.ts +2 -0
- package/src/common/data-store.ts +38 -0
- package/src/common/utils.ts +58 -0
- package/src/eedl/eedl.ts +241 -18
- package/src/index.tsx +98 -3
- package/src/models/geo-api-response.ts +13 -0
- package/src/processors/data-element.processor.ts +140 -70
- package/src/processors/geo-location.processor.ts +91 -0
|
@@ -4,35 +4,26 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Utils = void 0;
|
|
7
|
-
|
|
8
7
|
var _constants = require("./constants");
|
|
9
|
-
|
|
10
8
|
var _logger = require("./logger");
|
|
11
|
-
|
|
12
9
|
var _flat = require("flat");
|
|
13
|
-
|
|
14
10
|
var _eventBus = require("./event-bus");
|
|
15
|
-
|
|
16
11
|
var _reactNative = require("react-native");
|
|
17
|
-
|
|
18
12
|
var _reactNativeUrlPolyfill = require("react-native-url-polyfill");
|
|
19
|
-
|
|
13
|
+
var _asyncStorage = _interopRequireDefault(require("@react-native-async-storage/async-storage"));
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
20
15
|
class Utils {
|
|
21
16
|
static triggerEvent(eventName, payload) {
|
|
22
17
|
_eventBus.EventBus.triggerEvent(eventName, payload);
|
|
23
18
|
}
|
|
24
|
-
|
|
25
19
|
static calculateMsp(dim, limit) {
|
|
26
20
|
return dim.scale * dim.width >= limit || dim.scale * dim.height >= limit;
|
|
27
21
|
}
|
|
28
|
-
|
|
29
22
|
static _makeUniqueStringArray(input) {
|
|
30
23
|
return [...new Set(input)];
|
|
31
24
|
}
|
|
32
|
-
|
|
33
25
|
static parseQueryParamsToObject(url) {
|
|
34
26
|
const op = {};
|
|
35
|
-
|
|
36
27
|
try {
|
|
37
28
|
if (url && (url === null || url === void 0 ? void 0 : url.trim().length) > 0) {
|
|
38
29
|
const urlObject = new _reactNativeUrlPolyfill.URL(url);
|
|
@@ -44,64 +35,51 @@ class Utils {
|
|
|
44
35
|
// TODO: Report error
|
|
45
36
|
_logger.Logger.logError('Unable to parse query params', err);
|
|
46
37
|
}
|
|
47
|
-
|
|
48
38
|
return op;
|
|
49
39
|
}
|
|
50
|
-
|
|
51
40
|
static isTablet() {
|
|
52
41
|
const dim = _reactNative.Dimensions.get('screen');
|
|
53
|
-
|
|
54
42
|
return dim.scale < 2 && this.calculateMsp(dim, 1000) || dim.scale >= 2 && this.calculateMsp(dim, 1900);
|
|
55
43
|
}
|
|
56
|
-
|
|
57
|
-
static sleep() {
|
|
58
|
-
let delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1000;
|
|
44
|
+
static sleep(delay = 1000) {
|
|
59
45
|
return new Promise(resolve => {
|
|
60
46
|
setTimeout(() => {
|
|
61
47
|
return resolve();
|
|
62
48
|
}, delay);
|
|
63
49
|
});
|
|
64
50
|
}
|
|
51
|
+
|
|
65
52
|
/**
|
|
66
53
|
* deviceTypesMappings = {'1':'Desktop Web','2':'Mobile Web','3':'Tablet','4':'Other'};
|
|
67
54
|
* @param deviceType
|
|
68
55
|
*/
|
|
69
|
-
|
|
70
|
-
|
|
71
56
|
static dtToNum(deviceType) {
|
|
72
57
|
switch (deviceType) {
|
|
73
58
|
case 'desktop':
|
|
74
59
|
return 1;
|
|
75
|
-
|
|
76
60
|
case 'mobile':
|
|
77
61
|
return 2;
|
|
78
|
-
|
|
79
62
|
case 'tablet':
|
|
80
63
|
return 3;
|
|
81
|
-
|
|
82
64
|
default:
|
|
83
65
|
return 4;
|
|
84
66
|
}
|
|
85
67
|
}
|
|
68
|
+
|
|
86
69
|
/**
|
|
87
70
|
* static browserToOsMappings = {'101': 'ios','102': 'android', '7': 'Other'};
|
|
88
71
|
* @param browser
|
|
89
72
|
*/
|
|
90
|
-
|
|
91
|
-
|
|
92
73
|
static bwToNum(browser) {
|
|
93
74
|
switch (browser) {
|
|
94
75
|
case 'ios':
|
|
95
76
|
return 101;
|
|
96
|
-
|
|
97
77
|
case 'android':
|
|
98
78
|
return 102;
|
|
99
|
-
|
|
100
79
|
default:
|
|
101
80
|
return 7;
|
|
102
81
|
}
|
|
103
82
|
}
|
|
104
|
-
|
|
105
83
|
static langToNum(language) {
|
|
106
84
|
if (language === 'en') {
|
|
107
85
|
return 1;
|
|
@@ -111,16 +89,10 @@ class Utils {
|
|
|
111
89
|
return 3;
|
|
112
90
|
}
|
|
113
91
|
}
|
|
114
|
-
|
|
115
|
-
static mergeMaps(input) {
|
|
92
|
+
static mergeMaps(input, ...toMerge) {
|
|
116
93
|
if (!input) {
|
|
117
94
|
input = {};
|
|
118
95
|
}
|
|
119
|
-
|
|
120
|
-
for (var _len = arguments.length, toMerge = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
121
|
-
toMerge[_key - 1] = arguments[_key];
|
|
122
|
-
}
|
|
123
|
-
|
|
124
96
|
for (const mapObject of toMerge) {
|
|
125
97
|
if (mapObject) {
|
|
126
98
|
Object.keys(mapObject).forEach(key => {
|
|
@@ -128,25 +100,21 @@ class Utils {
|
|
|
128
100
|
});
|
|
129
101
|
}
|
|
130
102
|
}
|
|
131
|
-
|
|
132
103
|
return input;
|
|
133
104
|
}
|
|
134
|
-
|
|
135
105
|
static applyTransformationResourceParam(paramValue, tf) {
|
|
136
106
|
if (!tf || tf.length === 0) {
|
|
137
107
|
return paramValue;
|
|
138
108
|
}
|
|
139
|
-
|
|
140
109
|
if (typeof paramValue === 'undefined') {
|
|
141
110
|
return paramValue;
|
|
142
|
-
}
|
|
143
|
-
|
|
111
|
+
}
|
|
144
112
|
|
|
113
|
+
// transformers here are expected to be ordered when we get it from the server after build
|
|
145
114
|
for (let tfItem of tf) {
|
|
146
115
|
if (tfItem.nm === 'enc') {
|
|
147
116
|
// only url encode is implemented now
|
|
148
117
|
tfItem = tfItem;
|
|
149
|
-
|
|
150
118
|
if (tfItem.eTyp === 'URL_ENC') {
|
|
151
119
|
paramValue = encodeURIComponent(paramValue);
|
|
152
120
|
} else if (tfItem.eTyp === 'BASE64') {
|
|
@@ -154,9 +122,9 @@ class Utils {
|
|
|
154
122
|
}
|
|
155
123
|
}
|
|
156
124
|
}
|
|
157
|
-
|
|
158
125
|
return paramValue;
|
|
159
126
|
}
|
|
127
|
+
|
|
160
128
|
/**
|
|
161
129
|
* Verifies if the given 'toTest' string exists in any of the input array of strings.
|
|
162
130
|
* By default, this method does a case sensitive match unless specified by the ignoreCase param.
|
|
@@ -165,18 +133,13 @@ class Utils {
|
|
|
165
133
|
* @param ignoreCase - pass a value of 'true' to perform case-insensitive matching.
|
|
166
134
|
* @param fullMatch
|
|
167
135
|
*/
|
|
168
|
-
|
|
169
|
-
|
|
170
136
|
static isMatch(toTest, inputs, ignoreCase, fullMatch) {
|
|
171
137
|
if (!toTest) {
|
|
172
138
|
return false;
|
|
173
139
|
}
|
|
174
|
-
|
|
175
140
|
let isMatched = false;
|
|
176
|
-
|
|
177
141
|
for (let i = 0; i < inputs.length; i += 1) {
|
|
178
142
|
const _val = inputs[i];
|
|
179
|
-
|
|
180
143
|
if (_val) {
|
|
181
144
|
if (this.convertToRegex(_val, ignoreCase, fullMatch).test(toTest)) {
|
|
182
145
|
isMatched = true;
|
|
@@ -184,14 +147,11 @@ class Utils {
|
|
|
184
147
|
}
|
|
185
148
|
}
|
|
186
149
|
}
|
|
187
|
-
|
|
188
150
|
return isMatched;
|
|
189
151
|
}
|
|
190
|
-
|
|
191
152
|
static regExpEscape(input) {
|
|
192
153
|
return input.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&');
|
|
193
154
|
}
|
|
194
|
-
|
|
195
155
|
static convertToRegex(input, ignoreCase, fullMatch) {
|
|
196
156
|
if (fullMatch) {
|
|
197
157
|
return new RegExp('^' + input.split(/\*+/).map(this.regExpEscape).join('.*') + '$', ignoreCase ? 'i' : '');
|
|
@@ -199,7 +159,6 @@ class Utils {
|
|
|
199
159
|
return new RegExp(input.split(/\*+/).map(this.regExpEscape).join('.*'), ignoreCase ? 'i' : '');
|
|
200
160
|
}
|
|
201
161
|
}
|
|
202
|
-
|
|
203
162
|
static safeExecute(fn, payload) {
|
|
204
163
|
try {
|
|
205
164
|
return fn(payload);
|
|
@@ -207,27 +166,74 @@ class Utils {
|
|
|
207
166
|
_logger.Logger.logError('Error executing function: ', err);
|
|
208
167
|
}
|
|
209
168
|
}
|
|
210
|
-
|
|
211
169
|
static getUniqueID() {
|
|
212
170
|
return _constants.Constants.LARGE_RANDOM_POOL();
|
|
213
171
|
}
|
|
214
172
|
|
|
173
|
+
/**
|
|
174
|
+
* Make HTTP GET request - React Native implementation
|
|
175
|
+
* @param url URL to fetch
|
|
176
|
+
* @returns Promise with response data
|
|
177
|
+
*/
|
|
178
|
+
static async getHttp(url) {
|
|
179
|
+
try {
|
|
180
|
+
const response = await fetch(url, {
|
|
181
|
+
method: 'GET',
|
|
182
|
+
headers: {
|
|
183
|
+
'Content-Type': 'application/json'
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
if (!response.ok) {
|
|
187
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
188
|
+
}
|
|
189
|
+
return await response.json();
|
|
190
|
+
} catch (error) {
|
|
191
|
+
_logger.Logger.logError('HTTP GET request failed:', error);
|
|
192
|
+
throw error;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Get value from AsyncStorage (React Native equivalent of sessionStorage)
|
|
198
|
+
* @param key Storage key
|
|
199
|
+
* @param defaultValue Default value if key not found
|
|
200
|
+
* @returns Promise with stored value or default
|
|
201
|
+
*/
|
|
202
|
+
static async getValueFromAsyncStorage(key, defaultValue) {
|
|
203
|
+
try {
|
|
204
|
+
const value = await _asyncStorage.default.getItem(key);
|
|
205
|
+
return value ? JSON.parse(value) : defaultValue;
|
|
206
|
+
} catch (error) {
|
|
207
|
+
_logger.Logger.logError('Error getting value from AsyncStorage:', error);
|
|
208
|
+
return defaultValue;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Set value to AsyncStorage (React Native equivalent of sessionStorage)
|
|
214
|
+
* @param key Storage key
|
|
215
|
+
* @param value Value to store
|
|
216
|
+
*/
|
|
217
|
+
static async setValueToAsyncStorage(key, value) {
|
|
218
|
+
try {
|
|
219
|
+
await _asyncStorage.default.setItem(key, JSON.stringify(value));
|
|
220
|
+
} catch (error) {
|
|
221
|
+
_logger.Logger.logError('Error setting value to AsyncStorage:', error);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
215
224
|
static getSimpleDebugId(prefix) {
|
|
216
225
|
return `${prefix ?? ''}${this.randomNumber(100000000, 99999999999)}`;
|
|
217
226
|
}
|
|
218
|
-
|
|
219
227
|
static randomNumber(min, max) {
|
|
220
228
|
return Math.ceil(Math.random() * (max - min) + min);
|
|
221
229
|
}
|
|
222
|
-
|
|
223
230
|
static unFlattenResourceParams(input) {
|
|
224
231
|
if (!input || input.length === 0) {
|
|
225
232
|
return {};
|
|
226
233
|
}
|
|
227
|
-
|
|
228
234
|
const transformMap = {};
|
|
229
|
-
const op = {};
|
|
230
|
-
|
|
235
|
+
const op = {};
|
|
236
|
+
// convert input into a map for quick search O(1)
|
|
231
237
|
for (const item of input) {
|
|
232
238
|
if (item.pId) {
|
|
233
239
|
if (!transformMap[item.pId]) {
|
|
@@ -240,9 +246,9 @@ class Utils {
|
|
|
240
246
|
item.children = [];
|
|
241
247
|
transformMap[item.id] = item;
|
|
242
248
|
}
|
|
243
|
-
}
|
|
244
|
-
|
|
249
|
+
}
|
|
245
250
|
|
|
251
|
+
// sort children according to child_order inside children if they have any children
|
|
246
252
|
for (const item of Object.values(transformMap)) {
|
|
247
253
|
if (item.children && item.children.length > 0) {
|
|
248
254
|
item.children = item.children.sort(_constants.Constants.sortAscending);
|
|
@@ -251,33 +257,26 @@ class Utils {
|
|
|
251
257
|
op[item.nm] = item;
|
|
252
258
|
}
|
|
253
259
|
}
|
|
254
|
-
|
|
255
260
|
return op;
|
|
256
261
|
}
|
|
257
|
-
|
|
258
262
|
static unFlattenObject(obj) {
|
|
259
263
|
if (!obj) {
|
|
260
264
|
return {};
|
|
261
265
|
}
|
|
262
|
-
|
|
263
266
|
return (0, _flat.unflatten)(obj, {
|
|
264
267
|
object: false,
|
|
265
268
|
delimiter: '.'
|
|
266
269
|
});
|
|
267
270
|
}
|
|
268
|
-
|
|
269
271
|
static flattenObject(obj) {
|
|
270
272
|
if (!obj) {
|
|
271
273
|
return {};
|
|
272
274
|
}
|
|
273
|
-
|
|
274
275
|
return (0, _flat.flatten)(obj, {
|
|
275
276
|
maxDepth: 5,
|
|
276
277
|
safe: true
|
|
277
278
|
});
|
|
278
279
|
}
|
|
279
|
-
|
|
280
280
|
}
|
|
281
|
-
|
|
282
281
|
exports.Utils = Utils;
|
|
283
282
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Utils","triggerEvent","eventName","payload","EventBus","calculateMsp","dim","limit","scale","width","height","_makeUniqueStringArray","input","Set","parseQueryParamsToObject","url","op","trim","length","urlObject","URL","searchParams","forEach","value","name","err","Logger","logError","isTablet","Dimensions","get","sleep","delay","Promise","resolve","setTimeout","dtToNum","deviceType","bwToNum","browser","langToNum","language","mergeMaps","toMerge","mapObject","Object","keys","key","applyTransformationResourceParam","paramValue","tf","tfItem","nm","eTyp","encodeURIComponent","Buffer","from","toString","isMatch","toTest","inputs","ignoreCase","fullMatch","isMatched","i","_val","convertToRegex","test","regExpEscape","replace","RegExp","split","map","join","safeExecute","fn","getUniqueID","Constants","LARGE_RANDOM_POOL","getSimpleDebugId","prefix","randomNumber","min","max","Math","ceil","random","unFlattenResourceParams","transformMap","item","pId","children","id","push","values","sort","sortAscending","unFlattenObject","obj","unflatten","object","delimiter","flattenObject","flatten","maxDepth","safe"],"sources":["utils.ts"],"sourcesContent":["import { Constants } from './constants';\nimport { Logger } from './logger';\nimport type {\n BaseResourceParamType,\n SdkParamEncodingTransformer,\n TFType,\n} from '../models/mp-client-sdk';\nimport type { MapLike } from './app-types';\nimport { flatten, unflatten } from 'flat';\nimport { EventBus } from './event-bus';\nimport { Dimensions, ScaledSize } from 'react-native';\nimport { URL } from 'react-native-url-polyfill';\n\nexport class Utils {\n static triggerEvent(eventName: string, payload: any): void {\n EventBus.triggerEvent(eventName, payload);\n }\n\n static calculateMsp(dim: ScaledSize, limit: number): boolean {\n return dim.scale * dim.width >= limit || dim.scale * dim.height >= limit;\n }\n\n static _makeUniqueStringArray(input: string[]): string[] {\n return [...new Set(input)];\n }\n\n static parseQueryParamsToObject(url?: string): Record<string, any> {\n const op: Record<string, any> = {};\n try {\n if (url && url?.trim().length > 0) {\n const urlObject = new URL(url);\n urlObject.searchParams.forEach((value, name) => {\n op[name] = value;\n });\n }\n } catch (err) {\n // TODO: Report error\n Logger.logError('Unable to parse query params', err);\n }\n return op;\n }\n\n static isTablet(): boolean {\n const dim = Dimensions.get('screen');\n return (\n (dim.scale < 2 && this.calculateMsp(dim, 1000)) ||\n (dim.scale >= 2 && this.calculateMsp(dim, 1900))\n );\n }\n\n static sleep(delay = 1000): Promise<void> {\n return new Promise((resolve: (val?: any) => void) => {\n setTimeout(() => {\n return resolve();\n }, delay);\n });\n }\n\n /**\n * deviceTypesMappings = {'1':'Desktop Web','2':'Mobile Web','3':'Tablet','4':'Other'};\n * @param deviceType\n */\n static dtToNum(deviceType: string): number {\n switch (deviceType) {\n case 'desktop':\n return 1;\n case 'mobile':\n return 2;\n case 'tablet':\n return 3;\n default:\n return 4;\n }\n }\n\n /**\n * static browserToOsMappings = {'101': 'ios','102': 'android', '7': 'Other'};\n * @param browser\n */\n static bwToNum(browser: string): number {\n switch (browser) {\n case 'ios':\n return 101;\n case 'android':\n return 102;\n default:\n return 7;\n }\n }\n\n static langToNum(language: string): number {\n if (language === 'en') {\n return 1;\n } else if (language === 'es') {\n return 2;\n } else {\n return 3;\n }\n }\n\n static mergeMaps<T>(\n input: MapLike<T>,\n ...toMerge: Array<MapLike<T>>\n ): MapLike<T> {\n if (!input) {\n input = {} as MapLike<T>;\n }\n for (const mapObject of toMerge) {\n if (mapObject) {\n Object.keys(mapObject).forEach((key: string) => {\n input[key] = mapObject[key];\n });\n }\n }\n return input;\n }\n\n static applyTransformationResourceParam(\n paramValue: string,\n tf: TFType | undefined\n ): any {\n if (!tf || tf.length === 0) {\n return paramValue;\n }\n\n if (typeof paramValue === 'undefined') {\n return paramValue;\n }\n\n // transformers here are expected to be ordered when we get it from the server after build\n for (let tfItem of tf) {\n if (tfItem.nm === 'enc') {\n // only url encode is implemented now\n tfItem = tfItem as SdkParamEncodingTransformer;\n if (tfItem.eTyp === 'URL_ENC') {\n paramValue = encodeURIComponent(paramValue);\n } else if (tfItem.eTyp === 'BASE64') {\n paramValue = Buffer.from(paramValue).toString('base64');\n }\n }\n }\n\n return paramValue;\n }\n\n /**\n * Verifies if the given 'toTest' string exists in any of the input array of strings.\n * By default, this method does a case sensitive match unless specified by the ignoreCase param.\n * @param toTest\n * @param inputs\n * @param ignoreCase - pass a value of 'true' to perform case-insensitive matching.\n * @param fullMatch\n */\n static isMatch(\n toTest: string,\n inputs: string[],\n ignoreCase: boolean,\n fullMatch: boolean\n ): boolean {\n if (!toTest) {\n return false;\n }\n let isMatched = false;\n for (let i = 0; i < inputs.length; i += 1) {\n const _val = inputs[i];\n if (_val) {\n if (this.convertToRegex(_val, ignoreCase, fullMatch).test(toTest)) {\n isMatched = true;\n break;\n }\n }\n }\n return isMatched;\n }\n\n static regExpEscape(input: string): string {\n return input.replace(/[|\\\\{}()[\\]^$+*?.]/g, '\\\\$&');\n }\n\n static convertToRegex(\n input: string,\n ignoreCase: boolean,\n fullMatch: boolean\n ): RegExp {\n if (fullMatch) {\n return new RegExp(\n '^' + input.split(/\\*+/).map(this.regExpEscape).join('.*') + '$',\n ignoreCase ? 'i' : ''\n );\n } else {\n return new RegExp(\n input.split(/\\*+/).map(this.regExpEscape).join('.*'),\n ignoreCase ? 'i' : ''\n );\n }\n }\n\n static safeExecute(fn: (payload: any) => any, payload: any): any {\n try {\n return fn(payload);\n } catch (err) {\n Logger.logError('Error executing function: ', err);\n }\n }\n\n static getUniqueID(): string {\n return Constants.LARGE_RANDOM_POOL();\n }\n\n static getSimpleDebugId(prefix?: string): string {\n return `${prefix ?? ''}${this.randomNumber(100000000, 99999999999)}`;\n }\n\n static randomNumber(min: number, max: number): number {\n return Math.ceil(Math.random() * (max - min) + min);\n }\n\n static unFlattenResourceParams<T extends BaseResourceParamType>(\n input: T[]\n ): MapLike<T> {\n if (!input || input.length === 0) {\n return {};\n }\n\n const transformMap: MapLike<T> = {};\n const op: MapLike<T> = {};\n // convert input into a map for quick search O(1)\n for (const item of input) {\n if (item.pId) {\n if (!transformMap[item.pId]) {\n item.children = [];\n transformMap[item.id] = item;\n } else {\n transformMap[item.pId].children.push(item);\n }\n } else {\n item.children = [];\n transformMap[item.id] = item;\n }\n }\n\n // sort children according to child_order inside children if they have any children\n for (const item of Object.values(transformMap)) {\n if (item.children && item.children.length > 0) {\n item.children = item.children.sort(Constants.sortAscending);\n op[item.nm] = item;\n } else {\n op[item.nm] = item;\n }\n }\n\n return op;\n }\n\n static unFlattenObject(obj: any): Record<string, any> {\n if (!obj) {\n return {};\n }\n return unflatten(obj, { object: false, delimiter: '.' });\n }\n\n static flattenObject(obj: any): Record<string, any> {\n if (!obj) {\n return {};\n }\n return flatten(obj, { maxDepth: 5, safe: true });\n }\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AAOA;;AACA;;AACA;;AACA;;AAEO,MAAMA,KAAN,CAAY;EACE,OAAZC,YAAY,CAACC,SAAD,EAAoBC,OAApB,EAAwC;IACzDC,kBAAA,CAASH,YAAT,CAAsBC,SAAtB,EAAiCC,OAAjC;EACD;;EAEkB,OAAZE,YAAY,CAACC,GAAD,EAAkBC,KAAlB,EAA0C;IAC3D,OAAOD,GAAG,CAACE,KAAJ,GAAYF,GAAG,CAACG,KAAhB,IAAyBF,KAAzB,IAAkCD,GAAG,CAACE,KAAJ,GAAYF,GAAG,CAACI,MAAhB,IAA0BH,KAAnE;EACD;;EAE4B,OAAtBI,sBAAsB,CAACC,KAAD,EAA4B;IACvD,OAAO,CAAC,GAAG,IAAIC,GAAJ,CAAQD,KAAR,CAAJ,CAAP;EACD;;EAE8B,OAAxBE,wBAAwB,CAACC,GAAD,EAAoC;IACjE,MAAMC,EAAuB,GAAG,EAAhC;;IACA,IAAI;MACF,IAAID,GAAG,IAAI,CAAAA,GAAG,SAAH,IAAAA,GAAG,WAAH,YAAAA,GAAG,CAAEE,IAAL,GAAYC,MAAZ,IAAqB,CAAhC,EAAmC;QACjC,MAAMC,SAAS,GAAG,IAAIC,2BAAJ,CAAQL,GAAR,CAAlB;QACAI,SAAS,CAACE,YAAV,CAAuBC,OAAvB,CAA+B,CAACC,KAAD,EAAQC,IAAR,KAAiB;UAC9CR,EAAE,CAACQ,IAAD,CAAF,GAAWD,KAAX;QACD,CAFD;MAGD;IACF,CAPD,CAOE,OAAOE,GAAP,EAAY;MACZ;MACAC,cAAA,CAAOC,QAAP,CAAgB,8BAAhB,EAAgD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AuB,CAA5C,EAA+C;QAC7CuE,IAAI,CAACE,QAAL,GAAgBF,IAAI,CAACE,QAAL,CAAcI,IAAd,CAAmBlB,oBAAA,CAAUmB,aAA7B,CAAhB;QACAhF,EAAE,CAACyE,IAAI,CAACrC,EAAN,CAAF,GAAcqC,IAAd;MACD,CAHD,MAGO;QACLzE,EAAE,CAACyE,IAAI,CAACrC,EAAN,CAAF,GAAcqC,IAAd;MACD;IACF;;IAED,OAAOzE,EAAP;EACD;;EAEqB,OAAfiF,eAAe,CAACC,GAAD,EAAgC;IACpD,IAAI,CAACA,GAAL,EAAU;MACR,OAAO,EAAP;IACD;;IACD,OAAO,IAAAC,eAAA,EAAUD,GAAV,EAAe;MAAEE,MAAM,EAAE,KAAV;MAAiBC,SAAS,EAAE;IAA5B,CAAf,CAAP;EACD;;EAEmB,OAAbC,aAAa,CAACJ,GAAD,EAAgC;IAClD,IAAI,CAACA,GAAL,EAAU;MACR,OAAO,EAAP;IACD;;IACD,OAAO,IAAAK,aAAA,EAAQL,GAAR,EAAa;MAAEM,QAAQ,EAAE,CAAZ;MAAeC,IAAI,EAAE;IAArB,CAAb,CAAP;EACD;;AA7PgB"}
|
|
1
|
+
{"version":3,"names":["_constants","require","_logger","_flat","_eventBus","_reactNative","_reactNativeUrlPolyfill","_asyncStorage","_interopRequireDefault","e","__esModule","default","Utils","triggerEvent","eventName","payload","EventBus","calculateMsp","dim","limit","scale","width","height","_makeUniqueStringArray","input","Set","parseQueryParamsToObject","url","op","trim","length","urlObject","URL","searchParams","forEach","value","name","err","Logger","logError","isTablet","Dimensions","get","sleep","delay","Promise","resolve","setTimeout","dtToNum","deviceType","bwToNum","browser","langToNum","language","mergeMaps","toMerge","mapObject","Object","keys","key","applyTransformationResourceParam","paramValue","tf","tfItem","nm","eTyp","encodeURIComponent","Buffer","from","toString","isMatch","toTest","inputs","ignoreCase","fullMatch","isMatched","i","_val","convertToRegex","test","regExpEscape","replace","RegExp","split","map","join","safeExecute","fn","getUniqueID","Constants","LARGE_RANDOM_POOL","getHttp","response","fetch","method","headers","ok","Error","status","json","error","getValueFromAsyncStorage","defaultValue","AsyncStorage","getItem","JSON","parse","setValueToAsyncStorage","setItem","stringify","getSimpleDebugId","prefix","randomNumber","min","max","Math","ceil","random","unFlattenResourceParams","transformMap","item","pId","children","id","push","values","sort","sortAscending","unFlattenObject","obj","unflatten","object","delimiter","flattenObject","flatten","maxDepth","safe","exports"],"sources":["utils.ts"],"sourcesContent":["import { Constants } from './constants';\nimport { Logger } from './logger';\nimport type {\n BaseResourceParamType,\n SdkParamEncodingTransformer,\n TFType,\n} from '../models/mp-client-sdk';\nimport type { MapLike } from './app-types';\nimport { flatten, unflatten } from 'flat';\nimport { EventBus } from './event-bus';\nimport { Dimensions, ScaledSize } from 'react-native';\nimport { URL } from 'react-native-url-polyfill';\nimport AsyncStorage from '@react-native-async-storage/async-storage';\n\nexport class Utils {\n static triggerEvent(eventName: string, payload: any): void {\n EventBus.triggerEvent(eventName, payload);\n }\n\n static calculateMsp(dim: ScaledSize, limit: number): boolean {\n return dim.scale * dim.width >= limit || dim.scale * dim.height >= limit;\n }\n\n static _makeUniqueStringArray(input: string[]): string[] {\n return [...new Set(input)];\n }\n\n static parseQueryParamsToObject(url?: string): Record<string, any> {\n const op: Record<string, any> = {};\n try {\n if (url && url?.trim().length > 0) {\n const urlObject = new URL(url);\n urlObject.searchParams.forEach((value, name) => {\n op[name] = value;\n });\n }\n } catch (err) {\n // TODO: Report error\n Logger.logError('Unable to parse query params', err);\n }\n return op;\n }\n\n static isTablet(): boolean {\n const dim = Dimensions.get('screen');\n return (\n (dim.scale < 2 && this.calculateMsp(dim, 1000)) ||\n (dim.scale >= 2 && this.calculateMsp(dim, 1900))\n );\n }\n\n static sleep(delay = 1000): Promise<void> {\n return new Promise((resolve: (val?: any) => void) => {\n setTimeout(() => {\n return resolve();\n }, delay);\n });\n }\n\n /**\n * deviceTypesMappings = {'1':'Desktop Web','2':'Mobile Web','3':'Tablet','4':'Other'};\n * @param deviceType\n */\n static dtToNum(deviceType: string): number {\n switch (deviceType) {\n case 'desktop':\n return 1;\n case 'mobile':\n return 2;\n case 'tablet':\n return 3;\n default:\n return 4;\n }\n }\n\n /**\n * static browserToOsMappings = {'101': 'ios','102': 'android', '7': 'Other'};\n * @param browser\n */\n static bwToNum(browser: string): number {\n switch (browser) {\n case 'ios':\n return 101;\n case 'android':\n return 102;\n default:\n return 7;\n }\n }\n\n static langToNum(language: string): number {\n if (language === 'en') {\n return 1;\n } else if (language === 'es') {\n return 2;\n } else {\n return 3;\n }\n }\n\n static mergeMaps<T>(\n input: MapLike<T>,\n ...toMerge: Array<MapLike<T>>\n ): MapLike<T> {\n if (!input) {\n input = {} as MapLike<T>;\n }\n for (const mapObject of toMerge) {\n if (mapObject) {\n Object.keys(mapObject).forEach((key: string) => {\n input[key] = mapObject[key];\n });\n }\n }\n return input;\n }\n\n static applyTransformationResourceParam(\n paramValue: string,\n tf: TFType | undefined\n ): any {\n if (!tf || tf.length === 0) {\n return paramValue;\n }\n\n if (typeof paramValue === 'undefined') {\n return paramValue;\n }\n\n // transformers here are expected to be ordered when we get it from the server after build\n for (let tfItem of tf) {\n if (tfItem.nm === 'enc') {\n // only url encode is implemented now\n tfItem = tfItem as SdkParamEncodingTransformer;\n if (tfItem.eTyp === 'URL_ENC') {\n paramValue = encodeURIComponent(paramValue);\n } else if (tfItem.eTyp === 'BASE64') {\n paramValue = Buffer.from(paramValue).toString('base64');\n }\n }\n }\n\n return paramValue;\n }\n\n /**\n * Verifies if the given 'toTest' string exists in any of the input array of strings.\n * By default, this method does a case sensitive match unless specified by the ignoreCase param.\n * @param toTest\n * @param inputs\n * @param ignoreCase - pass a value of 'true' to perform case-insensitive matching.\n * @param fullMatch\n */\n static isMatch(\n toTest: string,\n inputs: string[],\n ignoreCase: boolean,\n fullMatch: boolean\n ): boolean {\n if (!toTest) {\n return false;\n }\n let isMatched = false;\n for (let i = 0; i < inputs.length; i += 1) {\n const _val = inputs[i];\n if (_val) {\n if (this.convertToRegex(_val, ignoreCase, fullMatch).test(toTest)) {\n isMatched = true;\n break;\n }\n }\n }\n return isMatched;\n }\n\n static regExpEscape(input: string): string {\n return input.replace(/[|\\\\{}()[\\]^$+*?.]/g, '\\\\$&');\n }\n\n static convertToRegex(\n input: string,\n ignoreCase: boolean,\n fullMatch: boolean\n ): RegExp {\n if (fullMatch) {\n return new RegExp(\n '^' + input.split(/\\*+/).map(this.regExpEscape).join('.*') + '$',\n ignoreCase ? 'i' : ''\n );\n } else {\n return new RegExp(\n input.split(/\\*+/).map(this.regExpEscape).join('.*'),\n ignoreCase ? 'i' : ''\n );\n }\n }\n\n static safeExecute(fn: (payload: any) => any, payload: any): any {\n try {\n return fn(payload);\n } catch (err) {\n Logger.logError('Error executing function: ', err);\n }\n }\n\n static getUniqueID(): string {\n return Constants.LARGE_RANDOM_POOL();\n }\n\n /**\n * Make HTTP GET request - React Native implementation\n * @param url URL to fetch\n * @returns Promise with response data\n */\n static async getHttp<T>(url: string): Promise<T> {\n try {\n const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n return await response.json();\n } catch (error) {\n Logger.logError('HTTP GET request failed:', error);\n throw error;\n }\n }\n\n /**\n * Get value from AsyncStorage (React Native equivalent of sessionStorage)\n * @param key Storage key\n * @param defaultValue Default value if key not found\n * @returns Promise with stored value or default\n */\n static async getValueFromAsyncStorage<T>(\n key: string,\n defaultValue: T\n ): Promise<T> {\n try {\n const value = await AsyncStorage.getItem(key);\n return value ? JSON.parse(value) : defaultValue;\n } catch (error) {\n Logger.logError('Error getting value from AsyncStorage:', error);\n return defaultValue;\n }\n }\n\n /**\n * Set value to AsyncStorage (React Native equivalent of sessionStorage)\n * @param key Storage key\n * @param value Value to store\n */\n static async setValueToAsyncStorage(key: string, value: any): Promise<void> {\n try {\n await AsyncStorage.setItem(key, JSON.stringify(value));\n } catch (error) {\n Logger.logError('Error setting value to AsyncStorage:', error);\n }\n }\n\n static getSimpleDebugId(prefix?: string): string {\n return `${prefix ?? ''}${this.randomNumber(100000000, 99999999999)}`;\n }\n\n static randomNumber(min: number, max: number): number {\n return Math.ceil(Math.random() * (max - min) + min);\n }\n\n static unFlattenResourceParams<T extends BaseResourceParamType>(\n input: T[]\n ): MapLike<T> {\n if (!input || input.length === 0) {\n return {};\n }\n\n const transformMap: MapLike<T> = {};\n const op: MapLike<T> = {};\n // convert input into a map for quick search O(1)\n for (const item of input) {\n if (item.pId) {\n if (!transformMap[item.pId]) {\n item.children = [];\n transformMap[item.id] = item;\n } else {\n transformMap[item.pId].children.push(item);\n }\n } else {\n item.children = [];\n transformMap[item.id] = item;\n }\n }\n\n // sort children according to child_order inside children if they have any children\n for (const item of Object.values(transformMap)) {\n if (item.children && item.children.length > 0) {\n item.children = item.children.sort(Constants.sortAscending);\n op[item.nm] = item;\n } else {\n op[item.nm] = item;\n }\n }\n\n return op;\n }\n\n static unFlattenObject(obj: any): Record<string, any> {\n if (!obj) {\n return {};\n }\n return unflatten(obj, { object: false, delimiter: '.' });\n }\n\n static flattenObject(obj: any): Record<string, any> {\n if (!obj) {\n return {};\n }\n return flatten(obj, { maxDepth: 5, safe: true });\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAOA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,uBAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAC,sBAAA,CAAAP,OAAA;AAAqE,SAAAO,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE9D,MAAMG,KAAK,CAAC;EACjB,OAAOC,YAAYA,CAACC,SAAiB,EAAEC,OAAY,EA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D,GAAG,EAAE;MAAEE,MAAM,EAAE,KAAK;MAAEC,SAAS,EAAE;IAAI,CAAC,CAAC;EAC1D;EAEA,OAAOC,aAAaA,CAACJ,GAAQ,EAAuB;IAClD,IAAI,CAACA,GAAG,EAAE;MACR,OAAO,CAAC,CAAC;IACX;IACA,OAAO,IAAAK,aAAO,EAACL,GAAG,EAAE;MAAEM,QAAQ,EAAE,CAAC;MAAEC,IAAI,EAAE;IAAK,CAAC,CAAC;EAClD;AACF;AAACC,OAAA,CAAA7H,KAAA,GAAAA,KAAA","ignoreList":[]}
|
|
@@ -3,24 +3,24 @@
|
|
|
3
3
|
/* eslint-disable */
|
|
4
4
|
var jumpToCode = function init() {
|
|
5
5
|
// Classes of code we would like to highlight in the file view
|
|
6
|
-
var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no'];
|
|
6
|
+
var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no'];
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
// Elements to highlight in the file listing view
|
|
9
|
+
var fileListingElements = ['td.pct.low'];
|
|
9
10
|
|
|
11
|
+
// We don't want to select elements that are direct descendants of another match
|
|
10
12
|
var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > `
|
|
11
|
-
// Selecter that finds elements on the page to which we can jump
|
|
12
13
|
|
|
14
|
+
// Selecter that finds elements on the page to which we can jump
|
|
13
15
|
var selector = fileListingElements.join(', ') + ', ' + notSelector + missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b`
|
|
14
|
-
// The NodeList of matching elements
|
|
15
16
|
|
|
17
|
+
// The NodeList of matching elements
|
|
16
18
|
var missingCoverageElements = document.querySelectorAll(selector);
|
|
17
19
|
var currentIndex;
|
|
18
|
-
|
|
19
20
|
function toggleClass(index) {
|
|
20
21
|
missingCoverageElements.item(currentIndex).classList.remove('highlighted');
|
|
21
22
|
missingCoverageElements.item(index).classList.add('highlighted');
|
|
22
23
|
}
|
|
23
|
-
|
|
24
24
|
function makeCurrent(index) {
|
|
25
25
|
toggleClass(index);
|
|
26
26
|
currentIndex = index;
|
|
@@ -30,47 +30,35 @@ var jumpToCode = function init() {
|
|
|
30
30
|
inline: 'center'
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
-
|
|
34
33
|
function goToPrevious() {
|
|
35
34
|
var nextIndex = 0;
|
|
36
|
-
|
|
37
35
|
if (typeof currentIndex !== 'number' || currentIndex === 0) {
|
|
38
36
|
nextIndex = missingCoverageElements.length - 1;
|
|
39
37
|
} else if (missingCoverageElements.length > 1) {
|
|
40
38
|
nextIndex = currentIndex - 1;
|
|
41
39
|
}
|
|
42
|
-
|
|
43
40
|
makeCurrent(nextIndex);
|
|
44
41
|
}
|
|
45
|
-
|
|
46
42
|
function goToNext() {
|
|
47
43
|
var nextIndex = 0;
|
|
48
|
-
|
|
49
44
|
if (typeof currentIndex === 'number' && currentIndex < missingCoverageElements.length - 1) {
|
|
50
45
|
nextIndex = currentIndex + 1;
|
|
51
46
|
}
|
|
52
|
-
|
|
53
47
|
makeCurrent(nextIndex);
|
|
54
48
|
}
|
|
55
|
-
|
|
56
49
|
return function jump(event) {
|
|
57
50
|
if (document.getElementById('fileSearch') === document.activeElement && document.activeElement != null) {
|
|
58
51
|
// if we're currently focused on the search input, we don't want to navigate
|
|
59
52
|
return;
|
|
60
53
|
}
|
|
61
|
-
|
|
62
54
|
switch (event.which) {
|
|
63
55
|
case 78: // n
|
|
64
|
-
|
|
65
56
|
case 74:
|
|
66
57
|
// j
|
|
67
58
|
goToNext();
|
|
68
59
|
break;
|
|
69
|
-
|
|
70
60
|
case 66: // b
|
|
71
|
-
|
|
72
61
|
case 75: // k
|
|
73
|
-
|
|
74
62
|
case 80:
|
|
75
63
|
// p
|
|
76
64
|
goToPrevious();
|
|
@@ -78,6 +66,5 @@ var jumpToCode = function init() {
|
|
|
78
66
|
}
|
|
79
67
|
};
|
|
80
68
|
}();
|
|
81
|
-
|
|
82
69
|
window.addEventListener('keydown', jumpToCode);
|
|
83
70
|
//# sourceMappingURL=block-navigation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["jumpToCode","init","missingCoverageClasses","fileListingElements","notSelector","join","selector","missingCoverageElements","document","querySelectorAll","currentIndex","toggleClass","index","item","classList","remove","add","makeCurrent","scrollIntoView","behavior","block","inline","goToPrevious","nextIndex","length","goToNext","jump","event","getElementById","activeElement","which","window","addEventListener"],"sources":["block-navigation.js"],"sourcesContent":["/* eslint-disable */\nvar jumpToCode = (function init() {\n // Classes of code we would like to highlight in the file view\n var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no'];\n\n // Elements to highlight in the file listing view\n var fileListingElements = ['td.pct.low'];\n\n // We don't want to select elements that are direct descendants of another match\n var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > `\n\n // Selecter that finds elements on the page to which we can jump\n var selector =\n fileListingElements.join(', ') +\n ', ' +\n notSelector +\n missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b`\n\n // The NodeList of matching elements\n var missingCoverageElements = document.querySelectorAll(selector);\n\n var currentIndex;\n\n function toggleClass(index) {\n missingCoverageElements\n .item(currentIndex)\n .classList.remove('highlighted');\n missingCoverageElements.item(index).classList.add('highlighted');\n }\n\n function makeCurrent(index) {\n toggleClass(index);\n currentIndex = index;\n missingCoverageElements.item(index).scrollIntoView({\n behavior: 'smooth',\n block: 'center',\n inline: 'center'\n });\n }\n\n function goToPrevious() {\n var nextIndex = 0;\n if (typeof currentIndex !== 'number' || currentIndex === 0) {\n nextIndex = missingCoverageElements.length - 1;\n } else if (missingCoverageElements.length > 1) {\n nextIndex = currentIndex - 1;\n }\n\n makeCurrent(nextIndex);\n }\n\n function goToNext() {\n var nextIndex = 0;\n\n if (\n typeof currentIndex === 'number' &&\n currentIndex < missingCoverageElements.length - 1\n ) {\n nextIndex = currentIndex + 1;\n }\n\n makeCurrent(nextIndex);\n }\n\n return function jump(event) {\n if (\n document.getElementById('fileSearch') === document.activeElement &&\n document.activeElement != null\n ) {\n // if we're currently focused on the search input, we don't want to navigate\n return;\n }\n\n switch (event.which) {\n case 78: // n\n case 74: // j\n goToNext();\n break;\n case 66: // b\n case 75: // k\n case 80: // p\n goToPrevious();\n break;\n }\n };\n})();\nwindow.addEventListener('keydown', jumpToCode);\n"],"mappings":";;AAAA;AACA,IAAIA,UAAU,GAAI,SAASC,
|
|
1
|
+
{"version":3,"names":["jumpToCode","init","missingCoverageClasses","fileListingElements","notSelector","join","selector","missingCoverageElements","document","querySelectorAll","currentIndex","toggleClass","index","item","classList","remove","add","makeCurrent","scrollIntoView","behavior","block","inline","goToPrevious","nextIndex","length","goToNext","jump","event","getElementById","activeElement","which","window","addEventListener"],"sources":["block-navigation.js"],"sourcesContent":["/* eslint-disable */\nvar jumpToCode = (function init() {\n // Classes of code we would like to highlight in the file view\n var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no'];\n\n // Elements to highlight in the file listing view\n var fileListingElements = ['td.pct.low'];\n\n // We don't want to select elements that are direct descendants of another match\n var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > `\n\n // Selecter that finds elements on the page to which we can jump\n var selector =\n fileListingElements.join(', ') +\n ', ' +\n notSelector +\n missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b`\n\n // The NodeList of matching elements\n var missingCoverageElements = document.querySelectorAll(selector);\n\n var currentIndex;\n\n function toggleClass(index) {\n missingCoverageElements\n .item(currentIndex)\n .classList.remove('highlighted');\n missingCoverageElements.item(index).classList.add('highlighted');\n }\n\n function makeCurrent(index) {\n toggleClass(index);\n currentIndex = index;\n missingCoverageElements.item(index).scrollIntoView({\n behavior: 'smooth',\n block: 'center',\n inline: 'center'\n });\n }\n\n function goToPrevious() {\n var nextIndex = 0;\n if (typeof currentIndex !== 'number' || currentIndex === 0) {\n nextIndex = missingCoverageElements.length - 1;\n } else if (missingCoverageElements.length > 1) {\n nextIndex = currentIndex - 1;\n }\n\n makeCurrent(nextIndex);\n }\n\n function goToNext() {\n var nextIndex = 0;\n\n if (\n typeof currentIndex === 'number' &&\n currentIndex < missingCoverageElements.length - 1\n ) {\n nextIndex = currentIndex + 1;\n }\n\n makeCurrent(nextIndex);\n }\n\n return function jump(event) {\n if (\n document.getElementById('fileSearch') === document.activeElement &&\n document.activeElement != null\n ) {\n // if we're currently focused on the search input, we don't want to navigate\n return;\n }\n\n switch (event.which) {\n case 78: // n\n case 74: // j\n goToNext();\n break;\n case 66: // b\n case 75: // k\n case 80: // p\n goToPrevious();\n break;\n }\n };\n})();\nwindow.addEventListener('keydown', jumpToCode);\n"],"mappings":";;AAAA;AACA,IAAIA,UAAU,GAAI,SAASC,IAAIA,CAAA,EAAG;EAC9B;EACA,IAAIC,sBAAsB,GAAG,CAAC,aAAa,EAAE,WAAW,EAAE,WAAW,CAAC;;EAEtE;EACA,IAAIC,mBAAmB,GAAG,CAAC,YAAY,CAAC;;EAExC;EACA,IAAIC,WAAW,GAAG,OAAO,GAAGF,sBAAsB,CAACG,IAAI,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,CAAC;;EAE5E;EACA,IAAIC,QAAQ,GACRH,mBAAmB,CAACE,IAAI,CAAC,IAAI,CAAC,GAC9B,IAAI,GACJD,WAAW,GACXF,sBAAsB,CAACG,IAAI,CAAC,IAAI,GAAGD,WAAW,CAAC,CAAC,CAAC;;EAErD;EACA,IAAIG,uBAAuB,GAAGC,QAAQ,CAACC,gBAAgB,CAACH,QAAQ,CAAC;EAEjE,IAAII,YAAY;EAEhB,SAASC,WAAWA,CAACC,KAAK,EAAE;IACxBL,uBAAuB,CAClBM,IAAI,CAACH,YAAY,CAAC,CAClBI,SAAS,CAACC,MAAM,CAAC,aAAa,CAAC;IACpCR,uBAAuB,CAACM,IAAI,CAACD,KAAK,CAAC,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