@microsoft/applicationinsights-properties-js 3.0.0-beta.2211-01 → 3.0.0-beta.2211-04

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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Application Insights JavaScript SDK - Properties Plugin, 3.0.0-beta.2211-01
2
+ * Application Insights JavaScript SDK - Properties Plugin, 3.0.0-beta.2211-04
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  (function (global, factory) {
@@ -927,16 +927,18 @@
927
927
  var _DYN_APPLY = "apply";
928
928
  var _DYN_PUSH = "push";
929
929
  var _DYN_SPLICE = "splice";
930
+ var _DYN_CANCEL = "cancel";
930
931
  var _DYN_INITIALIZE = "initialize";
931
932
  var _DYN_IDENTIFIER = "identifier";
932
933
  var _DYN_IS_INITIALIZED = "isInitialized";
934
+ var _DYN_GET_PLUGIN = "getPlugin";
933
935
  var _DYN_NAME$1 = "name";
934
936
  var _DYN_TIME = "time";
935
937
  var _DYN_PROCESS_NEXT = "processNext";
936
938
  var _DYN_GET_PROCESS_TEL_CONT0 = "getProcessTelContext";
937
939
  var _DYN_CALL = "call";
938
- var _DYN_GET_PLUGIN = "getPlugin";
939
940
  var _DYN_LOGGING_LEVEL_CONSOL4 = "loggingLevelConsole";
941
+ var _DYN_CREATE_NEW = "createNew";
940
942
  var _DYN_TEARDOWN = "teardown";
941
943
  var _DYN_MESSAGE_ID = "messageId";
942
944
  var _DYN_MESSAGE = "message";
@@ -946,8 +948,6 @@
946
948
  var _DYN_UPDATE$1 = "update";
947
949
  var _DYN_GET_NEXT = "getNext";
948
950
  var _DYN_SET_NEXT_PLUGIN = "setNextPlugin";
949
- var _DYN_CREATE_NEW = "createNew";
950
- var _DYN_CONFIG = "config";
951
951
  var _DYN_USER_AGENT = "userAgent";
952
952
  var _DYN_SPLIT = "split";
953
953
  var _DYN_NODE_TYPE = "nodeType";
@@ -1214,7 +1214,7 @@
1214
1214
  }
1215
1215
 
1216
1216
  var _objDefineProperty = ObjDefineProperty;
1217
- var version = "3.0.0-beta.2211-01";
1217
+ var version = "3.0.0-beta.2211-04";
1218
1218
  var instanceName = "." + newId(6);
1219
1219
  var _dataUid = 0;
1220
1220
  function _createAccessor(target, prop, value) {
@@ -1548,7 +1548,7 @@
1548
1548
  if (_waitingHandlers) {
1549
1549
  var notifyHandlers = _waitingHandlers;
1550
1550
  _waitingHandlers = null;
1551
- _watcherTimer && _watcherTimer.cancel();
1551
+ _watcherTimer && _watcherTimer[_DYN_CANCEL ]();
1552
1552
  _watcherTimer = null;
1553
1553
  var watcherFailures_1 = [];
1554
1554
  arrForEach(notifyHandlers, function (handler) {
@@ -1898,791 +1898,791 @@
1898
1898
  _getLogger(logger)[_DYN_LOG_INTERNAL_MESSAGE ](severity, message);
1899
1899
  }
1900
1900
 
1901
- var strExecutionContextKey = "ctx";
1902
- var strParentContextKey = "ParentContextKey";
1903
- var strChildrenContextKey = "ChildrenContextKey";
1904
- var PerfEvent = /** @class */ (function () {
1905
- function PerfEvent(name, payloadDetails, isAsync) {
1906
- var _self = this;
1907
- _self.start = utcNow();
1908
- _self[_DYN_NAME$1 ] = name;
1909
- _self[_DYN_IS_ASYNC ] = isAsync;
1910
- _self[_DYN_IS_CHILD_EVT ] = function () { return false; };
1911
- if (isFunction(payloadDetails)) {
1912
- var theDetails_1;
1913
- objDefineAccessors(_self, "payload", function () {
1914
- if (!theDetails_1 && isFunction(payloadDetails)) {
1915
- theDetails_1 = payloadDetails();
1916
- payloadDetails = null;
1917
- }
1918
- return theDetails_1;
1919
- });
1920
- }
1921
- _self[_DYN_GET_CTX ] = function (key) {
1922
- if (key) {
1923
- if (key === PerfEvent[strParentContextKey] || key === PerfEvent[strChildrenContextKey]) {
1924
- return _self[key];
1925
- }
1926
- return (_self[strExecutionContextKey] || {})[key];
1927
- }
1928
- return null;
1929
- };
1930
- _self[_DYN_SET_CTX ] = function (key, value) {
1931
- if (key) {
1932
- if (key === PerfEvent[strParentContextKey]) {
1933
- if (!_self[key]) {
1934
- _self[_DYN_IS_CHILD_EVT ] = function () { return true; };
1935
- }
1936
- _self[key] = value;
1937
- }
1938
- else if (key === PerfEvent[strChildrenContextKey]) {
1939
- _self[key] = value;
1940
- }
1941
- else {
1942
- var ctx = _self[strExecutionContextKey] = _self[strExecutionContextKey] || {};
1943
- ctx[key] = value;
1944
- }
1945
- }
1946
- };
1947
- _self[_DYN_COMPLETE ] = function () {
1948
- var childTime = 0;
1949
- var childEvts = _self[_DYN_GET_CTX ](PerfEvent[strChildrenContextKey]);
1950
- if (isArray(childEvts)) {
1951
- for (var lp = 0; lp < childEvts[_DYN_LENGTH$2 ]; lp++) {
1952
- var childEvt = childEvts[lp];
1953
- if (childEvt) {
1954
- childTime += childEvt[_DYN_TIME ];
1955
- }
1956
- }
1957
- }
1958
- _self[_DYN_TIME ] = utcNow() - _self.start;
1959
- _self.exTime = _self[_DYN_TIME ] - childTime;
1960
- _self[_DYN_COMPLETE ] = function () { };
1961
- };
1962
- }
1963
- PerfEvent.ParentContextKey = "parent";
1964
- PerfEvent.ChildrenContextKey = "childEvts";
1965
- return PerfEvent;
1966
- }());
1967
- var doPerfActiveKey = "CoreUtils.doPerf";
1968
- function doPerf(mgrSource, getSource, func, details, isAsync) {
1969
- if (mgrSource) {
1970
- var perfMgr = mgrSource;
1971
- if (perfMgr[STR_GET_PERF_MGR]) {
1972
- perfMgr = perfMgr[STR_GET_PERF_MGR]();
1973
- }
1974
- if (perfMgr) {
1975
- var perfEvt = void 0;
1976
- var currentActive = perfMgr[_DYN_GET_CTX ](doPerfActiveKey);
1977
- try {
1978
- perfEvt = perfMgr.create(getSource(), details, isAsync);
1979
- if (perfEvt) {
1980
- if (currentActive && perfEvt[_DYN_SET_CTX ]) {
1981
- perfEvt[_DYN_SET_CTX ](PerfEvent[strParentContextKey], currentActive);
1982
- if (currentActive[_DYN_GET_CTX ] && currentActive[_DYN_SET_CTX ]) {
1983
- var children = currentActive[_DYN_GET_CTX ](PerfEvent[strChildrenContextKey]);
1984
- if (!children) {
1985
- children = [];
1986
- currentActive[_DYN_SET_CTX ](PerfEvent[strChildrenContextKey], children);
1987
- }
1988
- children[_DYN_PUSH ](perfEvt);
1989
- }
1990
- }
1991
- perfMgr[_DYN_SET_CTX ](doPerfActiveKey, perfEvt);
1992
- return func(perfEvt);
1993
- }
1994
- }
1995
- catch (ex) {
1996
- if (perfEvt && perfEvt[_DYN_SET_CTX ]) {
1997
- perfEvt[_DYN_SET_CTX ]("exception", ex);
1998
- }
1999
- }
2000
- finally {
2001
- if (perfEvt) {
2002
- perfMgr.fire(perfEvt);
2003
- }
2004
- perfMgr[_DYN_SET_CTX ](doPerfActiveKey, currentActive);
2005
- }
2006
- }
1901
+ var _a$2, _b;
1902
+ var strToGMTString = "toGMTString";
1903
+ var strToUTCString = "toUTCString";
1904
+ var strCookie = "cookie";
1905
+ var strExpires = "expires";
1906
+ var strIsCookieUseDisabled = "isCookieUseDisabled";
1907
+ var strDisableCookiesUsage = "disableCookiesUsage";
1908
+ var strConfigCookieMgr = "_ckMgr";
1909
+ var _supportsCookies = null;
1910
+ var _allowUaSameSite = null;
1911
+ var _parsedCookieValue = null;
1912
+ var _doc = getDocument();
1913
+ var _cookieCache = {};
1914
+ var _globalCookieConfig = {};
1915
+ var defaultConfig = objDeepFreeze((_a$2 = {},
1916
+ _a$2[STR_DOMAIN] = { fb: "cookieDomain", dfVal: isNotNullOrUndefined },
1917
+ _a$2.path = { fb: "cookiePath", dfVal: isNotNullOrUndefined },
1918
+ _a$2.enabled = UNDEFINED_VALUE,
1919
+ _a$2));
1920
+ var rootDefaultConfig = (_b = {
1921
+ cookieCfg: {},
1922
+ cookieDomain: UNDEFINED_VALUE,
1923
+ cookiePath: UNDEFINED_VALUE
1924
+ },
1925
+ _b[strDisableCookiesUsage] = UNDEFINED_VALUE,
1926
+ _b);
1927
+ function _gblCookieMgr(config, logger) {
1928
+ var inst = createCookieMgr[strConfigCookieMgr] || _globalCookieConfig[strConfigCookieMgr];
1929
+ if (!inst) {
1930
+ inst = createCookieMgr[strConfigCookieMgr] = createCookieMgr(config, logger);
1931
+ _globalCookieConfig[strConfigCookieMgr] = inst;
2007
1932
  }
2008
- return func();
1933
+ return inst;
2009
1934
  }
2010
-
2011
- function generateW3CId() {
2012
- var hexValues = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
2013
- var oct = STR_EMPTY, tmp;
2014
- for (var a = 0; a < 4; a++) {
2015
- tmp = random32();
2016
- oct +=
2017
- hexValues[tmp & 0xF] +
2018
- hexValues[tmp >> 4 & 0xF] +
2019
- hexValues[tmp >> 8 & 0xF] +
2020
- hexValues[tmp >> 12 & 0xF] +
2021
- hexValues[tmp >> 16 & 0xF] +
2022
- hexValues[tmp >> 20 & 0xF] +
2023
- hexValues[tmp >> 24 & 0xF] +
2024
- hexValues[tmp >> 28 & 0xF];
1935
+ function _isMgrEnabled(cookieMgr) {
1936
+ if (cookieMgr) {
1937
+ return cookieMgr.isEnabled();
2025
1938
  }
2026
- var clockSequenceHi = hexValues[8 + (random32() & 0x03) | 0];
2027
- return strSubstr(oct, 0, 8) + strSubstr(oct, 9, 4) + "4" + strSubstr(oct, 13, 3) + clockSequenceHi + strSubstr(oct, 16, 3) + strSubstr(oct, 19, 12);
1939
+ return true;
2028
1940
  }
2029
-
2030
- var INVALID_TRACE_ID = "00000000000000000000000000000000";
2031
- var INVALID_SPAN_ID = "0000000000000000";
2032
- function _isValid(value, len, invalidValue) {
2033
- if (value && value[_DYN_LENGTH$2 ] === len && value !== invalidValue) {
2034
- return !!value.match(/^[\da-f]*$/i);
1941
+ function _isIgnoredCookie(cookieMgrCfg, name) {
1942
+ if (name && cookieMgrCfg && isArray(cookieMgrCfg.ignoreCookies)) {
1943
+ return arrIndexOf(cookieMgrCfg.ignoreCookies, name) !== -1;
2035
1944
  }
2036
1945
  return false;
2037
1946
  }
2038
- function isValidTraceId(value) {
2039
- return _isValid(value, 32, INVALID_TRACE_ID);
2040
- }
2041
- function isValidSpanId(value) {
2042
- return _isValid(value, 16, INVALID_SPAN_ID);
2043
- }
2044
-
2045
- var pluginStateData = createElmNodeData("plugin");
2046
- function _getPluginState(plugin) {
2047
- return pluginStateData.get(plugin, "state", {}, true);
2048
- }
2049
-
2050
- var strTelemetryPluginChain = "TelemetryPluginChain";
2051
- var strHasRunFlags = "_hasRun";
2052
- var strGetTelCtx = "_getTelCtx";
2053
- var _chainId = 0;
2054
- function _getNextProxyStart(proxy, core, startAt) {
2055
- while (proxy) {
2056
- if (proxy[_DYN_GET_PLUGIN ]() === startAt) {
2057
- return proxy;
1947
+ function _isBlockedCookie(cookieMgrCfg, name) {
1948
+ if (name && cookieMgrCfg && isArray(cookieMgrCfg.blockedCookies)) {
1949
+ if (arrIndexOf(cookieMgrCfg.blockedCookies, name) !== -1) {
1950
+ return true;
2058
1951
  }
2059
- proxy = proxy[_DYN_GET_NEXT ]();
2060
1952
  }
2061
- return createTelemetryProxyChain([startAt], core[_DYN_CONFIG ] || {}, core);
1953
+ return _isIgnoredCookie(cookieMgrCfg, name);
2062
1954
  }
2063
- function _createInternalContext(telemetryChain, dynamicHandler, core, startAt) {
2064
- var _nextProxy = null;
2065
- var _onComplete = [];
2066
- if (!dynamicHandler) {
2067
- dynamicHandler = createDynamicConfig({}, null, core[_DYN_LOGGER ]);
2068
- }
2069
- if (startAt !== null) {
2070
- _nextProxy = startAt ? _getNextProxyStart(telemetryChain, core, startAt) : telemetryChain;
1955
+ function safeGetCookieMgr(core, config) {
1956
+ var cookieMgr;
1957
+ if (core) {
1958
+ cookieMgr = core.getCookieMgr();
2071
1959
  }
2072
- var context = {
2073
- _next: _moveNext,
2074
- ctx: {
2075
- core: function () {
2076
- return core;
2077
- },
2078
- diagLog: function () {
2079
- return safeGetLogger(core, dynamicHandler.cfg);
2080
- },
2081
- getCfg: function () {
2082
- return dynamicHandler.cfg;
2083
- },
2084
- getExtCfg: _resolveExtCfg,
2085
- getConfig: _getConfig,
2086
- hasNext: function () {
2087
- return !!_nextProxy;
2088
- },
2089
- getNext: function () {
2090
- return _nextProxy;
2091
- },
2092
- setNext: function (nextPlugin) {
2093
- _nextProxy = nextPlugin;
2094
- },
2095
- iterate: _iterateChain,
2096
- onComplete: _addOnComplete
2097
- }
2098
- };
2099
- function _addOnComplete(onComplete, that) {
2100
- var args = [];
2101
- for (var _i = 2; _i < arguments.length; _i++) {
2102
- args[_i - 2] = arguments[_i];
1960
+ else if (config) {
1961
+ var cookieCfg = config.cookieCfg;
1962
+ if (cookieCfg && cookieCfg[strConfigCookieMgr]) {
1963
+ cookieMgr = cookieCfg[strConfigCookieMgr];
2103
1964
  }
2104
- if (onComplete) {
2105
- _onComplete[_DYN_PUSH ]({
2106
- func: onComplete,
2107
- self: !isUndefined(that) ? that : context.ctx,
2108
- args: args
2109
- });
1965
+ else {
1966
+ cookieMgr = createCookieMgr(config);
2110
1967
  }
2111
1968
  }
2112
- function _moveNext() {
2113
- var nextProxy = _nextProxy;
2114
- _nextProxy = nextProxy ? nextProxy[_DYN_GET_NEXT ]() : null;
2115
- if (!nextProxy) {
2116
- var onComplete = _onComplete;
2117
- if (onComplete && onComplete[_DYN_LENGTH$2 ] > 0) {
2118
- arrForEach(onComplete, function (completeDetails) {
2119
- try {
2120
- completeDetails.func[_DYN_CALL ](completeDetails.self, completeDetails.args);
2121
- }
2122
- catch (e) {
2123
- _throwInternal(core[_DYN_LOGGER ], 2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
2124
- }
2125
- });
2126
- _onComplete = [];
2127
- }
2128
- }
2129
- return nextProxy;
1969
+ if (!cookieMgr) {
1970
+ cookieMgr = _gblCookieMgr(config, (core || {})[_DYN_LOGGER ]);
2130
1971
  }
2131
- function _getExtCfg(identifier, createIfMissing) {
2132
- var idCfg = null;
2133
- var cfg = dynamicHandler.cfg;
2134
- if (cfg && identifier) {
2135
- var extCfg = cfg[STR_EXTENSION_CONFIG ];
2136
- if (!extCfg && createIfMissing) {
2137
- extCfg = {};
1972
+ return cookieMgr;
1973
+ }
1974
+ function createCookieMgr(rootConfig, logger) {
1975
+ var cookieMgrConfig;
1976
+ var _path;
1977
+ var _domain;
1978
+ var _enabled;
1979
+ var _getCookieFn;
1980
+ var _setCookieFn;
1981
+ var _delCookieFn;
1982
+ rootConfig = createDynamicConfig(rootConfig || _globalCookieConfig, null, logger).cfg;
1983
+ onConfigChange(rootConfig, function (details) {
1984
+ details[_DYN_SET_DF ](details.cfg, rootDefaultConfig);
1985
+ cookieMgrConfig = details[_DYN_SET_DF ](details.cfg.cookieCfg, defaultConfig);
1986
+ var isEnabled = cookieMgrConfig.enabled;
1987
+ if (isNullOrUndefined(isEnabled)) {
1988
+ var cookieEnabled = void 0;
1989
+ if (!isUndefined(rootConfig[strIsCookieUseDisabled])) {
1990
+ cookieEnabled = !rootConfig[strIsCookieUseDisabled];
2138
1991
  }
2139
- dynamicHandler.set(cfg, STR_EXTENSION_CONFIG, extCfg);
2140
- extCfg = cfg[STR_EXTENSION_CONFIG ];
2141
- if (extCfg) {
2142
- idCfg = extCfg[identifier];
2143
- if (!idCfg && createIfMissing) {
2144
- idCfg = {};
2145
- }
2146
- dynamicHandler.set(extCfg, identifier, idCfg);
2147
- idCfg = extCfg[identifier];
1992
+ if (!isUndefined(rootConfig[strDisableCookiesUsage])) {
1993
+ cookieEnabled = !rootConfig[strDisableCookiesUsage];
2148
1994
  }
1995
+ isEnabled = cookieEnabled;
2149
1996
  }
2150
- return idCfg;
2151
- }
2152
- function _resolveExtCfg(identifier, defaultValues) {
2153
- var newConfig = _getExtCfg(identifier, true);
2154
- if (defaultValues) {
2155
- objForEachKey(defaultValues, function (field, defaultValue) {
2156
- if (isNullOrUndefined(newConfig[field])) {
2157
- var cfgValue = dynamicHandler.cfg[field];
2158
- if (cfgValue || !isNullOrUndefined(cfgValue)) {
2159
- newConfig[field] = cfgValue;
1997
+ _path = cookieMgrConfig[STR_PATH ] || "/";
1998
+ _domain = cookieMgrConfig[STR_DOMAIN ];
1999
+ _enabled = isEnabled !== false;
2000
+ _getCookieFn = cookieMgrConfig.getCookie || _getCookieValue;
2001
+ _setCookieFn = cookieMgrConfig.setCookie || _setCookieValue;
2002
+ _delCookieFn = cookieMgrConfig.delCookie || _setCookieValue;
2003
+ }, logger);
2004
+ var cookieMgr = {
2005
+ isEnabled: function () {
2006
+ var enabled = _enabled && areCookiesSupported(logger);
2007
+ var gblManager = _globalCookieConfig[strConfigCookieMgr];
2008
+ if (enabled && gblManager && cookieMgr !== gblManager) {
2009
+ enabled = _isMgrEnabled(gblManager);
2010
+ }
2011
+ return enabled;
2012
+ },
2013
+ setEnabled: function (value) {
2014
+ _enabled = value !== false;
2015
+ },
2016
+ set: function (name, value, maxAgeSec, domain, path) {
2017
+ var result = false;
2018
+ if (_isMgrEnabled(cookieMgr) && !_isBlockedCookie(cookieMgrConfig, name)) {
2019
+ var values = {};
2020
+ var theValue = strTrim(value || STR_EMPTY);
2021
+ var idx = strIndexOf(theValue, ";");
2022
+ if (idx !== -1) {
2023
+ theValue = strTrim(strLeft(value, idx));
2024
+ values = _extractParts(strSubstring(value, idx + 1));
2025
+ }
2026
+ setValue(values, STR_DOMAIN, domain || _domain, isTruthy, isUndefined);
2027
+ if (!isNullOrUndefined(maxAgeSec)) {
2028
+ var _isIE = isIE();
2029
+ if (isUndefined(values[strExpires])) {
2030
+ var nowMs = utcNow();
2031
+ var expireMs = nowMs + (maxAgeSec * 1000);
2032
+ if (expireMs > 0) {
2033
+ var expiry = new Date();
2034
+ expiry.setTime(expireMs);
2035
+ setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || STR_EMPTY, isTruthy);
2036
+ }
2037
+ }
2038
+ if (!_isIE) {
2039
+ setValue(values, "max-age", STR_EMPTY + maxAgeSec, null, isUndefined);
2160
2040
  }
2161
2041
  }
2162
- _applyDefaultValue(dynamicHandler, newConfig, field, defaultValue);
2163
- });
2042
+ var location_1 = getLocation();
2043
+ if (location_1 && location_1.protocol === "https:") {
2044
+ setValue(values, "secure", null, null, isUndefined);
2045
+ if (_allowUaSameSite === null) {
2046
+ _allowUaSameSite = !uaDisallowsSameSiteNone((getNavigator() || {})[_DYN_USER_AGENT ]);
2047
+ }
2048
+ if (_allowUaSameSite) {
2049
+ setValue(values, "SameSite", "None", null, isUndefined);
2050
+ }
2051
+ }
2052
+ setValue(values, STR_PATH, path || _path, null, isUndefined);
2053
+ _setCookieFn(name, _formatCookieValue(theValue, values));
2054
+ result = true;
2055
+ }
2056
+ return result;
2057
+ },
2058
+ get: function (name) {
2059
+ var value = STR_EMPTY;
2060
+ if (_isMgrEnabled(cookieMgr) && !_isIgnoredCookie(cookieMgrConfig, name)) {
2061
+ value = _getCookieFn(name);
2062
+ }
2063
+ return value;
2064
+ },
2065
+ del: function (name, path) {
2066
+ var result = false;
2067
+ if (_isMgrEnabled(cookieMgr)) {
2068
+ result = cookieMgr.purge(name, path);
2069
+ }
2070
+ return result;
2071
+ },
2072
+ purge: function (name, path) {
2073
+ var _a;
2074
+ var result = false;
2075
+ if (areCookiesSupported(logger)) {
2076
+ var values = (_a = {},
2077
+ _a[STR_PATH] = path ? path : "/",
2078
+ _a[strExpires] = "Thu, 01 Jan 1970 00:00:01 GMT",
2079
+ _a);
2080
+ if (!isIE()) {
2081
+ values["max-age"] = "0";
2082
+ }
2083
+ _delCookieFn(name, _formatCookieValue(STR_EMPTY, values));
2084
+ result = true;
2085
+ }
2086
+ return result;
2164
2087
  }
2165
- return dynamicHandler[_DYN_SET_DF ](newConfig, defaultValues);
2166
- }
2167
- function _getConfig(identifier, field, defaultValue) {
2168
- if (defaultValue === void 0) { defaultValue = false; }
2169
- var theValue;
2170
- var extConfig = _getExtCfg(identifier, false);
2171
- var rootConfig = dynamicHandler.cfg;
2172
- if (extConfig && (extConfig[field] || !isNullOrUndefined(extConfig[field]))) {
2173
- theValue = extConfig[field];
2088
+ };
2089
+ cookieMgr[strConfigCookieMgr] = cookieMgr;
2090
+ return cookieMgr;
2091
+ }
2092
+ function areCookiesSupported(logger) {
2093
+ if (_supportsCookies === null) {
2094
+ _supportsCookies = false;
2095
+ try {
2096
+ var doc = _doc || {};
2097
+ _supportsCookies = doc[strCookie] !== undefined;
2174
2098
  }
2175
- else if (rootConfig[field] || !isNullOrUndefined(rootConfig[field])) {
2176
- theValue = rootConfig[field];
2099
+ catch (e) {
2100
+ _throwInternal(logger, 2 , 68 , "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
2177
2101
  }
2178
- return (theValue || !isNullOrUndefined(theValue)) ? theValue : defaultValue;
2179
2102
  }
2180
- function _iterateChain(cb) {
2181
- var nextPlugin;
2182
- while (!!(nextPlugin = context._next())) {
2183
- var plugin = nextPlugin[_DYN_GET_PLUGIN ]();
2184
- if (plugin) {
2185
- cb(plugin);
2103
+ return _supportsCookies;
2104
+ }
2105
+ function _extractParts(theValue) {
2106
+ var values = {};
2107
+ if (theValue && theValue[_DYN_LENGTH$2 ]) {
2108
+ var parts = strTrim(theValue)[_DYN_SPLIT ](";");
2109
+ arrForEach(parts, function (thePart) {
2110
+ thePart = strTrim(thePart || STR_EMPTY);
2111
+ if (thePart) {
2112
+ var idx = strIndexOf(thePart, "=");
2113
+ if (idx === -1) {
2114
+ values[thePart] = null;
2115
+ }
2116
+ else {
2117
+ values[strTrim(strLeft(thePart, idx))] = strTrim(strSubstring(thePart, idx + 1));
2118
+ }
2186
2119
  }
2187
- }
2120
+ });
2188
2121
  }
2189
- return context;
2122
+ return values;
2190
2123
  }
2191
- function createProcessTelemetryContext(telemetryChain, cfg, core, startAt) {
2192
- var config = createDynamicConfig(cfg);
2193
- var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
2194
- var context = internalContext.ctx;
2195
- function _processNext(env) {
2196
- var nextPlugin = internalContext._next();
2197
- if (nextPlugin) {
2198
- nextPlugin[STR_PROCESS_TELEMETRY ](env, context);
2199
- }
2200
- return !nextPlugin;
2124
+ function _formatDate(theDate, func) {
2125
+ if (isFunction(theDate[func])) {
2126
+ return theDate[func]();
2201
2127
  }
2202
- function _createNew(plugins, startAt) {
2203
- if (plugins === void 0) { plugins = null; }
2204
- if (isArray(plugins)) {
2205
- plugins = createTelemetryProxyChain(plugins, config.cfg, core, startAt);
2128
+ return null;
2129
+ }
2130
+ function _formatCookieValue(value, values) {
2131
+ var cookieValue = value || STR_EMPTY;
2132
+ objForEachKey(values, function (name, theValue) {
2133
+ cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : STR_EMPTY);
2134
+ });
2135
+ return cookieValue;
2136
+ }
2137
+ function _getCookieValue(name) {
2138
+ var cookieValue = STR_EMPTY;
2139
+ if (_doc) {
2140
+ var theCookie = _doc[strCookie] || STR_EMPTY;
2141
+ if (_parsedCookieValue !== theCookie) {
2142
+ _cookieCache = _extractParts(theCookie);
2143
+ _parsedCookieValue = theCookie;
2206
2144
  }
2207
- return createProcessTelemetryContext(plugins || context[_DYN_GET_NEXT ](), config.cfg, core, startAt);
2145
+ cookieValue = strTrim(_cookieCache[name] || STR_EMPTY);
2208
2146
  }
2209
- context[_DYN_PROCESS_NEXT ] = _processNext;
2210
- context[_DYN_CREATE_NEW ] = _createNew;
2211
- return context;
2147
+ return cookieValue;
2212
2148
  }
2213
- function createProcessTelemetryUnloadContext(telemetryChain, core, startAt) {
2214
- var config = createDynamicConfig(core[_DYN_CONFIG ]);
2215
- var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
2216
- var context = internalContext.ctx;
2217
- function _processNext(unloadState) {
2218
- var nextPlugin = internalContext._next();
2219
- nextPlugin && nextPlugin.unload(context, unloadState);
2220
- return !nextPlugin;
2149
+ function _setCookieValue(name, cookieValue) {
2150
+ if (_doc) {
2151
+ _doc[strCookie] = name + "=" + cookieValue;
2221
2152
  }
2222
- function _createNew(plugins, startAt) {
2223
- if (plugins === void 0) { plugins = null; }
2224
- if (isArray(plugins)) {
2225
- plugins = createTelemetryProxyChain(plugins, config.cfg, core, startAt);
2226
- }
2227
- return createProcessTelemetryUnloadContext(plugins || context[_DYN_GET_NEXT ](), core, startAt);
2228
- }
2229
- context[_DYN_PROCESS_NEXT ] = _processNext;
2230
- context[_DYN_CREATE_NEW ] = _createNew;
2231
- return context;
2232
2153
  }
2233
- function createProcessTelemetryUpdateContext(telemetryChain, core, startAt) {
2234
- var config = createDynamicConfig(core[_DYN_CONFIG ]);
2235
- var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
2236
- var context = internalContext.ctx;
2237
- function _processNext(updateState) {
2238
- return context.iterate(function (plugin) {
2239
- if (isFunction(plugin[_DYN_UPDATE$1 ])) {
2240
- plugin[_DYN_UPDATE$1 ](context, updateState);
2241
- }
2242
- });
2154
+ function uaDisallowsSameSiteNone(userAgent) {
2155
+ if (!isString(userAgent)) {
2156
+ return false;
2243
2157
  }
2244
- function _createNew(plugins, startAt) {
2245
- if (plugins === void 0) { plugins = null; }
2246
- if (isArray(plugins)) {
2247
- plugins = createTelemetryProxyChain(plugins, config.cfg, core, startAt);
2248
- }
2249
- return createProcessTelemetryUpdateContext(plugins || context[_DYN_GET_NEXT ](), core, startAt);
2158
+ if (strContains(userAgent, "CPU iPhone OS 12") || strContains(userAgent, "iPad; CPU OS 12")) {
2159
+ return true;
2250
2160
  }
2251
- context[_DYN_PROCESS_NEXT ] = _processNext;
2252
- context[_DYN_CREATE_NEW ] = _createNew;
2253
- return context;
2254
- }
2255
- function createTelemetryProxyChain(plugins, config, core, startAt) {
2256
- var firstProxy = null;
2257
- var add = startAt ? false : true;
2258
- if (isArray(plugins) && plugins[_DYN_LENGTH$2 ] > 0) {
2259
- var lastProxy_1 = null;
2260
- arrForEach(plugins, function (thePlugin) {
2261
- if (!add && startAt === thePlugin) {
2262
- add = true;
2263
- }
2264
- if (add && thePlugin && isFunction(thePlugin[STR_PROCESS_TELEMETRY ])) {
2265
- var newProxy = createTelemetryPluginProxy(thePlugin, config, core);
2266
- if (!firstProxy) {
2267
- firstProxy = newProxy;
2268
- }
2269
- if (lastProxy_1) {
2270
- lastProxy_1._setNext(newProxy);
2271
- }
2272
- lastProxy_1 = newProxy;
2273
- }
2274
- });
2161
+ if (strContains(userAgent, "Macintosh; Intel Mac OS X 10_14") && strContains(userAgent, "Version/") && strContains(userAgent, "Safari")) {
2162
+ return true;
2275
2163
  }
2276
- if (startAt && !firstProxy) {
2277
- return createTelemetryProxyChain([startAt], config, core);
2164
+ if (strContains(userAgent, "Macintosh; Intel Mac OS X 10_14") && strEndsWith(userAgent, "AppleWebKit/605.1.15 (KHTML, like Gecko)")) {
2165
+ return true;
2278
2166
  }
2279
- return firstProxy;
2280
- }
2281
- function createTelemetryPluginProxy(plugin, config, core) {
2282
- var nextProxy = null;
2283
- var hasProcessTelemetry = isFunction(plugin[STR_PROCESS_TELEMETRY ]);
2284
- var hasSetNext = isFunction(plugin[_DYN_SET_NEXT_PLUGIN ]);
2285
- var chainId;
2286
- if (plugin) {
2287
- chainId = plugin[_DYN_IDENTIFIER ] + "-" + plugin[STR_PRIORITY ] + "-" + _chainId++;
2167
+ if (strContains(userAgent, "Chrome/5") || strContains(userAgent, "Chrome/6")) {
2168
+ return true;
2288
2169
  }
2289
- else {
2290
- chainId = "Unknown-0-" + _chainId++;
2170
+ if (strContains(userAgent, "UnrealEngine") && !strContains(userAgent, "Chrome")) {
2171
+ return true;
2291
2172
  }
2292
- var proxyChain = {
2293
- getPlugin: function () {
2294
- return plugin;
2295
- },
2296
- getNext: function () {
2297
- return nextProxy;
2298
- },
2299
- processTelemetry: _processTelemetry,
2300
- unload: _unloadPlugin,
2301
- update: _updatePlugin,
2302
- _id: chainId,
2303
- _setNext: function (nextPlugin) {
2304
- nextProxy = nextPlugin;
2305
- }
2306
- };
2307
- function _getTelCtx() {
2308
- var itemCtx;
2309
- if (plugin && isFunction(plugin[strGetTelCtx])) {
2310
- itemCtx = plugin[strGetTelCtx]();
2311
- }
2312
- if (!itemCtx) {
2313
- itemCtx = createProcessTelemetryContext(proxyChain, config, core);
2314
- }
2315
- return itemCtx;
2173
+ if (strContains(userAgent, "UCBrowser/12") || strContains(userAgent, "UCBrowser/11")) {
2174
+ return true;
2316
2175
  }
2317
- function _processChain(itemCtx, processPluginFn, name, details, isAsync) {
2318
- var hasRun = false;
2319
- var identifier = plugin ? plugin[_DYN_IDENTIFIER ] : strTelemetryPluginChain;
2320
- var hasRunContext = itemCtx[strHasRunFlags];
2321
- if (!hasRunContext) {
2322
- hasRunContext = itemCtx[strHasRunFlags] = {};
2176
+ return false;
2177
+ }
2178
+
2179
+ var strExecutionContextKey = "ctx";
2180
+ var strParentContextKey = "ParentContextKey";
2181
+ var strChildrenContextKey = "ChildrenContextKey";
2182
+ var PerfEvent = /** @class */ (function () {
2183
+ function PerfEvent(name, payloadDetails, isAsync) {
2184
+ var _self = this;
2185
+ _self.start = utcNow();
2186
+ _self[_DYN_NAME$1 ] = name;
2187
+ _self[_DYN_IS_ASYNC ] = isAsync;
2188
+ _self[_DYN_IS_CHILD_EVT ] = function () { return false; };
2189
+ if (isFunction(payloadDetails)) {
2190
+ var theDetails_1;
2191
+ objDefineAccessors(_self, "payload", function () {
2192
+ if (!theDetails_1 && isFunction(payloadDetails)) {
2193
+ theDetails_1 = payloadDetails();
2194
+ payloadDetails = null;
2195
+ }
2196
+ return theDetails_1;
2197
+ });
2323
2198
  }
2324
- itemCtx.setNext(nextProxy);
2325
- if (plugin) {
2326
- doPerf(itemCtx[STR_CORE ](), function () { return identifier + ":" + name; }, function () {
2327
- hasRunContext[chainId] = true;
2328
- try {
2329
- var nextId = nextProxy ? nextProxy._id : STR_EMPTY;
2330
- if (nextId) {
2331
- hasRunContext[nextId] = false;
2332
- }
2333
- hasRun = processPluginFn(itemCtx);
2199
+ _self[_DYN_GET_CTX ] = function (key) {
2200
+ if (key) {
2201
+ if (key === PerfEvent[strParentContextKey] || key === PerfEvent[strChildrenContextKey]) {
2202
+ return _self[key];
2334
2203
  }
2335
- catch (error) {
2336
- var hasNextRun = nextProxy ? hasRunContext[nextProxy._id] : true;
2337
- if (hasNextRun) {
2338
- hasRun = true;
2339
- }
2340
- if (!nextProxy || !hasNextRun) {
2341
- _throwInternal(itemCtx[_DYN_DIAG_LOG ](), 1 , 73 , "Plugin [" + identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
2204
+ return (_self[strExecutionContextKey] || {})[key];
2205
+ }
2206
+ return null;
2207
+ };
2208
+ _self[_DYN_SET_CTX ] = function (key, value) {
2209
+ if (key) {
2210
+ if (key === PerfEvent[strParentContextKey]) {
2211
+ if (!_self[key]) {
2212
+ _self[_DYN_IS_CHILD_EVT ] = function () { return true; };
2342
2213
  }
2214
+ _self[key] = value;
2215
+ }
2216
+ else if (key === PerfEvent[strChildrenContextKey]) {
2217
+ _self[key] = value;
2218
+ }
2219
+ else {
2220
+ var ctx = _self[strExecutionContextKey] = _self[strExecutionContextKey] || {};
2221
+ ctx[key] = value;
2343
2222
  }
2344
- }, details, isAsync);
2345
- }
2346
- return hasRun;
2347
- }
2348
- function _processTelemetry(env, itemCtx) {
2349
- itemCtx = itemCtx || _getTelCtx();
2350
- function _callProcessTelemetry(itemCtx) {
2351
- if (!plugin || !hasProcessTelemetry) {
2352
- return false;
2353
- }
2354
- var pluginState = _getPluginState(plugin);
2355
- if (pluginState[_DYN_TEARDOWN ] || pluginState[STR_DISABLED]) {
2356
- return false;
2357
2223
  }
2358
- if (hasSetNext) {
2359
- plugin[_DYN_SET_NEXT_PLUGIN ](nextProxy);
2224
+ };
2225
+ _self[_DYN_COMPLETE ] = function () {
2226
+ var childTime = 0;
2227
+ var childEvts = _self[_DYN_GET_CTX ](PerfEvent[strChildrenContextKey]);
2228
+ if (isArray(childEvts)) {
2229
+ for (var lp = 0; lp < childEvts[_DYN_LENGTH$2 ]; lp++) {
2230
+ var childEvt = childEvts[lp];
2231
+ if (childEvt) {
2232
+ childTime += childEvt[_DYN_TIME ];
2233
+ }
2234
+ }
2360
2235
  }
2361
- plugin[STR_PROCESS_TELEMETRY ](env, itemCtx);
2362
- return true;
2363
- }
2364
- if (!_processChain(itemCtx, _callProcessTelemetry, "processTelemetry", function () { return ({ item: env }); }, !(env.sync))) {
2365
- itemCtx[_DYN_PROCESS_NEXT ](env);
2366
- }
2236
+ _self[_DYN_TIME ] = utcNow() - _self.start;
2237
+ _self.exTime = _self[_DYN_TIME ] - childTime;
2238
+ _self[_DYN_COMPLETE ] = function () { };
2239
+ };
2367
2240
  }
2368
- function _unloadPlugin(unloadCtx, unloadState) {
2369
- function _callTeardown() {
2370
- var hasRun = false;
2371
- if (plugin) {
2372
- var pluginState = _getPluginState(plugin);
2373
- var pluginCore = plugin[STR_CORE] || pluginState[STR_CORE ];
2374
- if (plugin && (!pluginCore || pluginCore === unloadCtx.core()) && !pluginState[_DYN_TEARDOWN ]) {
2375
- pluginState[STR_CORE ] = null;
2376
- pluginState[_DYN_TEARDOWN ] = true;
2377
- pluginState[_DYN_IS_INITIALIZED ] = false;
2378
- if (plugin[_DYN_TEARDOWN ] && plugin[_DYN_TEARDOWN ](unloadCtx, unloadState) === true) {
2379
- hasRun = true;
2241
+ PerfEvent.ParentContextKey = "parent";
2242
+ PerfEvent.ChildrenContextKey = "childEvts";
2243
+ return PerfEvent;
2244
+ }());
2245
+ var doPerfActiveKey = "CoreUtils.doPerf";
2246
+ function doPerf(mgrSource, getSource, func, details, isAsync) {
2247
+ if (mgrSource) {
2248
+ var perfMgr = mgrSource;
2249
+ if (perfMgr[STR_GET_PERF_MGR]) {
2250
+ perfMgr = perfMgr[STR_GET_PERF_MGR]();
2251
+ }
2252
+ if (perfMgr) {
2253
+ var perfEvt = void 0;
2254
+ var currentActive = perfMgr[_DYN_GET_CTX ](doPerfActiveKey);
2255
+ try {
2256
+ perfEvt = perfMgr.create(getSource(), details, isAsync);
2257
+ if (perfEvt) {
2258
+ if (currentActive && perfEvt[_DYN_SET_CTX ]) {
2259
+ perfEvt[_DYN_SET_CTX ](PerfEvent[strParentContextKey], currentActive);
2260
+ if (currentActive[_DYN_GET_CTX ] && currentActive[_DYN_SET_CTX ]) {
2261
+ var children = currentActive[_DYN_GET_CTX ](PerfEvent[strChildrenContextKey]);
2262
+ if (!children) {
2263
+ children = [];
2264
+ currentActive[_DYN_SET_CTX ](PerfEvent[strChildrenContextKey], children);
2265
+ }
2266
+ children[_DYN_PUSH ](perfEvt);
2267
+ }
2380
2268
  }
2269
+ perfMgr[_DYN_SET_CTX ](doPerfActiveKey, perfEvt);
2270
+ return func(perfEvt);
2381
2271
  }
2382
2272
  }
2383
- return hasRun;
2384
- }
2385
- if (!_processChain(unloadCtx, _callTeardown, "unload", function () { }, unloadState[_DYN_IS_ASYNC ])) {
2386
- unloadCtx[_DYN_PROCESS_NEXT ](unloadState);
2273
+ catch (ex) {
2274
+ if (perfEvt && perfEvt[_DYN_SET_CTX ]) {
2275
+ perfEvt[_DYN_SET_CTX ]("exception", ex);
2276
+ }
2277
+ }
2278
+ finally {
2279
+ if (perfEvt) {
2280
+ perfMgr.fire(perfEvt);
2281
+ }
2282
+ perfMgr[_DYN_SET_CTX ](doPerfActiveKey, currentActive);
2283
+ }
2387
2284
  }
2388
2285
  }
2389
- function _updatePlugin(updateCtx, updateState) {
2390
- function _callUpdate() {
2391
- var hasRun = false;
2392
- if (plugin) {
2393
- var pluginState = _getPluginState(plugin);
2394
- var pluginCore = plugin[STR_CORE] || pluginState[STR_CORE ];
2395
- if (plugin && (!pluginCore || pluginCore === updateCtx.core()) && !pluginState[_DYN_TEARDOWN ]) {
2396
- if (plugin[_DYN_UPDATE$1 ] && plugin[_DYN_UPDATE$1 ](updateCtx, updateState) === true) {
2397
- hasRun = true;
2398
- }
2399
- }
2400
- }
2401
- return hasRun;
2402
- }
2403
- if (!_processChain(updateCtx, _callUpdate, "update", function () { }, false)) {
2404
- updateCtx[_DYN_PROCESS_NEXT ](updateState);
2405
- }
2406
- }
2407
- return objFreeze(proxyChain);
2286
+ return func();
2408
2287
  }
2409
2288
 
2410
- var _a$2, _b;
2411
- var strToGMTString = "toGMTString";
2412
- var strToUTCString = "toUTCString";
2413
- var strCookie = "cookie";
2414
- var strExpires = "expires";
2415
- var strIsCookieUseDisabled = "isCookieUseDisabled";
2416
- var strDisableCookiesUsage = "disableCookiesUsage";
2417
- var strConfigCookieMgr = "_ckMgr";
2418
- var _supportsCookies = null;
2419
- var _allowUaSameSite = null;
2420
- var _parsedCookieValue = null;
2421
- var _doc = getDocument();
2422
- var _cookieCache = {};
2423
- var _globalCookieConfig = {};
2424
- var defaultConfig = objDeepFreeze((_a$2 = {},
2425
- _a$2[STR_DOMAIN] = { fb: "cookieDomain", dfVal: isNotNullOrUndefined },
2426
- _a$2.path = { fb: "cookiePath", dfVal: isNotNullOrUndefined },
2427
- _a$2.enabled = UNDEFINED_VALUE,
2428
- _a$2));
2429
- var rootDefaultConfig = (_b = {
2430
- cookieCfg: {},
2431
- cookieDomain: UNDEFINED_VALUE,
2432
- cookiePath: UNDEFINED_VALUE
2433
- },
2434
- _b[strDisableCookiesUsage] = UNDEFINED_VALUE,
2435
- _b);
2436
- function _gblCookieMgr(config, logger) {
2437
- var inst = createCookieMgr[strConfigCookieMgr] || _globalCookieConfig[strConfigCookieMgr];
2438
- if (!inst) {
2439
- inst = createCookieMgr[strConfigCookieMgr] = createCookieMgr(config, logger);
2440
- _globalCookieConfig[strConfigCookieMgr] = inst;
2441
- }
2442
- return inst;
2443
- }
2444
- function _isMgrEnabled(cookieMgr) {
2445
- if (cookieMgr) {
2446
- return cookieMgr.isEnabled();
2289
+ function generateW3CId() {
2290
+ var hexValues = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
2291
+ var oct = STR_EMPTY, tmp;
2292
+ for (var a = 0; a < 4; a++) {
2293
+ tmp = random32();
2294
+ oct +=
2295
+ hexValues[tmp & 0xF] +
2296
+ hexValues[tmp >> 4 & 0xF] +
2297
+ hexValues[tmp >> 8 & 0xF] +
2298
+ hexValues[tmp >> 12 & 0xF] +
2299
+ hexValues[tmp >> 16 & 0xF] +
2300
+ hexValues[tmp >> 20 & 0xF] +
2301
+ hexValues[tmp >> 24 & 0xF] +
2302
+ hexValues[tmp >> 28 & 0xF];
2447
2303
  }
2448
- return true;
2304
+ var clockSequenceHi = hexValues[8 + (random32() & 0x03) | 0];
2305
+ return strSubstr(oct, 0, 8) + strSubstr(oct, 9, 4) + "4" + strSubstr(oct, 13, 3) + clockSequenceHi + strSubstr(oct, 16, 3) + strSubstr(oct, 19, 12);
2449
2306
  }
2450
- function _isIgnoredCookie(cookieMgrCfg, name) {
2451
- if (name && cookieMgrCfg && isArray(cookieMgrCfg.ignoreCookies)) {
2452
- return arrIndexOf(cookieMgrCfg.ignoreCookies, name) !== -1;
2307
+
2308
+ var INVALID_TRACE_ID = "00000000000000000000000000000000";
2309
+ var INVALID_SPAN_ID = "0000000000000000";
2310
+ function _isValid(value, len, invalidValue) {
2311
+ if (value && value[_DYN_LENGTH$2 ] === len && value !== invalidValue) {
2312
+ return !!value.match(/^[\da-f]*$/i);
2453
2313
  }
2454
2314
  return false;
2455
2315
  }
2456
- function _isBlockedCookie(cookieMgrCfg, name) {
2457
- if (name && cookieMgrCfg && isArray(cookieMgrCfg.blockedCookies)) {
2458
- if (arrIndexOf(cookieMgrCfg.blockedCookies, name) !== -1) {
2459
- return true;
2316
+ function isValidTraceId(value) {
2317
+ return _isValid(value, 32, INVALID_TRACE_ID);
2318
+ }
2319
+ function isValidSpanId(value) {
2320
+ return _isValid(value, 16, INVALID_SPAN_ID);
2321
+ }
2322
+
2323
+ var pluginStateData = createElmNodeData("plugin");
2324
+ function _getPluginState(plugin) {
2325
+ return pluginStateData.get(plugin, "state", {}, true);
2326
+ }
2327
+
2328
+ var strTelemetryPluginChain = "TelemetryPluginChain";
2329
+ var strHasRunFlags = "_hasRun";
2330
+ var strGetTelCtx = "_getTelCtx";
2331
+ var _chainId = 0;
2332
+ function _getNextProxyStart(proxy, core, startAt) {
2333
+ while (proxy) {
2334
+ if (proxy[_DYN_GET_PLUGIN ]() === startAt) {
2335
+ return proxy;
2460
2336
  }
2337
+ proxy = proxy[_DYN_GET_NEXT ]();
2461
2338
  }
2462
- return _isIgnoredCookie(cookieMgrCfg, name);
2339
+ return createTelemetryProxyChain([startAt], core.config || {}, core);
2463
2340
  }
2464
- function safeGetCookieMgr(core, config) {
2465
- var cookieMgr;
2466
- if (core) {
2467
- cookieMgr = core.getCookieMgr();
2341
+ function _createInternalContext(telemetryChain, dynamicHandler, core, startAt) {
2342
+ var _nextProxy = null;
2343
+ var _onComplete = [];
2344
+ if (!dynamicHandler) {
2345
+ dynamicHandler = createDynamicConfig({}, null, core[_DYN_LOGGER ]);
2468
2346
  }
2469
- else if (config) {
2470
- var cookieCfg = config.cookieCfg;
2471
- if (cookieCfg && cookieCfg[strConfigCookieMgr]) {
2472
- cookieMgr = cookieCfg[strConfigCookieMgr];
2347
+ if (startAt !== null) {
2348
+ _nextProxy = startAt ? _getNextProxyStart(telemetryChain, core, startAt) : telemetryChain;
2349
+ }
2350
+ var context = {
2351
+ _next: _moveNext,
2352
+ ctx: {
2353
+ core: function () {
2354
+ return core;
2355
+ },
2356
+ diagLog: function () {
2357
+ return safeGetLogger(core, dynamicHandler.cfg);
2358
+ },
2359
+ getCfg: function () {
2360
+ return dynamicHandler.cfg;
2361
+ },
2362
+ getExtCfg: _resolveExtCfg,
2363
+ getConfig: _getConfig,
2364
+ hasNext: function () {
2365
+ return !!_nextProxy;
2366
+ },
2367
+ getNext: function () {
2368
+ return _nextProxy;
2369
+ },
2370
+ setNext: function (nextPlugin) {
2371
+ _nextProxy = nextPlugin;
2372
+ },
2373
+ iterate: _iterateChain,
2374
+ onComplete: _addOnComplete
2473
2375
  }
2474
- else {
2475
- cookieMgr = createCookieMgr(config);
2376
+ };
2377
+ function _addOnComplete(onComplete, that) {
2378
+ var args = [];
2379
+ for (var _i = 2; _i < arguments.length; _i++) {
2380
+ args[_i - 2] = arguments[_i];
2476
2381
  }
2477
- }
2478
- if (!cookieMgr) {
2479
- cookieMgr = _gblCookieMgr(config, (core || {})[_DYN_LOGGER ]);
2480
- }
2481
- return cookieMgr;
2482
- }
2483
- function createCookieMgr(rootConfig, logger) {
2484
- var cookieMgrConfig;
2485
- var _path;
2486
- var _domain;
2487
- var _enabled;
2488
- var _getCookieFn;
2489
- var _setCookieFn;
2490
- var _delCookieFn;
2491
- rootConfig = createDynamicConfig(rootConfig || _globalCookieConfig, null, logger).cfg;
2492
- onConfigChange(rootConfig, function (details) {
2493
- details[_DYN_SET_DF ](details.cfg, rootDefaultConfig);
2494
- cookieMgrConfig = details[_DYN_SET_DF ](details.cfg.cookieCfg, defaultConfig);
2495
- var isEnabled = cookieMgrConfig.enabled;
2496
- if (isNullOrUndefined(isEnabled)) {
2497
- var cookieEnabled = void 0;
2498
- if (!isUndefined(rootConfig[strIsCookieUseDisabled])) {
2499
- cookieEnabled = !rootConfig[strIsCookieUseDisabled];
2500
- }
2501
- if (!isUndefined(rootConfig[strDisableCookiesUsage])) {
2502
- cookieEnabled = !rootConfig[strDisableCookiesUsage];
2503
- }
2504
- isEnabled = cookieEnabled;
2382
+ if (onComplete) {
2383
+ _onComplete[_DYN_PUSH ]({
2384
+ func: onComplete,
2385
+ self: !isUndefined(that) ? that : context.ctx,
2386
+ args: args
2387
+ });
2505
2388
  }
2506
- _path = cookieMgrConfig[STR_PATH ] || "/";
2507
- _domain = cookieMgrConfig[STR_DOMAIN ];
2508
- _enabled = isEnabled !== false;
2509
- _getCookieFn = cookieMgrConfig.getCookie || _getCookieValue;
2510
- _setCookieFn = cookieMgrConfig.setCookie || _setCookieValue;
2511
- _delCookieFn = cookieMgrConfig.delCookie || _setCookieValue;
2512
- }, logger);
2513
- var cookieMgr = {
2514
- isEnabled: function () {
2515
- var enabled = _enabled && areCookiesSupported(logger);
2516
- var gblManager = _globalCookieConfig[strConfigCookieMgr];
2517
- if (enabled && gblManager && cookieMgr !== gblManager) {
2518
- enabled = _isMgrEnabled(gblManager);
2519
- }
2520
- return enabled;
2521
- },
2522
- setEnabled: function (value) {
2523
- _enabled = value !== false;
2524
- },
2525
- set: function (name, value, maxAgeSec, domain, path) {
2526
- var result = false;
2527
- if (_isMgrEnabled(cookieMgr) && !_isBlockedCookie(cookieMgrConfig, name)) {
2528
- var values = {};
2529
- var theValue = strTrim(value || STR_EMPTY);
2530
- var idx = strIndexOf(theValue, ";");
2531
- if (idx !== -1) {
2532
- theValue = strTrim(strLeft(value, idx));
2533
- values = _extractParts(strSubstring(value, idx + 1));
2534
- }
2535
- setValue(values, STR_DOMAIN, domain || _domain, isTruthy, isUndefined);
2536
- if (!isNullOrUndefined(maxAgeSec)) {
2537
- var _isIE = isIE();
2538
- if (isUndefined(values[strExpires])) {
2539
- var nowMs = utcNow();
2540
- var expireMs = nowMs + (maxAgeSec * 1000);
2541
- if (expireMs > 0) {
2542
- var expiry = new Date();
2543
- expiry.setTime(expireMs);
2544
- setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || STR_EMPTY, isTruthy);
2545
- }
2546
- }
2547
- if (!_isIE) {
2548
- setValue(values, "max-age", STR_EMPTY + maxAgeSec, null, isUndefined);
2549
- }
2550
- }
2551
- var location_1 = getLocation();
2552
- if (location_1 && location_1.protocol === "https:") {
2553
- setValue(values, "secure", null, null, isUndefined);
2554
- if (_allowUaSameSite === null) {
2555
- _allowUaSameSite = !uaDisallowsSameSiteNone((getNavigator() || {})[_DYN_USER_AGENT ]);
2389
+ }
2390
+ function _moveNext() {
2391
+ var nextProxy = _nextProxy;
2392
+ _nextProxy = nextProxy ? nextProxy[_DYN_GET_NEXT ]() : null;
2393
+ if (!nextProxy) {
2394
+ var onComplete = _onComplete;
2395
+ if (onComplete && onComplete[_DYN_LENGTH$2 ] > 0) {
2396
+ arrForEach(onComplete, function (completeDetails) {
2397
+ try {
2398
+ completeDetails.func[_DYN_CALL ](completeDetails.self, completeDetails.args);
2556
2399
  }
2557
- if (_allowUaSameSite) {
2558
- setValue(values, "SameSite", "None", null, isUndefined);
2400
+ catch (e) {
2401
+ _throwInternal(core[_DYN_LOGGER ], 2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
2559
2402
  }
2560
- }
2561
- setValue(values, STR_PATH, path || _path, null, isUndefined);
2562
- _setCookieFn(name, _formatCookieValue(theValue, values));
2563
- result = true;
2403
+ });
2404
+ _onComplete = [];
2564
2405
  }
2565
- return result;
2566
- },
2567
- get: function (name) {
2568
- var value = STR_EMPTY;
2569
- if (_isMgrEnabled(cookieMgr) && !_isIgnoredCookie(cookieMgrConfig, name)) {
2570
- value = _getCookieFn(name);
2406
+ }
2407
+ return nextProxy;
2408
+ }
2409
+ function _getExtCfg(identifier, createIfMissing) {
2410
+ var idCfg = null;
2411
+ var cfg = dynamicHandler.cfg;
2412
+ if (cfg && identifier) {
2413
+ var extCfg = cfg[STR_EXTENSION_CONFIG ];
2414
+ if (!extCfg && createIfMissing) {
2415
+ extCfg = {};
2571
2416
  }
2572
- return value;
2573
- },
2574
- del: function (name, path) {
2575
- var result = false;
2576
- if (_isMgrEnabled(cookieMgr)) {
2577
- result = cookieMgr.purge(name, path);
2417
+ dynamicHandler.set(cfg, STR_EXTENSION_CONFIG, extCfg);
2418
+ extCfg = cfg[STR_EXTENSION_CONFIG ];
2419
+ if (extCfg) {
2420
+ idCfg = extCfg[identifier];
2421
+ if (!idCfg && createIfMissing) {
2422
+ idCfg = {};
2423
+ }
2424
+ dynamicHandler.set(extCfg, identifier, idCfg);
2425
+ idCfg = extCfg[identifier];
2578
2426
  }
2579
- return result;
2580
- },
2581
- purge: function (name, path) {
2582
- var _a;
2583
- var result = false;
2584
- if (areCookiesSupported(logger)) {
2585
- var values = (_a = {},
2586
- _a[STR_PATH] = path ? path : "/",
2587
- _a[strExpires] = "Thu, 01 Jan 1970 00:00:01 GMT",
2588
- _a);
2589
- if (!isIE()) {
2590
- values["max-age"] = "0";
2427
+ }
2428
+ return idCfg;
2429
+ }
2430
+ function _resolveExtCfg(identifier, defaultValues) {
2431
+ var newConfig = _getExtCfg(identifier, true);
2432
+ if (defaultValues) {
2433
+ objForEachKey(defaultValues, function (field, defaultValue) {
2434
+ if (isNullOrUndefined(newConfig[field])) {
2435
+ var cfgValue = dynamicHandler.cfg[field];
2436
+ if (cfgValue || !isNullOrUndefined(cfgValue)) {
2437
+ newConfig[field] = cfgValue;
2438
+ }
2591
2439
  }
2592
- _delCookieFn(name, _formatCookieValue(STR_EMPTY, values));
2593
- result = true;
2440
+ _applyDefaultValue(dynamicHandler, newConfig, field, defaultValue);
2441
+ });
2442
+ }
2443
+ return dynamicHandler[_DYN_SET_DF ](newConfig, defaultValues);
2444
+ }
2445
+ function _getConfig(identifier, field, defaultValue) {
2446
+ if (defaultValue === void 0) { defaultValue = false; }
2447
+ var theValue;
2448
+ var extConfig = _getExtCfg(identifier, false);
2449
+ var rootConfig = dynamicHandler.cfg;
2450
+ if (extConfig && (extConfig[field] || !isNullOrUndefined(extConfig[field]))) {
2451
+ theValue = extConfig[field];
2452
+ }
2453
+ else if (rootConfig[field] || !isNullOrUndefined(rootConfig[field])) {
2454
+ theValue = rootConfig[field];
2455
+ }
2456
+ return (theValue || !isNullOrUndefined(theValue)) ? theValue : defaultValue;
2457
+ }
2458
+ function _iterateChain(cb) {
2459
+ var nextPlugin;
2460
+ while (!!(nextPlugin = context._next())) {
2461
+ var plugin = nextPlugin[_DYN_GET_PLUGIN ]();
2462
+ if (plugin) {
2463
+ cb(plugin);
2594
2464
  }
2595
- return result;
2596
2465
  }
2597
- };
2598
- cookieMgr[strConfigCookieMgr] = cookieMgr;
2599
- return cookieMgr;
2466
+ }
2467
+ return context;
2468
+ }
2469
+ function createProcessTelemetryContext(telemetryChain, cfg, core, startAt) {
2470
+ var config = createDynamicConfig(cfg);
2471
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
2472
+ var context = internalContext.ctx;
2473
+ function _processNext(env) {
2474
+ var nextPlugin = internalContext._next();
2475
+ if (nextPlugin) {
2476
+ nextPlugin[STR_PROCESS_TELEMETRY ](env, context);
2477
+ }
2478
+ return !nextPlugin;
2479
+ }
2480
+ function _createNew(plugins, startAt) {
2481
+ if (plugins === void 0) { plugins = null; }
2482
+ if (isArray(plugins)) {
2483
+ plugins = createTelemetryProxyChain(plugins, config.cfg, core, startAt);
2484
+ }
2485
+ return createProcessTelemetryContext(plugins || context[_DYN_GET_NEXT ](), config.cfg, core, startAt);
2486
+ }
2487
+ context[_DYN_PROCESS_NEXT ] = _processNext;
2488
+ context[_DYN_CREATE_NEW ] = _createNew;
2489
+ return context;
2600
2490
  }
2601
- function areCookiesSupported(logger) {
2602
- if (_supportsCookies === null) {
2603
- _supportsCookies = false;
2604
- try {
2605
- var doc = _doc || {};
2606
- _supportsCookies = doc[strCookie] !== undefined;
2607
- }
2608
- catch (e) {
2609
- _throwInternal(logger, 2 , 68 , "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
2491
+ function createProcessTelemetryUnloadContext(telemetryChain, core, startAt) {
2492
+ var config = createDynamicConfig(core.config);
2493
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
2494
+ var context = internalContext.ctx;
2495
+ function _processNext(unloadState) {
2496
+ var nextPlugin = internalContext._next();
2497
+ nextPlugin && nextPlugin.unload(context, unloadState);
2498
+ return !nextPlugin;
2499
+ }
2500
+ function _createNew(plugins, startAt) {
2501
+ if (plugins === void 0) { plugins = null; }
2502
+ if (isArray(plugins)) {
2503
+ plugins = createTelemetryProxyChain(plugins, config.cfg, core, startAt);
2610
2504
  }
2505
+ return createProcessTelemetryUnloadContext(plugins || context[_DYN_GET_NEXT ](), core, startAt);
2611
2506
  }
2612
- return _supportsCookies;
2507
+ context[_DYN_PROCESS_NEXT ] = _processNext;
2508
+ context[_DYN_CREATE_NEW ] = _createNew;
2509
+ return context;
2613
2510
  }
2614
- function _extractParts(theValue) {
2615
- var values = {};
2616
- if (theValue && theValue[_DYN_LENGTH$2 ]) {
2617
- var parts = strTrim(theValue)[_DYN_SPLIT ](";");
2618
- arrForEach(parts, function (thePart) {
2619
- thePart = strTrim(thePart || STR_EMPTY);
2620
- if (thePart) {
2621
- var idx = strIndexOf(thePart, "=");
2622
- if (idx === -1) {
2623
- values[thePart] = null;
2624
- }
2625
- else {
2626
- values[strTrim(strLeft(thePart, idx))] = strTrim(strSubstring(thePart, idx + 1));
2627
- }
2511
+ function createProcessTelemetryUpdateContext(telemetryChain, core, startAt) {
2512
+ var config = createDynamicConfig(core.config);
2513
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
2514
+ var context = internalContext.ctx;
2515
+ function _processNext(updateState) {
2516
+ return context.iterate(function (plugin) {
2517
+ if (isFunction(plugin[_DYN_UPDATE$1 ])) {
2518
+ plugin[_DYN_UPDATE$1 ](context, updateState);
2628
2519
  }
2629
2520
  });
2630
2521
  }
2631
- return values;
2632
- }
2633
- function _formatDate(theDate, func) {
2634
- if (isFunction(theDate[func])) {
2635
- return theDate[func]();
2636
- }
2637
- return null;
2638
- }
2639
- function _formatCookieValue(value, values) {
2640
- var cookieValue = value || STR_EMPTY;
2641
- objForEachKey(values, function (name, theValue) {
2642
- cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : STR_EMPTY);
2643
- });
2644
- return cookieValue;
2645
- }
2646
- function _getCookieValue(name) {
2647
- var cookieValue = STR_EMPTY;
2648
- if (_doc) {
2649
- var theCookie = _doc[strCookie] || STR_EMPTY;
2650
- if (_parsedCookieValue !== theCookie) {
2651
- _cookieCache = _extractParts(theCookie);
2652
- _parsedCookieValue = theCookie;
2522
+ function _createNew(plugins, startAt) {
2523
+ if (plugins === void 0) { plugins = null; }
2524
+ if (isArray(plugins)) {
2525
+ plugins = createTelemetryProxyChain(plugins, config.cfg, core, startAt);
2653
2526
  }
2654
- cookieValue = strTrim(_cookieCache[name] || STR_EMPTY);
2527
+ return createProcessTelemetryUpdateContext(plugins || context[_DYN_GET_NEXT ](), core, startAt);
2655
2528
  }
2656
- return cookieValue;
2529
+ context[_DYN_PROCESS_NEXT ] = _processNext;
2530
+ context[_DYN_CREATE_NEW ] = _createNew;
2531
+ return context;
2657
2532
  }
2658
- function _setCookieValue(name, cookieValue) {
2659
- if (_doc) {
2660
- _doc[strCookie] = name + "=" + cookieValue;
2533
+ function createTelemetryProxyChain(plugins, config, core, startAt) {
2534
+ var firstProxy = null;
2535
+ var add = startAt ? false : true;
2536
+ if (isArray(plugins) && plugins[_DYN_LENGTH$2 ] > 0) {
2537
+ var lastProxy_1 = null;
2538
+ arrForEach(plugins, function (thePlugin) {
2539
+ if (!add && startAt === thePlugin) {
2540
+ add = true;
2541
+ }
2542
+ if (add && thePlugin && isFunction(thePlugin[STR_PROCESS_TELEMETRY ])) {
2543
+ var newProxy = createTelemetryPluginProxy(thePlugin, config, core);
2544
+ if (!firstProxy) {
2545
+ firstProxy = newProxy;
2546
+ }
2547
+ if (lastProxy_1) {
2548
+ lastProxy_1._setNext(newProxy);
2549
+ }
2550
+ lastProxy_1 = newProxy;
2551
+ }
2552
+ });
2661
2553
  }
2554
+ if (startAt && !firstProxy) {
2555
+ return createTelemetryProxyChain([startAt], config, core);
2556
+ }
2557
+ return firstProxy;
2662
2558
  }
2663
- function uaDisallowsSameSiteNone(userAgent) {
2664
- if (!isString(userAgent)) {
2665
- return false;
2559
+ function createTelemetryPluginProxy(plugin, config, core) {
2560
+ var nextProxy = null;
2561
+ var hasProcessTelemetry = isFunction(plugin[STR_PROCESS_TELEMETRY ]);
2562
+ var hasSetNext = isFunction(plugin[_DYN_SET_NEXT_PLUGIN ]);
2563
+ var chainId;
2564
+ if (plugin) {
2565
+ chainId = plugin[_DYN_IDENTIFIER ] + "-" + plugin[STR_PRIORITY ] + "-" + _chainId++;
2666
2566
  }
2667
- if (strContains(userAgent, "CPU iPhone OS 12") || strContains(userAgent, "iPad; CPU OS 12")) {
2668
- return true;
2567
+ else {
2568
+ chainId = "Unknown-0-" + _chainId++;
2669
2569
  }
2670
- if (strContains(userAgent, "Macintosh; Intel Mac OS X 10_14") && strContains(userAgent, "Version/") && strContains(userAgent, "Safari")) {
2671
- return true;
2570
+ var proxyChain = {
2571
+ getPlugin: function () {
2572
+ return plugin;
2573
+ },
2574
+ getNext: function () {
2575
+ return nextProxy;
2576
+ },
2577
+ processTelemetry: _processTelemetry,
2578
+ unload: _unloadPlugin,
2579
+ update: _updatePlugin,
2580
+ _id: chainId,
2581
+ _setNext: function (nextPlugin) {
2582
+ nextProxy = nextPlugin;
2583
+ }
2584
+ };
2585
+ function _getTelCtx() {
2586
+ var itemCtx;
2587
+ if (plugin && isFunction(plugin[strGetTelCtx])) {
2588
+ itemCtx = plugin[strGetTelCtx]();
2589
+ }
2590
+ if (!itemCtx) {
2591
+ itemCtx = createProcessTelemetryContext(proxyChain, config, core);
2592
+ }
2593
+ return itemCtx;
2672
2594
  }
2673
- if (strContains(userAgent, "Macintosh; Intel Mac OS X 10_14") && strEndsWith(userAgent, "AppleWebKit/605.1.15 (KHTML, like Gecko)")) {
2674
- return true;
2595
+ function _processChain(itemCtx, processPluginFn, name, details, isAsync) {
2596
+ var hasRun = false;
2597
+ var identifier = plugin ? plugin[_DYN_IDENTIFIER ] : strTelemetryPluginChain;
2598
+ var hasRunContext = itemCtx[strHasRunFlags];
2599
+ if (!hasRunContext) {
2600
+ hasRunContext = itemCtx[strHasRunFlags] = {};
2601
+ }
2602
+ itemCtx.setNext(nextProxy);
2603
+ if (plugin) {
2604
+ doPerf(itemCtx[STR_CORE ](), function () { return identifier + ":" + name; }, function () {
2605
+ hasRunContext[chainId] = true;
2606
+ try {
2607
+ var nextId = nextProxy ? nextProxy._id : STR_EMPTY;
2608
+ if (nextId) {
2609
+ hasRunContext[nextId] = false;
2610
+ }
2611
+ hasRun = processPluginFn(itemCtx);
2612
+ }
2613
+ catch (error) {
2614
+ var hasNextRun = nextProxy ? hasRunContext[nextProxy._id] : true;
2615
+ if (hasNextRun) {
2616
+ hasRun = true;
2617
+ }
2618
+ if (!nextProxy || !hasNextRun) {
2619
+ _throwInternal(itemCtx[_DYN_DIAG_LOG ](), 1 , 73 , "Plugin [" + identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
2620
+ }
2621
+ }
2622
+ }, details, isAsync);
2623
+ }
2624
+ return hasRun;
2675
2625
  }
2676
- if (strContains(userAgent, "Chrome/5") || strContains(userAgent, "Chrome/6")) {
2677
- return true;
2626
+ function _processTelemetry(env, itemCtx) {
2627
+ itemCtx = itemCtx || _getTelCtx();
2628
+ function _callProcessTelemetry(itemCtx) {
2629
+ if (!plugin || !hasProcessTelemetry) {
2630
+ return false;
2631
+ }
2632
+ var pluginState = _getPluginState(plugin);
2633
+ if (pluginState[_DYN_TEARDOWN ] || pluginState[STR_DISABLED]) {
2634
+ return false;
2635
+ }
2636
+ if (hasSetNext) {
2637
+ plugin[_DYN_SET_NEXT_PLUGIN ](nextProxy);
2638
+ }
2639
+ plugin[STR_PROCESS_TELEMETRY ](env, itemCtx);
2640
+ return true;
2641
+ }
2642
+ if (!_processChain(itemCtx, _callProcessTelemetry, "processTelemetry", function () { return ({ item: env }); }, !(env.sync))) {
2643
+ itemCtx[_DYN_PROCESS_NEXT ](env);
2644
+ }
2678
2645
  }
2679
- if (strContains(userAgent, "UnrealEngine") && !strContains(userAgent, "Chrome")) {
2680
- return true;
2646
+ function _unloadPlugin(unloadCtx, unloadState) {
2647
+ function _callTeardown() {
2648
+ var hasRun = false;
2649
+ if (plugin) {
2650
+ var pluginState = _getPluginState(plugin);
2651
+ var pluginCore = plugin[STR_CORE] || pluginState[STR_CORE ];
2652
+ if (plugin && (!pluginCore || pluginCore === unloadCtx.core()) && !pluginState[_DYN_TEARDOWN ]) {
2653
+ pluginState[STR_CORE ] = null;
2654
+ pluginState[_DYN_TEARDOWN ] = true;
2655
+ pluginState[_DYN_IS_INITIALIZED ] = false;
2656
+ if (plugin[_DYN_TEARDOWN ] && plugin[_DYN_TEARDOWN ](unloadCtx, unloadState) === true) {
2657
+ hasRun = true;
2658
+ }
2659
+ }
2660
+ }
2661
+ return hasRun;
2662
+ }
2663
+ if (!_processChain(unloadCtx, _callTeardown, "unload", function () { }, unloadState[_DYN_IS_ASYNC ])) {
2664
+ unloadCtx[_DYN_PROCESS_NEXT ](unloadState);
2665
+ }
2681
2666
  }
2682
- if (strContains(userAgent, "UCBrowser/12") || strContains(userAgent, "UCBrowser/11")) {
2683
- return true;
2667
+ function _updatePlugin(updateCtx, updateState) {
2668
+ function _callUpdate() {
2669
+ var hasRun = false;
2670
+ if (plugin) {
2671
+ var pluginState = _getPluginState(plugin);
2672
+ var pluginCore = plugin[STR_CORE] || pluginState[STR_CORE ];
2673
+ if (plugin && (!pluginCore || pluginCore === updateCtx.core()) && !pluginState[_DYN_TEARDOWN ]) {
2674
+ if (plugin[_DYN_UPDATE$1 ] && plugin[_DYN_UPDATE$1 ](updateCtx, updateState) === true) {
2675
+ hasRun = true;
2676
+ }
2677
+ }
2678
+ }
2679
+ return hasRun;
2680
+ }
2681
+ if (!_processChain(updateCtx, _callUpdate, "update", function () { }, false)) {
2682
+ updateCtx[_DYN_PROCESS_NEXT ](updateState);
2683
+ }
2684
2684
  }
2685
- return false;
2685
+ return objFreeze(proxyChain);
2686
2686
  }
2687
2687
 
2688
2688
  function createUnloadHandlerContainer() {