@v-tilt/browser 1.0.6 → 1.0.7

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.
@@ -0,0 +1,423 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.detectDeviceType = exports.detectDevice = exports.detectOS = exports.detectBrowserVersion = exports.detectBrowser = void 0;
4
+ /**
5
+ * this device detection code is (at time of writing) about 3% of the size of the entire library
6
+ * this is mostly because the identifiers user in regexes and results can't be minified away since
7
+ * they have meaning
8
+ *
9
+ * so, there are some pre-uglifying choices in the code to help reduce the size
10
+ * e.g. many repeated strings are stored as variables and then old-fashioned concatenated together
11
+ *
12
+ * TL;DR here be dragons
13
+ */
14
+ const FACEBOOK = "Facebook";
15
+ const MOBILE = "Mobile";
16
+ const IOS = "iOS";
17
+ const ANDROID = "Android";
18
+ const TABLET = "Tablet";
19
+ const ANDROID_TABLET = ANDROID + " " + TABLET;
20
+ const IPAD = "iPad";
21
+ const APPLE = "Apple";
22
+ const APPLE_WATCH = APPLE + " Watch";
23
+ const SAFARI = "Safari";
24
+ const BLACKBERRY = "BlackBerry";
25
+ const SAMSUNG = "Samsung";
26
+ const SAMSUNG_BROWSER = SAMSUNG + "Browser";
27
+ const SAMSUNG_INTERNET = SAMSUNG + " Internet";
28
+ const CHROME = "Chrome";
29
+ const CHROME_OS = CHROME + " OS";
30
+ const CHROME_IOS = CHROME + " " + IOS;
31
+ const INTERNET_EXPLORER = "Internet Explorer";
32
+ const INTERNET_EXPLORER_MOBILE = INTERNET_EXPLORER + " " + MOBILE;
33
+ const OPERA = "Opera";
34
+ const OPERA_MINI = OPERA + " Mini";
35
+ const EDGE = "Edge";
36
+ const MICROSOFT_EDGE = "Microsoft " + EDGE;
37
+ const FIREFOX = "Firefox";
38
+ const FIREFOX_IOS = FIREFOX + " " + IOS;
39
+ const NINTENDO = "Nintendo";
40
+ const PLAYSTATION = "PlayStation";
41
+ const XBOX = "Xbox";
42
+ const ANDROID_MOBILE = ANDROID + " " + MOBILE;
43
+ const MOBILE_SAFARI = MOBILE + " " + SAFARI;
44
+ const WINDOWS = "Windows";
45
+ const WINDOWS_PHONE = WINDOWS + " Phone";
46
+ const NOKIA = "Nokia";
47
+ const OUYA = "Ouya";
48
+ const GENERIC = "Generic";
49
+ const GENERIC_MOBILE = GENERIC + " " + MOBILE.toLowerCase();
50
+ const GENERIC_TABLET = GENERIC + " " + TABLET.toLowerCase();
51
+ const KONQUEROR = "Konqueror";
52
+ const BROWSER_VERSION_REGEX_SUFFIX = "(\\d+(\\.\\d+)?)";
53
+ const DEFAULT_BROWSER_VERSION_REGEX = new RegExp("Version/" + BROWSER_VERSION_REGEX_SUFFIX);
54
+ const XBOX_REGEX = new RegExp(XBOX, "i");
55
+ const PLAYSTATION_REGEX = new RegExp(PLAYSTATION + " \\w+", "i");
56
+ const NINTENDO_REGEX = new RegExp(NINTENDO + " \\w+", "i");
57
+ const BLACKBERRY_REGEX = new RegExp(BLACKBERRY + "|PlayBook|BB10", "i");
58
+ const windowsVersionMap = {
59
+ "NT3.51": "NT 3.11",
60
+ "NT4.0": "NT 4.0",
61
+ "5.0": "2000",
62
+ "5.1": "XP",
63
+ "5.2": "XP",
64
+ "6.0": "Vista",
65
+ "6.1": "7",
66
+ "6.2": "8",
67
+ "6.3": "8.1",
68
+ "6.4": "10",
69
+ "10.0": "10",
70
+ };
71
+ /**
72
+ * Helper function to check if string includes substring (case-insensitive)
73
+ */
74
+ function includes(str, substr) {
75
+ return str.toLowerCase().includes(substr.toLowerCase());
76
+ }
77
+ /**
78
+ * Safari detection turns out to be complicated. For e.g. https://stackoverflow.com/a/29696509
79
+ * We can be slightly loose because some options have been ruled out (e.g. firefox on iOS)
80
+ * before this check is made
81
+ */
82
+ function isSafari(userAgent) {
83
+ return (includes(userAgent, SAFARI) &&
84
+ !includes(userAgent, CHROME) &&
85
+ !includes(userAgent, ANDROID));
86
+ }
87
+ const safariCheck = (ua, vendor) => (vendor && includes(vendor, APPLE)) || isSafari(ua);
88
+ /**
89
+ * This function detects which browser is running this script.
90
+ * The order of the checks are important since many user agents
91
+ * include keywords used in later checks.
92
+ */
93
+ const detectBrowser = function (user_agent, vendor) {
94
+ vendor = vendor || ""; // vendor is undefined for at least IE9
95
+ if (includes(user_agent, " OPR/") && includes(user_agent, "Mini")) {
96
+ return OPERA_MINI;
97
+ }
98
+ else if (includes(user_agent, " OPR/")) {
99
+ return OPERA;
100
+ }
101
+ else if (BLACKBERRY_REGEX.test(user_agent)) {
102
+ return BLACKBERRY;
103
+ }
104
+ else if (includes(user_agent, "IE" + MOBILE) ||
105
+ includes(user_agent, "WPDesktop")) {
106
+ return INTERNET_EXPLORER_MOBILE;
107
+ }
108
+ else if (includes(user_agent, SAMSUNG_BROWSER)) {
109
+ return SAMSUNG_INTERNET;
110
+ }
111
+ else if (includes(user_agent, EDGE) || includes(user_agent, "Edg/")) {
112
+ return MICROSOFT_EDGE;
113
+ }
114
+ else if (includes(user_agent, "FBIOS")) {
115
+ return FACEBOOK + " " + MOBILE;
116
+ }
117
+ else if (includes(user_agent, "UCWEB") ||
118
+ includes(user_agent, "UCBrowser")) {
119
+ return "UC Browser";
120
+ }
121
+ else if (includes(user_agent, "CriOS")) {
122
+ return CHROME_IOS;
123
+ }
124
+ else if (includes(user_agent, "CrMo")) {
125
+ return CHROME;
126
+ }
127
+ else if (includes(user_agent, CHROME)) {
128
+ return CHROME;
129
+ }
130
+ else if (includes(user_agent, ANDROID) && includes(user_agent, SAFARI)) {
131
+ return ANDROID_MOBILE;
132
+ }
133
+ else if (includes(user_agent, "FxiOS")) {
134
+ return FIREFOX_IOS;
135
+ }
136
+ else if (includes(user_agent.toLowerCase(), KONQUEROR.toLowerCase())) {
137
+ return KONQUEROR;
138
+ }
139
+ else if (safariCheck(user_agent, vendor)) {
140
+ return includes(user_agent, MOBILE) ? MOBILE_SAFARI : SAFARI;
141
+ }
142
+ else if (includes(user_agent, FIREFOX)) {
143
+ return FIREFOX;
144
+ }
145
+ else if (includes(user_agent, "MSIE") || includes(user_agent, "Trident/")) {
146
+ return INTERNET_EXPLORER;
147
+ }
148
+ else if (includes(user_agent, "Gecko")) {
149
+ return FIREFOX;
150
+ }
151
+ return "";
152
+ };
153
+ exports.detectBrowser = detectBrowser;
154
+ const versionRegexes = {
155
+ [INTERNET_EXPLORER_MOBILE]: [
156
+ new RegExp("rv:" + BROWSER_VERSION_REGEX_SUFFIX),
157
+ ],
158
+ [MICROSOFT_EDGE]: [new RegExp(EDGE + "?\\/" + BROWSER_VERSION_REGEX_SUFFIX)],
159
+ [CHROME]: [
160
+ new RegExp("(" + CHROME + "|CrMo)\\/" + BROWSER_VERSION_REGEX_SUFFIX),
161
+ ],
162
+ [CHROME_IOS]: [new RegExp("CriOS\\/" + BROWSER_VERSION_REGEX_SUFFIX)],
163
+ "UC Browser": [
164
+ new RegExp("(UCBrowser|UCWEB)\\/" + BROWSER_VERSION_REGEX_SUFFIX),
165
+ ],
166
+ [SAFARI]: [DEFAULT_BROWSER_VERSION_REGEX],
167
+ [MOBILE_SAFARI]: [DEFAULT_BROWSER_VERSION_REGEX],
168
+ [OPERA]: [
169
+ new RegExp("(" + OPERA + "|OPR)\\/" + BROWSER_VERSION_REGEX_SUFFIX),
170
+ ],
171
+ [FIREFOX]: [new RegExp(FIREFOX + "\\/" + BROWSER_VERSION_REGEX_SUFFIX)],
172
+ [FIREFOX_IOS]: [new RegExp("FxiOS\\/" + BROWSER_VERSION_REGEX_SUFFIX)],
173
+ [KONQUEROR]: [
174
+ new RegExp("Konqueror[:/]?" + BROWSER_VERSION_REGEX_SUFFIX, "i"),
175
+ ],
176
+ // not every blackberry user agent has the version after the name
177
+ [BLACKBERRY]: [
178
+ new RegExp(BLACKBERRY + " " + BROWSER_VERSION_REGEX_SUFFIX),
179
+ DEFAULT_BROWSER_VERSION_REGEX,
180
+ ],
181
+ [ANDROID_MOBILE]: [
182
+ new RegExp("android\\s" + BROWSER_VERSION_REGEX_SUFFIX, "i"),
183
+ ],
184
+ [SAMSUNG_INTERNET]: [
185
+ new RegExp(SAMSUNG_BROWSER + "\\/" + BROWSER_VERSION_REGEX_SUFFIX),
186
+ ],
187
+ [INTERNET_EXPLORER]: [
188
+ new RegExp("(rv:|MSIE )" + BROWSER_VERSION_REGEX_SUFFIX),
189
+ ],
190
+ Mozilla: [new RegExp("rv:" + BROWSER_VERSION_REGEX_SUFFIX)],
191
+ };
192
+ /**
193
+ * This function detects which browser version is running this script,
194
+ * parsing major and minor version (e.g., 42.1). User agent strings from:
195
+ * http://www.useragentstring.com/pages/useragentstring.php
196
+ *
197
+ * `navigator.vendor` is passed in and used to help with detecting certain browsers
198
+ * NB `navigator.vendor` is deprecated and not present in every browser
199
+ */
200
+ const detectBrowserVersion = function (userAgent, vendor) {
201
+ const browser = (0, exports.detectBrowser)(userAgent, vendor);
202
+ const regexes = versionRegexes[browser];
203
+ if (regexes === undefined) {
204
+ return null;
205
+ }
206
+ for (let i = 0; i < regexes.length; i++) {
207
+ const regex = regexes[i];
208
+ const matches = userAgent.match(regex);
209
+ if (matches) {
210
+ return parseFloat(matches[matches.length - 2]);
211
+ }
212
+ }
213
+ return null;
214
+ };
215
+ exports.detectBrowserVersion = detectBrowserVersion;
216
+ /**
217
+ * Helper to check if value is a function (type guard)
218
+ */
219
+ function isFunction(value) {
220
+ return typeof value === "function";
221
+ }
222
+ // to avoid repeating regexes or calling them twice, we have an array of matches
223
+ // the first regex that matches uses its matcher function to return the result
224
+ const osMatchers = [
225
+ [
226
+ new RegExp(XBOX + "; " + XBOX + " (.*?)[);]", "i"),
227
+ (match) => {
228
+ return [XBOX, (match && match[1]) || ""];
229
+ },
230
+ ],
231
+ [new RegExp(NINTENDO, "i"), [NINTENDO, ""]],
232
+ [new RegExp(PLAYSTATION, "i"), [PLAYSTATION, ""]],
233
+ [BLACKBERRY_REGEX, [BLACKBERRY, ""]],
234
+ [
235
+ new RegExp(WINDOWS, "i"),
236
+ (_, user_agent) => {
237
+ if (/Phone/.test(user_agent) || /WPDesktop/.test(user_agent)) {
238
+ return [WINDOWS_PHONE, ""];
239
+ }
240
+ // not all JS versions support negative lookbehind, so we need two checks here
241
+ if (new RegExp(MOBILE).test(user_agent) &&
242
+ !/IEMobile\b/.test(user_agent)) {
243
+ return [WINDOWS + " " + MOBILE, ""];
244
+ }
245
+ const match = /Windows NT ([0-9.]+)/i.exec(user_agent);
246
+ if (match && match[1]) {
247
+ const version = match[1];
248
+ let osVersion = windowsVersionMap[version] || "";
249
+ if (/arm/i.test(user_agent)) {
250
+ osVersion = "RT";
251
+ }
252
+ return [WINDOWS, osVersion];
253
+ }
254
+ return [WINDOWS, ""];
255
+ },
256
+ ],
257
+ [
258
+ /((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,
259
+ (match) => {
260
+ if (match && match[3]) {
261
+ const versionParts = [match[3], match[4], match[5] || "0"];
262
+ return [IOS, versionParts.join(".")];
263
+ }
264
+ return [IOS, ""];
265
+ },
266
+ ],
267
+ [
268
+ /(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,
269
+ (match) => {
270
+ // e.g. Watch4,3/5.3.8 (16U680)
271
+ let version = "";
272
+ if (match && match.length >= 3) {
273
+ version = match[2] === undefined ? match[3] : match[2];
274
+ }
275
+ return ["watchOS", version];
276
+ },
277
+ ],
278
+ [
279
+ new RegExp("(" + ANDROID + " (\\d+)\\.(\\d+)\\.?(\\d+)?|" + ANDROID + ")", "i"),
280
+ (match) => {
281
+ if (match && match[2]) {
282
+ const versionParts = [match[2], match[3], match[4] || "0"];
283
+ return [ANDROID, versionParts.join(".")];
284
+ }
285
+ return [ANDROID, ""];
286
+ },
287
+ ],
288
+ [
289
+ /Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,
290
+ (match) => {
291
+ const result = ["Mac OS X", ""];
292
+ if (match && match[1]) {
293
+ const versionParts = [match[1], match[2], match[3] || "0"];
294
+ result[1] = versionParts.join(".");
295
+ }
296
+ return result;
297
+ },
298
+ ],
299
+ [
300
+ /Mac/i,
301
+ // mop up a few non-standard UAs that should match mac
302
+ ["Mac OS X", ""],
303
+ ],
304
+ [/CrOS/, [CHROME_OS, ""]],
305
+ [/Linux|debian/i, ["Linux", ""]],
306
+ ];
307
+ const detectOS = function (user_agent) {
308
+ for (let i = 0; i < osMatchers.length; i++) {
309
+ const [rgex, resultOrFn] = osMatchers[i];
310
+ const match = rgex.exec(user_agent);
311
+ if (match) {
312
+ let result;
313
+ if (isFunction(resultOrFn)) {
314
+ result = resultOrFn(match, user_agent);
315
+ }
316
+ else {
317
+ result = resultOrFn;
318
+ }
319
+ if (result) {
320
+ return result;
321
+ }
322
+ }
323
+ }
324
+ return ["", ""];
325
+ };
326
+ exports.detectOS = detectOS;
327
+ const detectDevice = function (user_agent) {
328
+ if (NINTENDO_REGEX.test(user_agent)) {
329
+ return NINTENDO;
330
+ }
331
+ else if (PLAYSTATION_REGEX.test(user_agent)) {
332
+ return PLAYSTATION;
333
+ }
334
+ else if (XBOX_REGEX.test(user_agent)) {
335
+ return XBOX;
336
+ }
337
+ else if (new RegExp(OUYA, "i").test(user_agent)) {
338
+ return OUYA;
339
+ }
340
+ else if (new RegExp("(" + WINDOWS_PHONE + "|WPDesktop)", "i").test(user_agent)) {
341
+ return WINDOWS_PHONE;
342
+ }
343
+ else if (/iPad/.test(user_agent)) {
344
+ return IPAD;
345
+ }
346
+ else if (/iPod/.test(user_agent)) {
347
+ return "iPod Touch";
348
+ }
349
+ else if (/iPhone/.test(user_agent)) {
350
+ return "iPhone";
351
+ }
352
+ else if (/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(user_agent)) {
353
+ return APPLE_WATCH;
354
+ }
355
+ else if (BLACKBERRY_REGEX.test(user_agent)) {
356
+ return BLACKBERRY;
357
+ }
358
+ else if (/(kobo)\s(ereader|touch)/i.test(user_agent)) {
359
+ return "Kobo";
360
+ }
361
+ else if (new RegExp(NOKIA, "i").test(user_agent)) {
362
+ return NOKIA;
363
+ }
364
+ else if (
365
+ // Kindle Fire without Silk / Echo Show
366
+ /(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(user_agent) ||
367
+ // Kindle Fire HD
368
+ /(kf[a-z]+)( bui|\)).+silk\//i.test(user_agent)) {
369
+ return "Kindle Fire";
370
+ }
371
+ else if (/(Android|ZTE)/i.test(user_agent)) {
372
+ if (!new RegExp(MOBILE).test(user_agent) ||
373
+ /(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(user_agent)) {
374
+ if ((/pixel[\daxl ]{1,6}/i.test(user_agent) &&
375
+ !/pixel c/i.test(user_agent)) ||
376
+ /(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(user_agent) ||
377
+ (/lmy47v/i.test(user_agent) && !/QTAQZ3/i.test(user_agent))) {
378
+ return ANDROID;
379
+ }
380
+ return ANDROID_TABLET;
381
+ }
382
+ else {
383
+ return ANDROID;
384
+ }
385
+ }
386
+ else if (new RegExp("(pda|" + MOBILE + ")", "i").test(user_agent)) {
387
+ return GENERIC_MOBILE;
388
+ }
389
+ else if (new RegExp(TABLET, "i").test(user_agent) &&
390
+ !new RegExp(TABLET + " pc", "i").test(user_agent)) {
391
+ return GENERIC_TABLET;
392
+ }
393
+ else {
394
+ return "";
395
+ }
396
+ };
397
+ exports.detectDevice = detectDevice;
398
+ const detectDeviceType = function (user_agent) {
399
+ const device = (0, exports.detectDevice)(user_agent);
400
+ if (device === IPAD ||
401
+ device === ANDROID_TABLET ||
402
+ device === "Kobo" ||
403
+ device === "Kindle Fire" ||
404
+ device === GENERIC_TABLET) {
405
+ return TABLET;
406
+ }
407
+ else if (device === NINTENDO ||
408
+ device === XBOX ||
409
+ device === PLAYSTATION ||
410
+ device === OUYA) {
411
+ return "Console";
412
+ }
413
+ else if (device === APPLE_WATCH) {
414
+ return "Wearable";
415
+ }
416
+ else if (device) {
417
+ return MOBILE;
418
+ }
419
+ else {
420
+ return "Desktop";
421
+ }
422
+ };
423
+ exports.detectDeviceType = detectDeviceType;
package/lib/vtilt.d.ts CHANGED
@@ -1,18 +1,59 @@
1
1
  import { VTiltConfig, EventPayload } from "./types";
2
+ import { TrackingManager } from "./tracking";
3
+ import { HistoryAutocapture } from "./extensions/history-autocapture";
2
4
  export declare class VTilt {
3
5
  private configManager;
4
- private trackingManager;
6
+ trackingManager: TrackingManager;
5
7
  private webVitalsManager;
6
- private initialized;
7
- private _lastPathname;
8
+ historyAutocapture?: HistoryAutocapture;
9
+ __loaded: boolean;
8
10
  private _initialPageviewCaptured;
9
11
  private _visibilityStateListener;
10
- private _popstateListener;
11
12
  constructor(config?: Partial<VTiltConfig>);
12
13
  /**
13
- * Initialize VTilt tracking
14
+ * Initializes a new instance of the VTilt tracking object.
15
+ *
16
+ * @remarks
17
+ * All new instances are added to the main vt object as sub properties (such as
18
+ * `vt.library_name`) and also returned by this function.
19
+ *
20
+ * @example
21
+ * ```js
22
+ * // basic initialization
23
+ * vt.init('<project_id>', {
24
+ * api_host: '<client_api_host>'
25
+ * })
26
+ * ```
27
+ *
28
+ * @example
29
+ * ```js
30
+ * // multiple instances
31
+ * vt.init('<project_id>', {}, 'project1')
32
+ * vt.init('<project_id>', {}, 'project2')
33
+ * ```
34
+ *
35
+ * @public
36
+ *
37
+ * @param projectId - Your VTilt project ID
38
+ * @param config - A dictionary of config options to override
39
+ * @param name - The name for the new VTilt instance that you want created
40
+ *
41
+ * @returns The newly initialized VTilt instance
14
42
  */
15
- init(): void;
43
+ init(projectId: string, config?: Partial<VTiltConfig>, name?: string): VTilt;
44
+ /**
45
+ * Handles the actual initialization logic for a VTilt instance.
46
+ * This internal method should only be called by `init()`.
47
+ * Follows the PostHog convention of using a private `_init()` method for instance setup.
48
+ */
49
+ private _init;
50
+ /**
51
+ * Returns a string representation of the instance name (PostHog-style)
52
+ * Used for debugging and logging
53
+ *
54
+ * @internal
55
+ */
56
+ toString(): string;
16
57
  /**
17
58
  * Track a custom event
18
59
  */
@@ -103,25 +144,11 @@ export declare class VTilt {
103
144
  * vtilt.createAlias('user_12345', 'anonymous_abc123')
104
145
  */
105
146
  createAlias(alias: string, original?: string): void;
106
- /**
107
- * Setup page tracking with history API support
108
- * Based on PostHog's setupHistoryEventTracking implementation
109
- */
110
- private setupPageTracking;
111
147
  /**
112
148
  * Capture initial pageview with visibility check
113
149
  * Based on PostHog's _captureInitialPageview implementation
114
150
  */
115
151
  private _captureInitialPageview;
116
- /**
117
- * Capture pageview event for navigation changes
118
- * Based on PostHog's captureNavigationEvent implementation
119
- */
120
- private _capturePageview;
121
- /**
122
- * Setup popstate listener for browser back/forward navigation
123
- */
124
- private _setupPopstateListener;
125
152
  /**
126
153
  * Get current configuration
127
154
  */
@@ -135,11 +162,11 @@ export declare class VTilt {
135
162
  */
136
163
  updateConfig(config: Partial<VTiltConfig>): void;
137
164
  /**
138
- * _execute_array() deals with processing any VTilt function
139
- * calls that were called before the VTilt library was loaded
165
+ * _execute_array() deals with processing any vTilt function
166
+ * calls that were called before the vTilt library was loaded
140
167
  * (and are thus stored in an array so they can be called later)
141
168
  *
142
- * Note: we fire off all the VTilt function calls BEFORE we fire off
169
+ * Note: we fire off all the vTilt function calls BEFORE we fire off
143
170
  * tracking calls. This is so identify/setUserProperties/updateConfig calls
144
171
  * can properly modify early tracking calls.
145
172
  *
@@ -152,12 +179,12 @@ export declare class VTilt {
152
179
  _dom_loaded(): void;
153
180
  }
154
181
  /**
155
- * Initialize VTilt as a module (similar to PostHog's init_as_module)
156
- * Returns an uninitialized VTilt instance that the user must call init() on
182
+ * Initialize vTilt as a module (similar to PostHog's init_as_module)
183
+ * Returns an uninitialized vTilt instance that the user must call init() on
157
184
  */
158
185
  export declare function init_as_module(): VTilt;
159
186
  /**
160
- * Initialize VTilt from snippet (similar to PostHog's init_from_snippet)
187
+ * Initialize vTilt from snippet (similar to PostHog's init_from_snippet)
161
188
  * Processes queued calls from the snippet stub and replaces it with real instance
162
189
  *
163
190
  * The snippet uses some clever tricks to allow deferred loading of array.js (this code)