Merge remote-tracking branch 'upstream/master' into MSNev/beta

This commit is contained in:
Nev Wylie 2023-02-01 18:17:30 -08:00
Родитель 2cf0854cd1 c920fb782a
Коммит d8abe518ac
61 изменённых файлов: 21802 добавлений и 2684 удалений

4
.github/workflows/ci.yml поставляемый
Просмотреть файл

@ -16,7 +16,7 @@ jobs:
strategy:
matrix:
node-version: [12.x, 14.x, 16.x, 18.x]
node-version: [14.x, 16.x, 18.x]
steps:
- uses: actions/checkout@v2
@ -25,7 +25,7 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- run: npm install rollup -g
- run: npm install grunt-cli findup-sync nopt pify@2.3.0
- run: npm install grunt-cli
- run: npm install
- run: node common/scripts/install-run-rush.js check
- run: node common/scripts/install-run-rush.js install

12
.vscode/settings.json поставляемый
Просмотреть файл

@ -1,12 +0,0 @@
{
"typescript.tsdk": "./node_modules/typescript/lib",
"files.exclude": {
"**/.tscache": true
},
"markdownlint.config": {
"MD028": false,
"MD025": {
"front_matter_title": ""
}
}
}

Просмотреть файл

@ -5,23 +5,21 @@
<meta charset="utf-8">
<meta http-equiv="Cache-control" content="no-Cache" />
<title>Tests for Application Insights JavaScript AISKU</title>
<link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-1.23.1.css">
<link rel="stylesheet" href="../../../common/Tests/External/qunit-2.9.3.css">
<script>
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.oneDS={})}(this,function(e){"use strict";function u(e){return t(e,"number")}function o(e){return t(e,"boolean")}function s(e,t,n){var r,i=-1;return l(e)?i:(t&&0<t&&(32===t?i=8192:t<=13&&(i=t<<5)),v(n)&&u(r=n)&&0<=r&&r<=9?(-1===i&&(i=0),i|n):(f(e)&&(e=e[0]),-1!==i?i|(l(e)?-1:u(e)?6:a(e)?1:o(e)?7:-1):u(e)?6:i))}function p(e,t,n){if(void 0===n&&(n=!1),y(t)){var r=n?"qsp=true&":"&";return u(t)||o(t)?r+=e+"="+t:r+="object"==typeof t?e+"="+JSON.stringify(t):e+'="'+encodeURIComponent(t)+'"',r}return""}function y(e){return!i(e)&&""!==e}function i(e){return l(e)||null===e}function l(e){return e===undefined||void 0===e}function t(e,t){return typeof e===t}function a(e){return t(e,"string")}function f(e){return e instanceof Array}function v(e){return!l(e)}function m(e,t,n){if(!a(e)||i(t)||""===t)return null;if(a(t)||u(t)||o(t)||f(t))t={value:t};else if("object"!=typeof t||t.hasOwnProperty("value")){if(i(t.value)||""===t.value||!a(t.value)&&!u(t.value)&&!o(t.value)&&!f(t.value))return null}else t={value:n?JSON.stringify(t):t};if(f(t.value)&&!(0<t.value.length))return null;if(v(t.kind)){if(f(t.value)||!((r=t.kind)&&u(r)&&(0<=r&&r<=13||32===r)))return null;t.value=t.value.toString()}var r;return t}e.getCollectorUrlGenerator=function(e,t){var n="https://browser.events.data.microsoft.com/OneCollector/1.0/";t&&t.endpointUrl&&(n=t.endpointUrl);var r=function(e){if("[object Date]"===Object.prototype.toString.call(e)){var t=function(e){var t=e+"";return 1===t.length&&(t="0"+t),t};return e.getUTCFullYear()+"-"+t(1+e.getUTCMonth())+"-"+t(e.getUTCDate())+"T"+t(e.getUTCHours())+":"+t(e.getUTCMinutes())+":"+t(e.getUTCSeconds())+"."+((e.getUTCMilliseconds()/1e3).toFixed(3)+"").slice(2,5)+"Z"}}(new Date),i=0;if(null==e)return"input is null or undefined";if(null===e.name||"undefined"==typeof e.name)return"telemetry item expects valid name";if(null===e.iKey||"undefined"==typeof e.iKey)return"telemetry item expects valid ikey";null!==e.time&&"undefined"!=typeof e.time||(e.time=r);var u=e.baseData,o=e.data,l=p("name",e.name,!0);if(l+=p("time",e.time),l+=p("ver",e.ver),l+=p("iKey","o:"+function(e){if(e){var t=e.indexOf("-");if(-1<t)return e.substring(0,t)}return""}(e.iKey)),l+="&apikey="+e.iKey,e.ext)for(var a in e.ext)if(e.ext.hasOwnProperty(a))for(var f in e.ext[a])e.ext[a].hasOwnProperty(f)&&y(e.ext[a][f])&&y(d=m(f,e.ext[a][f],!0))&&(l+=p("ext."+a+"."+f,d.value));for(var v in u){var c="-"+v;(d=m(v,u[v],!0))&&(0<(i=s(d.value,d.kind,d.propertyType))&&(c=c+"*"+i.toString()),l+=p(c,d.value))}for(var v in o){var d,c="*"+v;(d=m(v,o[v],!0))&&(0<(i=s(d.value,d.kind,d.propertyType))&&(c=c+"*"+i.toString()),l+=p(c,d.value))}return n+"t.js?"+l},Object.defineProperty(e,"__esModule",{value:!0})});
</script>
<script src="https://js.monitor.azure.com/next/ext/ai.prfmm-mgr.2.js"></script>
<script src="../../../common/Tests/External/require-2.2.0.js"></script>
<script src="../../../common/Tests/External/require-2.3.6.js"></script>
<script src="../../../common/Tests/Selenium/ModuleLoader.js"></script>
<script src="../../../common/Tests/Selenium/SimpleSyncPromise.js"></script>
<script>
var modules = new ModuleLoader({
baseUrl: '../',
paths: {
qunit: "../../common/Tests/External/qunit-1.23.1",
"whatwg-fetch": "../../common/Tests/External/whatwg-fetch.3.0.0",
qunit: "../../common/Tests/External/qunit-2.9.3",
"whatwg-fetch": "../../common/Tests/External/whatwg-fetch.3.6.2",
}
});

Просмотреть файл

@ -1,7 +1,10 @@
import { AITestClass, Assert } from "@microsoft/ai-test-framework";
import { AnalyticsPluginIdentifier, BreezeChannelIdentifier, DEFAULT_BREEZE_ENDPOINT, DisabledPropertyName, DistributedTracingModes, PropertiesPluginIdentifier, RequestHeaders, SeverityLevel } from "@microsoft/applicationinsights-common";
import { addEventHandler, eventOff, eventOn, generateW3CId, LoggingSeverity, mergeEvtNamespace, objForEachKey, removeEventHandler, strUndefined } from "@microsoft/applicationinsights-core-js";
import { Snippet } from "../../../src/Snippet";
import {
AnalyticsPluginIdentifier, BreezeChannelIdentifier, DEFAULT_BREEZE_ENDPOINT, DisabledPropertyName,
DistributedTracingModes, PropertiesPluginIdentifier, RequestHeaders, SeverityLevel
} from "@microsoft/applicationinsights-common";
import { dumpObj, LoggingSeverity, objForEachKey, objKeys, strUndefined } from "@microsoft/applicationinsights-core-js";
import { Snippet } from "../../../src/Initialization";
declare var define;
@ -118,9 +121,10 @@ export class CdnPackagingChecks extends AITestClass {
Assert.equal(theExports.AnalyticsPluginIdentifier, AnalyticsPluginIdentifier, "AnalyticsPluginIdentifier value");
}
private _validateExports(text: string, format: CdnFormat) {
private _validateExportsAsModule(text: string, format: CdnFormat) {
let orgExports = exports;
let orgDefine = define;
try {
// remove any previously registered bundle
@ -132,38 +136,51 @@ export class CdnPackagingChecks extends AITestClass {
// Remove any "exports"
exports = {};
// Used to simulate loading a cjs module
let cjsModule = this["_cjsModule"] = {};
// Used to simulate globals without overriding them
let theExports = {};
let hostValues = this["_hostValues"] = {
global: {},
globalThis: undefined,
exports: theExports,
module: {
exports: theExports
},
define: undefined
};
// "process" the script
eval(text);
if (format == CdnFormat.Umd) {
// Because "exports" exists then no namespace is expected
let microsoft: any = window["Microsoft"];
Assert.equal(undefined, microsoft, "global Microsoft namespace does not exists");
Assert.equal(undefined, cjsModule["Microsoft"], "global not added to cjs exports");
this._validateExpectedExports(exports);
// This test should not be overriding the real globals
Assert.equal(0, objKeys(exports || {}), "The exports should not have been changed");
Assert.equal(undefined, define, "define should not have been exposed");
Assert.equal(undefined, window["Microsoft"], "The global window[\"Microsoft\"] should not have been defined");
Assert.equal(undefined, exports["Microsoft"], "global not added to exports");
Assert.equal(undefined, this["Microsoft"], "The this should not have been changed Microsoft namespace does not exists");
if (format == CdnFormat.Umd) {
// Because "exports" exists as a module then no namespace is expected
Assert.equal(undefined, hostValues.global["Microsoft"], "global Microsoft namespace does not exists");
Assert.equal(undefined, hostValues.exports["Microsoft"], "global not added to cjs exports");
this._validateExpectedExports(hostValues.exports);
} else if (format === CdnFormat.Gbl) {
let microsoft: any = window["Microsoft"];
Assert.equal(undefined, microsoft, "global Microsoft namespace does not exists");
Assert.equal(undefined, exports["Microsoft"], "global not added to exports");
Assert.equal(undefined, cjsModule["Microsoft"], "global not added to cjs exports");
microsoft = this["Microsoft"];
let microsoft: any = hostValues.global["Microsoft"];
Assert.equal(0, objKeys(hostValues.exports || {}), "The exports should not have been changed");
Assert.ok(microsoft, "Microsoft namespace exists on this");
Assert.ok(microsoft.ApplicationInsights, "Microsoft namespace exists");
this._validateExpectedExports(microsoft.ApplicationInsights);
} else if (format === CdnFormat.CommonJs) {
// There is no namespace for common js
let microsoft: any = window["Microsoft"];
let microsoft: any = hostValues.global["Microsoft"];
Assert.equal(undefined, microsoft, "global Microsoft namespace does not exists");
Assert.equal(undefined, exports["Microsoft"], "global Microsoft namespace does not exist on exports");
Assert.equal(undefined, hostValues.exports["Microsoft"], "global Microsoft namespace does not exist on exports");
this._validateExpectedExports(cjsModule);
this._validateExpectedExports(hostValues.exports);
}
} catch (e) {
Assert.ok(false, dumpObj(e));
} finally {
if (orgExports) {
exports = orgExports;
@ -192,17 +209,35 @@ export class CdnPackagingChecks extends AITestClass {
// Remove any "exports"
exports = undefined;
// Used to simulate loading a cjs module
let cjsModule = this["_cjsModule"] = {};
// Used to simulate globals without overriding them
let hostValues = this["_hostValues"] = {
global: {},
globalThis: undefined,
exports: undefined as any, // Don't provide an "exports"
module: undefined,
define: undefined
};
if (format === CdnFormat.CommonJs) {
// CommonJs always needs the "exports" defined
hostValues.exports = {};
}
// "process" the script
eval(text);
// This test should not be overriding the real globals
Assert.equal(0, objKeys(exports || {}), "The exports should not have been changed");
Assert.equal(undefined, define, "define should not have been exposed");
Assert.equal(undefined, window["Microsoft"], "The global window[\"Microsoft\"] should not have been defined");
Assert.equal(undefined, exports, "global not added to exports");
Assert.equal(undefined, this["Microsoft"], "The this should not have been changed Microsoft namespace does not exists");
if (format == CdnFormat.Umd) {
// Because we are simulating no "exports" then there should be a global namespace defined
Assert.equal(undefined, exports, "No global exports should have been defined");
Assert.equal(undefined, cjsModule["Microsoft"], "global not added to cjs exports");
Assert.equal(undefined, hostValues.exports, "No global exports should have been defined");
let microsoft: any = window["Microsoft"];
let microsoft: any = hostValues.global["Microsoft"];
Assert.ok(microsoft, "Microsoft namespace exists");
Assert.ok(microsoft.ApplicationInsights, "Microsoft namespace exists");
@ -210,22 +245,211 @@ export class CdnPackagingChecks extends AITestClass {
} else if (format === CdnFormat.Gbl) {
let microsoft: any = window["Microsoft"];
Assert.equal(undefined, microsoft, "global Microsoft namespace does not exists");
Assert.equal(undefined, exports, "global not added to exports");
Assert.equal(undefined, cjsModule["Microsoft"], "global not added to cjs exports");
Assert.equal(undefined, hostValues.exports, "global not added to exports");
microsoft = this["Microsoft"];
microsoft = hostValues.global["Microsoft"];
Assert.ok(microsoft, "Microsoft namespace exists on this");
Assert.ok(microsoft.ApplicationInsights, "Microsoft namespace exists");
this._validateExpectedExports(microsoft.ApplicationInsights);
} else if (format === CdnFormat.CommonJs) {
// There is no namespace for common js
let microsoft: any = hostValues.global["Microsoft"];
Assert.equal(undefined, microsoft, "global Microsoft namespace does not exists");
this._validateExpectedExports(hostValues.exports);
}
} catch (e) {
Assert.ok(false, dumpObj(e));
} finally {
if (orgExports) {
exports = orgExports;
} else {
exports = undefined;
}
if (orgDefine) {
define = orgDefine;
} else {
define = undefined;
}
}
}
private _validateExportsAsDefine(text: string, format: CdnFormat) {
let orgExports = window.exports;
let orgDefine = define;
try {
// remove any previously registered bundle
delete window["Microsoft"];
// Hide define()
define = undefined;
// Remove any "exports"
exports = undefined;
let simulatedDefine = (names: string[], factory) => {
QUnit.assert.ok(false, "Not tagged as 'amd' so should not be called");
}
// Used to simulate globals without overriding them
let hostValues = this["_hostValues"] = {
global: {},
globalThis: undefined,
exports: undefined as any, // Don't provide an "exports"
module: undefined,
define: simulatedDefine
};
if (format === CdnFormat.CommonJs) {
// CommonJs always needs the "exports" defined
hostValues.exports = {};
}
// "process" the script
eval(text);
// This test should not be overriding the real globals
Assert.equal(0, objKeys(exports || {}), "The exports should not have been changed");
Assert.equal(undefined, define, "define should not have been exposed");
Assert.equal(undefined, window["Microsoft"], "The global window[\"Microsoft\"] should not have been defined");
Assert.equal(undefined, exports, "global not added to exports");
Assert.equal(undefined, this["Microsoft"], "The this should not have been changed Microsoft namespace does not exists");
if (format == CdnFormat.Umd) {
// Because we are simulating no "exports" then there should be a global namespace defined
Assert.equal(undefined, hostValues.exports, "No global exports should have been defined");
let microsoft: any = hostValues.global["Microsoft"];
Assert.ok(microsoft, "Microsoft namespace exists");
Assert.ok(microsoft.ApplicationInsights, "Microsoft namespace exists");
this._validateExpectedExports(microsoft.ApplicationInsights);
} else if (format === CdnFormat.Gbl) {
let microsoft: any = window["Microsoft"];
Assert.equal(undefined, microsoft, "global Microsoft namespace does not exists");
Assert.equal(undefined, exports, "global not added to exports");
Assert.equal(undefined, hostValues.exports, "global not added to exports");
microsoft = hostValues.global["Microsoft"];
Assert.ok(microsoft, "Microsoft namespace exists on this");
Assert.ok(microsoft.ApplicationInsights, "Microsoft namespace exists");
this._validateExpectedExports(cjsModule);
this._validateExpectedExports(microsoft.ApplicationInsights);
} else if (format === CdnFormat.CommonJs) {
// There is no namespace for common js
let microsoft: any = hostValues.global["Microsoft"];
Assert.equal(undefined, microsoft, "global Microsoft namespace does not exists");
this._validateExpectedExports(hostValues.exports);
}
} catch (e) {
Assert.ok(false, dumpObj(e));
} finally {
if (orgExports) {
exports = orgExports;
} else {
exports = undefined;
}
if (orgDefine) {
define = orgDefine;
} else {
define = undefined;
}
}
}
private _validateExportsAsAmdDefine(text: string, format: CdnFormat) {
let orgExports = window.exports;
let orgDefine = define;
try {
// remove any previously registered bundle
delete window["Microsoft"];
// Hide define()
define = undefined;
// Remove any "exports"
exports = undefined;
let defineCalled = false;
let theNames: string[];
let theFactory = null;
let simulatedDefine = (names: string[], factory) => {
defineCalled = true;
theNames = names;
theFactory = factory;
}
// Tag the function
simulatedDefine["amd"] = true;
// Used to simulate globals without overriding them
let hostValues = this["_hostValues"] = {
global: {},
globalThis: undefined,
exports: undefined as any, // Don't provide an "exports"
module: undefined,
define: simulatedDefine
};
if (format === CdnFormat.CommonJs) {
// CommonJs always needs the "exports" defined
hostValues.exports = {};
}
// "process" the script
eval(text);
// This test should not be overriding the real globals
Assert.equal(0, objKeys(exports || {}), "The exports should not have been changed");
Assert.equal(undefined, define, "define should not have been exposed");
Assert.equal(undefined, window["Microsoft"], "The global window[\"Microsoft\"] should not have been defined");
Assert.equal(undefined, exports, "global not added to exports");
Assert.equal(undefined, this["Microsoft"], "The this should not have been changed Microsoft namespace does not exists");
if (format == CdnFormat.Umd) {
// Because we are simulating no "exports" then there should be a global namespace defined
Assert.equal(undefined, hostValues.exports, "No global exports should have been defined");
Assert.equal(undefined, hostValues.global["Microsoft"], "Microsoft namespace should not have been defined");
let microsoft: any = hostValues.global["Microsoft"];
Assert.equal(undefined, microsoft, "Microsoft namespace does not exist on the global");
Assert.equal(true, defineCalled, "Validate that define was called");
Assert.ok(theNames, "Make sure names was populated");
Assert.equal(1, theNames.length, "Check the provided names")
Assert.equal("exports", theNames[0], "Check the provided name")
let theExports = {};
Assert.ok(theFactory, "Make sure the factory was provided");
theFactory(theExports);
microsoft = theExports["Microsoft"];
Assert.equal(undefined, microsoft, "Microsoft namespace does not exist on the exports");
this._validateExpectedExports(theExports);
} else if (format === CdnFormat.Gbl) {
let microsoft: any = window["Microsoft"];
Assert.equal(undefined, microsoft, "global Microsoft namespace does not exists");
Assert.equal(undefined, hostValues.exports, "global not added to exports");
microsoft = hostValues.global["Microsoft"];
Assert.ok(microsoft, "Microsoft namespace exists on this");
Assert.ok(microsoft.ApplicationInsights, "Microsoft namespace exists");
Assert.equal(false, defineCalled, "Validate that define was not called");
this._validateExpectedExports(microsoft.ApplicationInsights);
} else if (format === CdnFormat.CommonJs) {
// There is no namespace for common js
let microsoft: any = hostValues.global["Microsoft"];
Assert.equal(undefined, microsoft, "global Microsoft namespace does not exists");
Assert.equal(false, defineCalled, "Validate that define was not called");
this._validateExpectedExports(hostValues.exports);
}
} catch (e) {
Assert.ok(false, dumpObj(e));
} finally {
if (orgExports) {
exports = orgExports;
@ -254,13 +478,25 @@ export class CdnPackagingChecks extends AITestClass {
return;
} else {
return response.text().then(text => {
if (format === CdnFormat.CommonJs) {
// Wrap commonJs in a closure so the global space is not polluted
text = "(function(exports) {" + text + "})(this._cjsModule);";
}
// Wrap in a closure so the global space is not polluted
text = "(function(values) {\n" +
"function init(hostValues) {\n" +
"console.log(\"initializing\");" +
"console.log(JSON.stringify(this));\n" +
"let globalThis = hostValues.globalThis;\n" +
"let exports = hostValues.exports;\n" +
"let module = hostValues.module;\n" +
"let define = hostValues.define;\n" +
"console.log(\"Now running CDN script\");" +
text + "\n" +
"}\n" +
"init.apply(values.global, [values]);\n" +
"})(this._hostValues)";
this._validateExports(text, format);
this._validateExportsAsModule(text, format);
this._validateGlobalExports(text, format);
this._validateExportsAsDefine(text, format);
this._validateExportsAsAmdDefine(text, format);
}).catch((error: Error) => {
Assert.ok(false, `AISKU bundle ${fileName} response error: ${error}`);
});

Просмотреть файл

@ -5,19 +5,18 @@
<meta charset="utf-8">
<meta http-equiv="Cache-control" content="no-Cache" />
<title>Tests for Application Insights JavaScript AISKU</title>
<link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-1.23.1.css">
<script src="http://sinonjs.org/releases/sinon-2.3.8.js"></script>
<script src="../../../common/Tests/External/require-2.2.0.js"></script>
<link rel="stylesheet" href="../../../common/Tests/External/qunit-2.9.3.css">
<script src="../../../common/Tests/External/sinon-2.3.8.js"></script>
<script src="../../../common/Tests/External/require-2.3.6.js"></script>
<script src="../../../common/Tests/Selenium/ModuleLoader.js"></script>
<script src="../../../common/Tests/Selenium/SimpleSyncPromise.js"></script>
<script>
var modules = new ModuleLoader({
baseUrl: '../',
paths: {
qunit: "../../common/Tests/External/qunit-1.23.1",
qunit: "../../common/Tests/External/qunit-2.9.3",
sinon: "../../common/Tests/External/sinon-7.3.1",
"whatwg-fetch": "../../common/Tests/External/whatwg-fetch.3.0.0",
"whatwg-fetch": "../../common/Tests/External/whatwg-fetch.3.6.2",
}
});

Просмотреть файл

@ -46,7 +46,7 @@
"finalhandler": "^1.1.1",
"grunt": "^1.5.3",
"grunt-cli": "^1.4.3",
"grunt-contrib-qunit": "^5.0.1",
"grunt-contrib-qunit": "^6.2.1",
"@nevware21/grunt-ts-plugin": "^0.4.3",
"@nevware21/grunt-eslint-ts": "^0.2.2",
"globby": "^11.0.0",
@ -59,7 +59,7 @@
"rollup": "^2.32.0",
"selenium-server-standalone-jar": "^3.141.5",
"serve-static": "^1.13.2",
"typescript": "^4.3.4",
"typescript": "^4.9.3",
"tslib": "^2.0.0"
},
"peerDependencies": {
@ -74,7 +74,7 @@
"@microsoft/applicationinsights-core-js": "2.8.9",
"@microsoft/applicationinsights-dependencies-js": "2.8.9",
"@microsoft/applicationinsights-properties-js": "2.8.9",
"@nevware21/ts-utils": "^0.6.0"
"@nevware21/ts-utils": "^0.7.0"
},
"license": "MIT"
}

Просмотреть файл

@ -6,15 +6,24 @@
<!-- import Application Insights JS SDK from CDN -->
<script type="text/javascript">!function(T,l,y){var S=T.location,k="script",D="instrumentationKey",C="ingestionendpoint",I="disableExceptionTracking",E="ai.device.",b="toLowerCase",w="crossOrigin",N="POST",e="appInsightsSDK",t=y.name||"appInsights";(y.name||T[e])&&(T[e]=t);var n=T[t]||function(d){var g=!1,f=!1,m={initialize:!0,queue:[],sv:"5",version:2,config:d};function v(e,t){var n={},a="Browser";return n[E+"id"]=a[b](),n[E+"type"]=a,n["ai.operation.name"]=S&&S.pathname||"_unknown_",n["ai.internal.sdkVersion"]="javascript:snippet_"+(m.sv||m.version),{time:function(){var e=new Date;function t(e){var t=""+e;return 1===t.length&&(t="0"+t),t}return e.getUTCFullYear()+"-"+t(1+e.getUTCMonth())+"-"+t(e.getUTCDate())+"T"+t(e.getUTCHours())+":"+t(e.getUTCMinutes())+":"+t(e.getUTCSeconds())+"."+((e.getUTCMilliseconds()/1e3).toFixed(3)+"").slice(2,5)+"Z"}(),iKey:e,name:"Microsoft.ApplicationInsights."+e.replace(/-/g,"")+"."+t,sampleRate:100,tags:n,data:{baseData:{ver:2}}}}var h=d.url||y.src;if(h){function a(e){var t,n,a,i,r,o,s,c,u,p,l;g=!0,m.queue=[],f||(f=!0,t=h,s=function(){var e={},t=d.connectionString;if(t)for(var n=t.split(";"),a=0;a<n.length;a++){var i=n[a].split("=");2===i.length&&(e[i[0][b]()]=i[1])}if(!e[C]){var r=e.endpointsuffix,o=r?e.location:null;e[C]="https://"+(o?o+".":"")+"dc."+(r||"services.visualstudio.com")}return e}(),c=s[D]||d[D]||"",u=s[C],p=u?u+"/v2/track":d.endpointUrl,(l=[]).push((n="SDK LOAD Failure: Failed to load Application Insights SDK script (See stack for details)",a=t,i=p,(o=(r=v(c,"Exception")).data).baseType="ExceptionData",o.baseData.exceptions=[{typeName:"SDKLoadFailed",message:n.replace(/\./g,"-"),hasFullStack:!1,stack:n+"\nSnippet failed to load ["+a+"] -- Telemetry is disabled\nHelp Link: https://go.microsoft.com/fwlink/?linkid=2128109\nHost: "+(S&&S.pathname||"_unknown_")+"\nEndpoint: "+i,parsedStack:[]}],r)),l.push(function(e,t,n,a){var i=v(c,"Message"),r=i.data;r.baseType="MessageData";var o=r.baseData;return o.message='AI (Internal): 99 message:"'+("SDK LOAD Failure: Failed to load Application Insights SDK script (See stack for details) ("+n+")").replace(/\"/g,"")+'"',o.properties={endpoint:a},i}(0,0,t,p)),function(e,t){if(JSON){var n=T.fetch;if(n&&!y.useXhr)n(t,{method:N,body:JSON.stringify(e),mode:"cors"});else if(XMLHttpRequest){var a=new XMLHttpRequest;a.open(N,t),a.setRequestHeader("Content-type","application/json"),a.send(JSON.stringify(e))}}}(l,p))}function i(e,t){f||setTimeout(function(){!t&&m.core||a()},500)}var e=function(){var n=l.createElement(k);n.src=h;var e=y[w];return!e&&""!==e||"undefined"==n[w]||(n[w]=e),n.onload=i,n.onerror=a,n.onreadystatechange=function(e,t){"loaded"!==n.readyState&&"complete"!==n.readyState||i(0,t)},n}();y.ld<0?l.getElementsByTagName("head")[0].appendChild(e):setTimeout(function(){l.getElementsByTagName(k)[0].parentNode.appendChild(e)},y.ld||0)}try{m.cookie=l.cookie}catch(p){}function t(e){for(;e.length;)!function(t){m[t]=function(){var e=arguments;g||m.queue.push(function(){m[t].apply(m,e)})}}(e.pop())}var n="track",r="TrackPage",o="TrackEvent";t([n+"Event",n+"PageView",n+"Exception",n+"Trace",n+"DependencyData",n+"Metric",n+"PageViewPerformance","start"+r,"stop"+r,"start"+o,"stop"+o,"addTelemetryInitializer","setAuthenticatedUserContext","clearAuthenticatedUserContext","flush"]),m.SeverityLevel={Verbose:0,Information:1,Warning:2,Error:3,Critical:4};var s=(d.extensionConfig||{}).ApplicationInsightsAnalytics||{};if(!0!==d[I]&&!0!==s[I]){var c="onerror";t(["_"+c]);var u=T[c];T[c]=function(e,t,n,a,i){var r=u&&u(e,t,n,a,i);return!0!==r&&m["_"+c]({message:e,url:t,lineNumber:n,columnNumber:a,error:i}),r},d.autoExceptionInstrumented=!0}return m}(y.cfg);function a(){y.onInit&&y.onInit(n)}(T[t]=n).queue&&0===n.queue.length?(n.queue.push(a),n.trackPageView({})):a()}(window,document,{
src: "https://js.monitor.azure.com/scripts/b/ai.2.min.js", // The SDK URL Source for the CDN
//src: "../../browser/ai.2.min.js", // The URL Source for the local build
//src: "http://localhost:9001/AISKU/browser/ai.2.min.js", // The URL Source for the local build
crossOrigin: "anonymous", // When supplied this will add the provided value as the cross origin attribute on the script tag
cfg: { // Application Insights Configuration
instrumentationKey: "INSTRUMENTATION_KEY"
instrumentationKey: "INSTRUMENTATION_KEY",
disableIKeyValidation: true
}});
</script>
</head>
<body>
<h1>Hello World!</h1>
<!-- trackException manual tests
<button onclick="javascript: throw 'String Error'">Throw String Exception</button>
<button onclick="javascript: appInsights.trackException({ exception: 'String Error' })">trackException with String as the exception</button>
<button onclick="javascript: try { throw 'String Error'; } catch(e) { appInsights.trackException({exception: e})}">trackException with try / catch</button>
<button onclick="javascript: appInsights.trackException('String Error')">trackException with String</button>
<button onclick="javascript: try { throw 'String Error'; } catch(e) { appInsights.trackException(null)}">trackException with null</button>
-->
</body>
</html>

Просмотреть файл

@ -1,7 +1,9 @@
import { AISKULightSizeCheck } from "./AISKULightSize.Tests";
import { ApplicationInsightsDynamicConfigTests } from "./dynamicconfig.tests";
import { ApplicationInsightsConfigTests } from "./config.tests";
export function runTests() {
new AISKULightSizeCheck().registerTests();
new ApplicationInsightsDynamicConfigTests().registerTests();
new ApplicationInsightsConfigTests().registerTests();
}

Просмотреть файл

@ -0,0 +1,183 @@
import { AITestClass, Assert } from "@microsoft/ai-test-framework";
import { newId } from "@microsoft/applicationinsights-core-js";
import { ApplicationInsights} from "../../../src/index";
export class ApplicationInsightsConfigTests extends AITestClass {
private readonly _instrumentationKey = "b7170927-2d1c-44f1-acec-59f4e1751c11";
private readonly _endpoint = "endpoint"
private readonly _connectionString = `InstrumentationKey=${this._instrumentationKey};ingestionendpoint=${this._endpoint}`;
private readonly _iKey = "testKey";
private _sessionPrefix: string = newId();
static registerTests: any;
constructor(testName?: string) {
super(testName || "ApplicationInsightsAISKULightTests");
}
protected _getTestConfig(sessionPrefix: string, ikey?: boolean, cs?: boolean) {
return {
instrumentationKey: ikey? this._iKey : undefined,
connectionString: cs? this._connectionString : undefined,
namePrefix: sessionPrefix
};
}
public testInitialize() {
super.testInitialize();
}
public testCleanup() {
super.testCleanup();
}
public testFinishedCleanup(): void {
console.log("* testCleanup(" + (AITestClass.currentTestInfo ? AITestClass.currentTestInfo.name : "<null>") + ")");
}
public registerTests() {
this.addConfigTests();
this.addApiTests();
}
private addConfigTests(): void {
this.testCase({
name: "ConfigTests: ApplicationInsights config should set default endpoint",
test: () => {
let expectedConnectionString = `InstrumentationKey=${this._instrumentationKey}`
let _config = {
connectionString: expectedConnectionString,
namePrefix:this._sessionPrefix
};
Assert.ok(_config)
let ai = new ApplicationInsights(_config);
this.onDone(() =>{
ai.unload(false);
});
Assert.ok(ai, "ApplicationInsights light Instance is initialized");
let config = ai.config;
let expectedIkey = this._instrumentationKey;
let expectedEndpointUrl = "https://dc.services.visualstudio.com/v2/track";
let expectedLoggingLevel = 10000;
Assert.ok(config, "ApplicationInsights Light config exists");
Assert.equal(expectedConnectionString, config.connectionString, "connection string is set");
Assert.equal(expectedIkey, config.instrumentationKey, "ikey is set");
Assert.equal(expectedLoggingLevel, config.diagnosticLogInterval, "diagnosticLogInterval is set to 1000 by default");
Assert.equal(expectedEndpointUrl, config.endpointUrl, "endpoint url is set from connection string");
}
});
this.testCase({
name: "ConfigTests: ApplicationInsights config works correctly with connection string",
test: () => {
let _config = this._getTestConfig(this._sessionPrefix, false, true);
Assert.ok(_config)
let ai = new ApplicationInsights(_config);
this.onDone(() =>{
ai.unload(false);
});
Assert.ok(ai, "ApplicationInsights light Instance is initialized");
let config = ai.config;
let expectedIkey = this._instrumentationKey;
let expectedConnectionString = this._connectionString;
let expectedEndpointUrl = `${this._endpoint}/v2/track`;
let expectedLoggingLevel = 10000;
Assert.ok(config, "ApplicationInsights Light config exists");
Assert.equal(expectedConnectionString, config.connectionString, "connection string is set");
Assert.equal(expectedIkey, config.instrumentationKey, "ikey is set");
Assert.equal(expectedLoggingLevel, config.diagnosticLogInterval, "diagnosticLogInterval is set to 1000 by default");
Assert.equal(expectedEndpointUrl, config.endpointUrl, "endpoint url is set from connection string");
}
});
this.testCase({
name: "ConfigTests: ApplicationInsights config works correctly with connection string and Ikey",
useFakeTimers: true,
test: () => {
let _config = this._getTestConfig(this._sessionPrefix, true, true);
Assert.ok(_config)
let ai = new ApplicationInsights(_config);
this.onDone(() =>{
ai.unload(false);
});
Assert.ok(ai, "ApplicationInsights light Instance is initialized");
Assert.ok(ai);
let config = ai.config;
let expectedIkey = this._instrumentationKey;
let expectedConnectionString = this._connectionString;
let expectedEndpointUrl = `${this._endpoint}/v2/track`;
let expectedLoggingLevel = 10000;
Assert.ok(config, "ApplicationInsights Light config exists");
Assert.equal(expectedConnectionString, config.connectionString, "connection string is set");
Assert.equal(expectedIkey, config.instrumentationKey, "ikey is set from connection string");
Assert.equal(expectedLoggingLevel, config.diagnosticLogInterval, "diagnosticLogInterval is set to 1000 by default");
Assert.equal(expectedEndpointUrl, config.endpointUrl, "endpoint url is set from connection string");
}
});
this.testCase({
name: "ConfigTests: ApplicationInsights config works correctly with ikey",
useFakeTimers: true,
test: () => {
let _config = this._getTestConfig(this._sessionPrefix, true, false);
Assert.ok(_config)
let ai = new ApplicationInsights(_config);
this.onDone(() =>{
ai.unload(false);
});
Assert.ok(ai, "ApplicationInsights light Instance is initialized");
Assert.ok(ai);
let config = ai.config;
let expectedIkey = this._iKey;
let expectedLoggingLevel = 10000;
Assert.ok(config, "ApplicationInsights Light config exists");
Assert.ok(!config.connectionString, "connection string shoud not set");
Assert.equal(expectedIkey, config.instrumentationKey, "ikey is set");
Assert.equal(expectedLoggingLevel, config.diagnosticLogInterval, "diagnosticLogInterval is set to 1000 by default");
Assert.ok(!config.endpointUrl, "endpoint url should not set from ikey");
}
});
this.testCase({
name: "ConfigTests: ApplicationInsights sholuld throw error when no ikey and connection string provided",
useFakeTimers: true,
test: () => {
try {
let _config = this._getTestConfig(this._sessionPrefix, false, false);
Assert.ok(_config)
let ai = new ApplicationInsights(_config);
this.onDone(() =>{
ai.unload(false);
});
Assert.ok(false, "ApplicationInsights light Instance should not be initialized");
Assert.ok(ai);
} catch(e) {
Assert.ok(true, "error should be thrown");
}
}
});
}
public addApiTests(): void {
this.testCase({
name: "DynamicConfigTests: Public Members exist",
test: () => {
let _config = this._getTestConfig(this._sessionPrefix, true, false);
Assert.ok(_config)
let ai = new ApplicationInsights(_config);
this.onDone(() =>{
ai.unload(false);
});
Assert.ok(ai, "ApplicationInsights light Instance is initialized");
let trackMethod = "track";
let flushMethod = "flush";
Assert.ok(ai[trackMethod], `${trackMethod} method exists`);
Assert.equal("function", typeof ai["track"], `${trackMethod} is a function`);
Assert.ok(ai[flushMethod], `${flushMethod} method exists`);
Assert.equal("function", typeof ai[flushMethod], `${flushMethod} is a function`);
}
});
}
}

Просмотреть файл

@ -9,15 +9,14 @@
<script src="http://sinonjs.org/releases/sinon-2.3.8.js"></script>
<script src="../../../common/Tests/External/require-2.2.0.js"></script>
<script src="../../../common/Tests/Selenium/ModuleLoader.js"></script>
<script src="../../../common/Tests/Selenium/SimpleSyncPromise.js"></script>
<script>
var modules = new ModuleLoader({
baseUrl: '../',
paths: {
qunit: "../../common/Tests/External/qunit-1.23.1",
qunit: "../../common/Tests/External/qunit-2.9.3",
sinon: "../../common/Tests/External/sinon-7.3.1",
"whatwg-fetch": "../../common/Tests/External/whatwg-fetch.3.0.0",
"whatwg-fetch": "../../common/Tests/External/whatwg-fetch.3.6.2",
}
});

Просмотреть файл

@ -33,7 +33,7 @@
"@microsoft/api-extractor": "^7.18.1",
"grunt": "^1.5.3",
"grunt-cli": "^1.4.3",
"grunt-contrib-qunit": "^5.0.1",
"grunt-contrib-qunit": "^6.2.1",
"@nevware21/grunt-ts-plugin": "^0.4.3",
"@nevware21/grunt-eslint-ts": "^0.2.2",
"globby": "^11.0.0",
@ -44,7 +44,7 @@
"@rollup/plugin-replace": "^2.3.3",
"rollup-plugin-cleanup": "^3.2.1",
"rollup": "^2.32.0",
"typescript": "^4.3.4",
"typescript": "^4.9.3",
"tslib": "^2.0.0"
},
"peerDependencies": {
@ -56,7 +56,7 @@
"@microsoft/applicationinsights-common": "2.8.9",
"@microsoft/applicationinsights-channel-js": "2.8.9",
"@microsoft/applicationinsights-core-js": "2.8.9",
"@nevware21/ts-utils": "^0.6.0"
"@nevware21/ts-utils": "^0.7.0"
},
"license": "MIT"
}

Просмотреть файл

@ -8,7 +8,7 @@ import {
AppInsightsCore, IConfigDefaults, IConfiguration, IDynamicConfigHandler, ILoadedPlugin, IPlugin, ITelemetryItem, ITelemetryPlugin,
IUnloadHook, UnloadHandler, WatcherFunction, createDynamicConfig, onConfigChange, proxyFunctions
} from "@microsoft/applicationinsights-core-js";
import { objDefineProp } from "@nevware21/ts-utils";
import { isNullOrUndefined, objDefineProp, throwError } from "@nevware21/ts-utils";
const defaultConfigValues: IConfigDefaults<IConfiguration> = {
diagnosticLogInterval: { isVal: _chkDiagLevel, v: 10000 }
@ -35,7 +35,22 @@ export class ApplicationInsights {
let core = new AppInsightsCore();
let _config: IConfiguration & IConfig;
// initialize the queue and config in case they are undefined
if (
isNullOrUndefined(config) ||
(isNullOrUndefined(config.instrumentationKey) && isNullOrUndefined(config.connectionString))
) {
throwError("Invalid input configuration");
}
dynamicProto(ApplicationInsights, this, (_self) => {
if (config.connectionString) {
const cs = parseConnectionString(config.connectionString);
const ingest = cs.ingestionendpoint;
config.endpointUrl = ingest ? (ingest + DEFAULT_BREEZE_PATH) : config.endpointUrl; // only add /v2/track when from connectionstring
config.instrumentationKey = cs.instrumentationkey || config.instrumentationKey;
}
// Define _self.config
objDefineProp(_self, "config", {
@ -191,8 +206,8 @@ export {
proxyFunctions,
IPlugin,
ITelemetryPlugin
} from "@microsoft/applicationinsights-core-js";
export {
SeverityLevel,
eSeverityLevel,

Просмотреть файл

@ -5,18 +5,17 @@
<meta charset="utf-8">
<meta http-equiv="Cache-control" content="no-Cache" />
<title>Tests for Application Insights JavaScript API</title>
<link rel="stylesheet" href="../../../common/Tests//External/qunit-2.9.1.css">
<link rel="stylesheet" href="../../../common/Tests/External/qunit-2.9.3.css">
<!-- <script src="../../../common/Tests/External/sinon-7.3.1.js"></script> -->
<script src="../../../common/Tests/External/require-2.3.6.js"></script>
<script src="../../../common/Tests/Selenium/ModuleLoader.js"></script>
<script src="../../../common/Tests/Selenium/SimpleSyncPromise.js"></script>
<script>
var modules = new ModuleLoader({
baseUrl: '../',
paths: {
qunit: "../../common/Tests/External/qunit-1.23.1",
qunit: "../../common/Tests/External/qunit-2.9.3",
sinon: "../../common/Tests/External/sinon-7.3.1",
"whatwg-fetch": "../../common/Tests/External/whatwg-fetch.3.0.0"
"whatwg-fetch": "../../common/Tests/External/whatwg-fetch.3.6.2"
}
});

Просмотреть файл

@ -40,7 +40,7 @@
"@rollup/plugin-replace": "^2.3.3",
"rollup-plugin-cleanup": "^3.2.1",
"rollup": "^2.32.0",
"typescript": "^4.3.4",
"typescript": "^4.9.3",
"tslib": "^2.0.0",
"sinon": "^7.3.1"
},
@ -52,7 +52,7 @@
"@microsoft/applicationinsights-shims": "2.0.2",
"@microsoft/applicationinsights-core-js": "2.8.9",
"@microsoft/applicationinsights-common": "2.8.9",
"@nevware21/ts-utils": "^0.6.0"
"@nevware21/ts-utils": "^0.7.0"
},
"license": "MIT"
}

Просмотреть файл

@ -40,7 +40,7 @@
"@rollup/plugin-replace": "^2.3.3",
"rollup-plugin-cleanup": "^3.2.1",
"rollup": "^2.32.0",
"typescript": "^4.3.4",
"typescript": "^4.9.3",
"tslib": "^2.0.0",
"sinon": "^7.3.1"
},
@ -52,7 +52,7 @@
"@microsoft/applicationinsights-shims": "2.0.2",
"@microsoft/applicationinsights-core-js": "2.8.9",
"@microsoft/applicationinsights-common": "2.8.9",
"@nevware21/ts-utils": "^0.6.0"
"@nevware21/ts-utils": "^0.7.0"
},
"license": "MIT"
}

525
common/Tests/External/qunit-2.9.3.css поставляемый Normal file
Просмотреть файл

@ -0,0 +1,525 @@
/*!
* QUnit 2.19.3
* https://qunitjs.com/
*
* Copyright OpenJS Foundation and other contributors
* Released under the MIT license
* https://jquery.org/license
*/
/** Font Family and Sizes */
#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-filteredTest, #qunit-userAgent, #qunit-testresult {
font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif;
}
#qunit-testrunner-toolbar, #qunit-filteredTest, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
#qunit-tests { font-size: smaller; }
/** Resets */
#qunit-tests, #qunit-header, #qunit-banner, #qunit-filteredTest, #qunit-userAgent, #qunit-testresult, #qunit-modulefilter {
margin: 0;
padding: 0;
}
/* Style our buttons in a simple way, uninfluenced by the styles
the tested app might load. Don't affect buttons in #qunit-fixture!
https://github.com/qunitjs/qunit/pull/1395
https://github.com/qunitjs/qunit/issues/1437 */
#qunit-testrunner-toolbar button,
#qunit-testresult button {
all: unset; /* best effort, modern browsers only */
font: inherit;
color: initial;
border: initial;
background-color: buttonface;
padding: 0 4px;
}
/** Fixed headers with scrollable tests */
@supports (display: flex) or (display: -webkit-box) {
@media (min-height: 500px) {
#qunit {
position: fixed;
left: 0px;
right: 0px;
top: 0px;
bottom: 0px;
padding: 8px;
display: -webkit-box;
display: flex;
flex-direction: column;
}
#qunit-tests {
overflow: scroll;
}
#qunit-banner {
flex: 5px 0 0;
}
}
}
/** Header (excluding toolbar) */
#qunit-header {
padding: 0.5em 0 0.5em 1em;
color: #C2CCD1;
background-color: #0D3349;
font-size: 1.5em;
line-height: 1em;
font-weight: 400;
border-radius: 5px 5px 0 0;
}
#qunit-header a {
text-decoration: none;
color: inherit;
}
#qunit-header a:hover,
#qunit-header a:focus {
color: #FFF;
}
#qunit-banner {
height: 5px;
}
#qunit-filteredTest {
padding: 0.5em 1em 0.5em 1em;
color: #366097;
background-color: #F4FF77;
}
#qunit-userAgent {
padding: 0.5em 1em 0.5em 1em;
color: #FFF;
background-color: #2B81AF;
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
}
/** Toolbar */
#qunit-testrunner-toolbar {
padding: 0.5em 1em 0.5em 1em;
color: #5E740B;
background-color: #EEE;
}
#qunit-testrunner-toolbar .clearfix {
height: 0;
clear: both;
}
#qunit-testrunner-toolbar label {
display: inline-block;
}
#qunit-testrunner-toolbar input[type=checkbox],
#qunit-testrunner-toolbar input[type=radio] {
margin: 3px;
vertical-align: -2px;
}
#qunit-testrunner-toolbar input[type=text] {
box-sizing: border-box;
height: 1.6em;
}
#qunit-testrunner-toolbar button,
#qunit-testresult button {
border-radius: .25em;
border: 1px solid #AAA;
background-color: #F8F8F8;
color: #222;
line-height: 1.6;
cursor: pointer;
}
#qunit-testrunner-toolbar button:hover,
#qunit-testresult button:hover {
border-color: #AAA;
background-color: #FFF;
color: #444;
}
#qunit-testrunner-toolbar button:active,
#qunit-testresult button:active {
border-color: #777;
background-color: #CCC;
color: #000;
}
#qunit-testrunner-toolbar button:focus,
#qunit-testresult button:focus {
border-color: #2F68DA;
/* emulate 2px border without a layout shift */
box-shadow: inset 0 0 0 1px #2F68DA
}
#qunit-testrunner-toolbar button:disabled,
#qunit-testresult button:disabled {
border-color: #CCC;
background-color: #CCC;
color: #FFF;
cursor: default;
}
#qunit-toolbar-filters {
float: right;
/* aligning right avoids overflows and inefficient use of space
around the dropdown menu on narrow viewports */
text-align: right;
}
.qunit-url-config,
.qunit-filter,
#qunit-modulefilter {
display: inline-block;
line-height: 2.1em;
text-align: left;
}
.qunit-filter,
#qunit-modulefilter {
position: relative;
margin-left: 1em;
}
.qunit-url-config label {
margin-right: 0.5em;
}
#qunit-modulefilter-search {
box-sizing: border-box;
min-width: 400px;
min-width: min(400px, 80vw);
}
#qunit-modulefilter-search-container {
position: relative;
}
#qunit-modulefilter-search-container:after {
position: absolute;
right: 0.3em;
bottom: 0;
line-height: 100%;
content: "\25bc";
color: black;
}
#qunit-modulefilter-dropdown {
/* align with #qunit-modulefilter-search */
box-sizing: border-box;
min-width: 400px;
min-width: min(400px, 80vw);
max-width: 80vw;
position: absolute;
right: 0;
top: 100%;
margin-top: 2px;
/* ensure that when on a narrow viewports and having only one result,
that #qunit-modulefilter-actions fall outside the dropdown rectangle. */
min-height: 3em;
border: 1px solid #AAA;
border-top-color: transparent;
border-radius: 0 0 .25em .25em;
color: #0D3349;
background-color: #F5F5F5;
z-index: 99;
}
#qunit-modulefilter-actions {
display: block;
overflow: auto;
/* align with #qunit-modulefilter-dropdown-list */
font: smaller/1.5em sans-serif;
}
@media (min-width: 350px) {
#qunit-modulefilter-actions {
position: absolute;
right: 0;
}
}
#qunit-modulefilter-dropdown #qunit-modulefilter-actions > * {
box-sizing: border-box;
max-height: 2.8em;
display: block;
padding: 0.4em;
}
#qunit-modulefilter-dropdown #qunit-modulefilter-actions > button {
float: right;
margin: 0.25em;
}
#qunit-modulefilter-dropdown-list {
margin: 0;
padding: 0;
font: smaller/1.5em sans-serif;
}
#qunit-modulefilter-dropdown-list li {
list-style: none;
}
#qunit-modulefilter-dropdown-list .clickable {
display: block;
padding: 0.25em 0.50em 0.25em 0.15em;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
#qunit-modulefilter-dropdown-list .clickable.checked {
font-weight: bold;
background-color: #E2F0F7;
color: #0D3349;
}
#qunit-modulefilter-dropdown .clickable:hover {
background-color: #FFF;
color: #444;
}
/** Tests: Pass/Fail */
#qunit-tests {
list-style-position: inside;
}
#qunit-tests li {
padding: 0.4em 1em 0.4em 1em;
border-bottom: 1px solid #FFF;
list-style-position: inside;
}
#qunit-tests > li {
display: none;
}
#qunit-tests li.running,
#qunit-tests li.pass,
#qunit-tests li.fail,
#qunit-tests li.skipped,
#qunit-tests li.aborted {
display: list-item;
}
#qunit-tests.hidepass {
position: relative;
}
#qunit-tests.hidepass li.running,
#qunit-tests.hidepass li.pass:not(.todo) {
visibility: hidden;
position: absolute;
width: 0;
height: 0;
padding: 0;
border: 0;
margin: 0;
}
#qunit-tests li strong {
cursor: pointer;
}
#qunit-tests li.skipped strong {
cursor: default;
}
#qunit-tests li a {
padding: 0.5em;
color: inherit;
text-decoration: underline;
}
#qunit-tests li a:hover,
#qunit-tests li a:focus {
color: #0D3349;
}
#qunit-tests li .runtime {
float: right;
font-size: smaller;
}
.qunit-assert-list {
margin-top: 0.5em;
padding: 0.5em;
background-color: #FFF;
border-radius: 5px;
}
.qunit-source {
margin: 0.6em 0 0.3em;
}
.qunit-collapsed {
display: none;
}
#qunit-tests table {
border-collapse: collapse;
margin-top: 0.2em;
}
#qunit-tests th {
text-align: right;
vertical-align: top;
padding: 0 0.5em 0 0;
}
#qunit-tests td {
vertical-align: top;
}
#qunit-tests pre {
margin: 0;
white-space: pre-wrap;
word-wrap: break-word;
}
#qunit-tests del {
color: #374E0C;
background-color: #E0F2BE;
text-decoration: none;
}
#qunit-tests ins {
color: #500;
background-color: #FFCACA;
text-decoration: none;
}
/*** Test Counts */
#qunit-tests b.counts { color: #0D3349; }
#qunit-tests b.passed { color: #5E740B; }
#qunit-tests b.failed { color: #710909; }
#qunit-tests li li {
padding: 5px;
background-color: #FFF;
border-bottom: none;
list-style-position: inside;
}
/*** Passing Styles */
#qunit-tests .pass {
color: #2F68DA;
background-color: #E2F0F7;
}
#qunit-tests .pass .test-name {
color: #366097;
}
#qunit-tests li li.pass {
color: #3C510C;
background-color: #FFF;
border-left: 10px solid #C6E746;
}
#qunit-tests .pass .test-actual,
#qunit-tests .pass .test-expected { color: #999; }
#qunit-banner.qunit-pass { background-color: #C6E746; }
/*** Failing Styles */
#qunit-tests .fail {
color: #000;
background-color: #EE5757;
}
#qunit-tests li li.fail {
color: #710909;
background-color: #FFF;
border-left: 10px solid #EE5757;
white-space: pre;
}
#qunit-tests > li:last-child {
border-radius: 0 0 5px 5px;
}
#qunit-tests .fail .test-actual { color: #EE5757; }
#qunit-tests .fail .test-expected { color: #008000; }
#qunit-banner.qunit-fail { background-color: #EE5757; }
/*** Aborted tests */
#qunit-tests .aborted { color: #000; background-color: orange; }
/*** Skipped tests */
#qunit-tests .skipped {
background-color: #EBECE9;
}
#qunit-tests .qunit-todo-label,
#qunit-tests .qunit-skipped-label {
background-color: #F4FF77;
display: inline-block;
font-style: normal;
color: #366097;
line-height: 1.8em;
padding: 0 0.5em;
margin: -0.4em 0.4em -0.4em 0;
}
#qunit-tests .qunit-todo-label {
background-color: #EEE;
}
/** Result */
#qunit-testresult {
color: #366097;
background-color: #E2F0F7;
border-bottom: 1px solid #FFF;
}
#qunit-testresult a {
color: #2F68DA;
}
#qunit-testresult .clearfix {
height: 0;
clear: both;
}
#qunit-testresult .module-name {
font-weight: 700;
}
#qunit-testresult-display {
padding: 0.5em 1em 0.5em 1em;
width: 85%;
float:left;
}
#qunit-testresult-controls {
padding: 0.5em 1em 0.5em 1em;
width: 10%;
float:left;
}
/** Fixture */
#qunit-fixture {
position: absolute;
top: -10000px;
left: -10000px;
width: 1000px;
height: 1000px;
}

7006
common/Tests/External/qunit-2.9.3.js поставляемый Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

2142
common/Tests/External/require-2.3.6.js поставляемый

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

12410
common/Tests/External/sinon-2.3.8.js поставляемый Normal file

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

620
common/Tests/External/whatwg-fetch.3.6.2.js поставляемый Normal file
Просмотреть файл

@ -0,0 +1,620 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.WHATWGFetch = {})));
}(this, (function (exports) { 'use strict';
var global =
(typeof globalThis !== 'undefined' && globalThis) ||
(typeof self !== 'undefined' && self) ||
(typeof global !== 'undefined' && global);
var support = {
searchParams: 'URLSearchParams' in global,
iterable: 'Symbol' in global && 'iterator' in Symbol,
blob:
'FileReader' in global &&
'Blob' in global &&
(function() {
try {
new Blob();
return true
} catch (e) {
return false
}
})(),
formData: 'FormData' in global,
arrayBuffer: 'ArrayBuffer' in global
};
function isDataView(obj) {
return obj && DataView.prototype.isPrototypeOf(obj)
}
if (support.arrayBuffer) {
var viewClasses = [
'[object Int8Array]',
'[object Uint8Array]',
'[object Uint8ClampedArray]',
'[object Int16Array]',
'[object Uint16Array]',
'[object Int32Array]',
'[object Uint32Array]',
'[object Float32Array]',
'[object Float64Array]'
];
var isArrayBufferView =
ArrayBuffer.isView ||
function(obj) {
return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1
};
}
function normalizeName(name) {
if (typeof name !== 'string') {
name = String(name);
}
if (/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(name) || name === '') {
throw new TypeError('Invalid character in header field name: "' + name + '"')
}
return name.toLowerCase()
}
function normalizeValue(value) {
if (typeof value !== 'string') {
value = String(value);
}
return value
}
// Build a destructive iterator for the value list
function iteratorFor(items) {
var iterator = {
next: function() {
var value = items.shift();
return {done: value === undefined, value: value}
}
};
if (support.iterable) {
iterator[Symbol.iterator] = function() {
return iterator
};
}
return iterator
}
function Headers(headers) {
this.map = {};
if (headers instanceof Headers) {
headers.forEach(function(value, name) {
this.append(name, value);
}, this);
} else if (Array.isArray(headers)) {
headers.forEach(function(header) {
this.append(header[0], header[1]);
}, this);
} else if (headers) {
Object.getOwnPropertyNames(headers).forEach(function(name) {
this.append(name, headers[name]);
}, this);
}
}
Headers.prototype.append = function(name, value) {
name = normalizeName(name);
value = normalizeValue(value);
var oldValue = this.map[name];
this.map[name] = oldValue ? oldValue + ', ' + value : value;
};
Headers.prototype['delete'] = function(name) {
delete this.map[normalizeName(name)];
};
Headers.prototype.get = function(name) {
name = normalizeName(name);
return this.has(name) ? this.map[name] : null
};
Headers.prototype.has = function(name) {
return this.map.hasOwnProperty(normalizeName(name))
};
Headers.prototype.set = function(name, value) {
this.map[normalizeName(name)] = normalizeValue(value);
};
Headers.prototype.forEach = function(callback, thisArg) {
for (var name in this.map) {
if (this.map.hasOwnProperty(name)) {
callback.call(thisArg, this.map[name], name, this);
}
}
};
Headers.prototype.keys = function() {
var items = [];
this.forEach(function(value, name) {
items.push(name);
});
return iteratorFor(items)
};
Headers.prototype.values = function() {
var items = [];
this.forEach(function(value) {
items.push(value);
});
return iteratorFor(items)
};
Headers.prototype.entries = function() {
var items = [];
this.forEach(function(value, name) {
items.push([name, value]);
});
return iteratorFor(items)
};
if (support.iterable) {
Headers.prototype[Symbol.iterator] = Headers.prototype.entries;
}
function consumed(body) {
if (body.bodyUsed) {
return Promise.reject(new TypeError('Already read'))
}
body.bodyUsed = true;
}
function fileReaderReady(reader) {
return new Promise(function(resolve, reject) {
reader.onload = function() {
resolve(reader.result);
};
reader.onerror = function() {
reject(reader.error);
};
})
}
function readBlobAsArrayBuffer(blob) {
var reader = new FileReader();
var promise = fileReaderReady(reader);
reader.readAsArrayBuffer(blob);
return promise
}
function readBlobAsText(blob) {
var reader = new FileReader();
var promise = fileReaderReady(reader);
reader.readAsText(blob);
return promise
}
function readArrayBufferAsText(buf) {
var view = new Uint8Array(buf);
var chars = new Array(view.length);
for (var i = 0; i < view.length; i++) {
chars[i] = String.fromCharCode(view[i]);
}
return chars.join('')
}
function bufferClone(buf) {
if (buf.slice) {
return buf.slice(0)
} else {
var view = new Uint8Array(buf.byteLength);
view.set(new Uint8Array(buf));
return view.buffer
}
}
function Body() {
this.bodyUsed = false;
this._initBody = function(body) {
/*
fetch-mock wraps the Response object in an ES6 Proxy to
provide useful test harness features such as flush. However, on
ES5 browsers without fetch or Proxy support pollyfills must be used;
the proxy-pollyfill is unable to proxy an attribute unless it exists
on the object before the Proxy is created. This change ensures
Response.bodyUsed exists on the instance, while maintaining the
semantic of setting Request.bodyUsed in the constructor before
_initBody is called.
*/
this.bodyUsed = this.bodyUsed;
this._bodyInit = body;
if (!body) {
this._bodyText = '';
} else if (typeof body === 'string') {
this._bodyText = body;
} else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
this._bodyBlob = body;
} else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
this._bodyFormData = body;
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
this._bodyText = body.toString();
} else if (support.arrayBuffer && support.blob && isDataView(body)) {
this._bodyArrayBuffer = bufferClone(body.buffer);
// IE 10-11 can't handle a DataView body.
this._bodyInit = new Blob([this._bodyArrayBuffer]);
} else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
this._bodyArrayBuffer = bufferClone(body);
} else {
this._bodyText = body = Object.prototype.toString.call(body);
}
if (!this.headers.get('content-type')) {
if (typeof body === 'string') {
this.headers.set('content-type', 'text/plain;charset=UTF-8');
} else if (this._bodyBlob && this._bodyBlob.type) {
this.headers.set('content-type', this._bodyBlob.type);
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
}
}
};
if (support.blob) {
this.blob = function() {
var rejected = consumed(this);
if (rejected) {
return rejected
}
if (this._bodyBlob) {
return Promise.resolve(this._bodyBlob)
} else if (this._bodyArrayBuffer) {
return Promise.resolve(new Blob([this._bodyArrayBuffer]))
} else if (this._bodyFormData) {
throw new Error('could not read FormData body as blob')
} else {
return Promise.resolve(new Blob([this._bodyText]))
}
};
this.arrayBuffer = function() {
if (this._bodyArrayBuffer) {
var isConsumed = consumed(this);
if (isConsumed) {
return isConsumed
}
if (ArrayBuffer.isView(this._bodyArrayBuffer)) {
return Promise.resolve(
this._bodyArrayBuffer.buffer.slice(
this._bodyArrayBuffer.byteOffset,
this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength
)
)
} else {
return Promise.resolve(this._bodyArrayBuffer)
}
} else {
return this.blob().then(readBlobAsArrayBuffer)
}
};
}
this.text = function() {
var rejected = consumed(this);
if (rejected) {
return rejected
}
if (this._bodyBlob) {
return readBlobAsText(this._bodyBlob)
} else if (this._bodyArrayBuffer) {
return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer))
} else if (this._bodyFormData) {
throw new Error('could not read FormData body as text')
} else {
return Promise.resolve(this._bodyText)
}
};
if (support.formData) {
this.formData = function() {
return this.text().then(decode)
};
}
this.json = function() {
return this.text().then(JSON.parse)
};
return this
}
// HTTP methods whose capitalization should be normalized
var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT'];
function normalizeMethod(method) {
var upcased = method.toUpperCase();
return methods.indexOf(upcased) > -1 ? upcased : method
}
function Request(input, options) {
if (!(this instanceof Request)) {
throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.')
}
options = options || {};
var body = options.body;
if (input instanceof Request) {
if (input.bodyUsed) {
throw new TypeError('Already read')
}
this.url = input.url;
this.credentials = input.credentials;
if (!options.headers) {
this.headers = new Headers(input.headers);
}
this.method = input.method;
this.mode = input.mode;
this.signal = input.signal;
if (!body && input._bodyInit != null) {
body = input._bodyInit;
input.bodyUsed = true;
}
} else {
this.url = String(input);
}
this.credentials = options.credentials || this.credentials || 'same-origin';
if (options.headers || !this.headers) {
this.headers = new Headers(options.headers);
}
this.method = normalizeMethod(options.method || this.method || 'GET');
this.mode = options.mode || this.mode || null;
this.signal = options.signal || this.signal;
this.referrer = null;
if ((this.method === 'GET' || this.method === 'HEAD') && body) {
throw new TypeError('Body not allowed for GET or HEAD requests')
}
this._initBody(body);
if (this.method === 'GET' || this.method === 'HEAD') {
if (options.cache === 'no-store' || options.cache === 'no-cache') {
// Search for a '_' parameter in the query string
var reParamSearch = /([?&])_=[^&]*/;
if (reParamSearch.test(this.url)) {
// If it already exists then set the value with the current time
this.url = this.url.replace(reParamSearch, '$1_=' + new Date().getTime());
} else {
// Otherwise add a new '_' parameter to the end with the current time
var reQueryString = /\?/;
this.url += (reQueryString.test(this.url) ? '&' : '?') + '_=' + new Date().getTime();
}
}
}
}
Request.prototype.clone = function() {
return new Request(this, {body: this._bodyInit})
};
function decode(body) {
var form = new FormData();
body
.trim()
.split('&')
.forEach(function(bytes) {
if (bytes) {
var split = bytes.split('=');
var name = split.shift().replace(/\+/g, ' ');
var value = split.join('=').replace(/\+/g, ' ');
form.append(decodeURIComponent(name), decodeURIComponent(value));
}
});
return form
}
function parseHeaders(rawHeaders) {
var headers = new Headers();
// Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space
// https://tools.ietf.org/html/rfc7230#section-3.2
var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' ');
// Avoiding split via regex to work around a common IE11 bug with the core-js 3.6.0 regex polyfill
// https://github.com/github/fetch/issues/748
// https://github.com/zloirock/core-js/issues/751
preProcessedHeaders
.split('\r')
.map(function(header) {
return header.indexOf('\n') === 0 ? header.substr(1, header.length) : header
})
.forEach(function(line) {
var parts = line.split(':');
var key = parts.shift().trim();
if (key) {
var value = parts.join(':').trim();
headers.append(key, value);
}
});
return headers
}
Body.call(Request.prototype);
function Response(bodyInit, options) {
if (!(this instanceof Response)) {
throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.')
}
if (!options) {
options = {};
}
this.type = 'default';
this.status = options.status === undefined ? 200 : options.status;
this.ok = this.status >= 200 && this.status < 300;
this.statusText = options.statusText === undefined ? '' : '' + options.statusText;
this.headers = new Headers(options.headers);
this.url = options.url || '';
this._initBody(bodyInit);
}
Body.call(Response.prototype);
Response.prototype.clone = function() {
return new Response(this._bodyInit, {
status: this.status,
statusText: this.statusText,
headers: new Headers(this.headers),
url: this.url
})
};
Response.error = function() {
var response = new Response(null, {status: 0, statusText: ''});
response.type = 'error';
return response
};
var redirectStatuses = [301, 302, 303, 307, 308];
Response.redirect = function(url, status) {
if (redirectStatuses.indexOf(status) === -1) {
throw new RangeError('Invalid status code')
}
return new Response(null, {status: status, headers: {location: url}})
};
exports.DOMException = global.DOMException;
try {
new exports.DOMException();
} catch (err) {
exports.DOMException = function(message, name) {
this.message = message;
this.name = name;
var error = Error(message);
this.stack = error.stack;
};
exports.DOMException.prototype = Object.create(Error.prototype);
exports.DOMException.prototype.constructor = exports.DOMException;
}
function fetch(input, init) {
return new Promise(function(resolve, reject) {
var request = new Request(input, init);
if (request.signal && request.signal.aborted) {
return reject(new exports.DOMException('Aborted', 'AbortError'))
}
var xhr = new XMLHttpRequest();
function abortXhr() {
xhr.abort();
}
xhr.onload = function() {
var options = {
status: xhr.status,
statusText: xhr.statusText,
headers: parseHeaders(xhr.getAllResponseHeaders() || '')
};
options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL');
var body = 'response' in xhr ? xhr.response : xhr.responseText;
setTimeout(function() {
resolve(new Response(body, options));
}, 0);
};
xhr.onerror = function() {
setTimeout(function() {
reject(new TypeError('Network request failed'));
}, 0);
};
xhr.ontimeout = function() {
setTimeout(function() {
reject(new TypeError('Network request failed'));
}, 0);
};
xhr.onabort = function() {
setTimeout(function() {
reject(new exports.DOMException('Aborted', 'AbortError'));
}, 0);
};
function fixUrl(url) {
try {
return url === '' && global.location.href ? global.location.href : url
} catch (e) {
return url
}
}
xhr.open(request.method, fixUrl(request.url), true);
if (request.credentials === 'include') {
xhr.withCredentials = true;
} else if (request.credentials === 'omit') {
xhr.withCredentials = false;
}
if ('responseType' in xhr) {
if (support.blob) {
xhr.responseType = 'blob';
} else if (
support.arrayBuffer &&
request.headers.get('Content-Type') &&
request.headers.get('Content-Type').indexOf('application/octet-stream') !== -1
) {
xhr.responseType = 'arraybuffer';
}
}
if (init && typeof init.headers === 'object' && !(init.headers instanceof Headers)) {
Object.getOwnPropertyNames(init.headers).forEach(function(name) {
xhr.setRequestHeader(name, normalizeValue(init.headers[name]));
});
} else {
request.headers.forEach(function(value, name) {
xhr.setRequestHeader(name, value);
});
}
if (request.signal) {
request.signal.addEventListener('abort', abortXhr);
xhr.onreadystatechange = function() {
// DONE (success or failure)
if (xhr.readyState === 4) {
request.signal.removeEventListener('abort', abortXhr);
}
};
}
xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit);
})
}
fetch.polyfill = true;
if (!global.fetch) {
global.fetch = fetch;
global.Headers = Headers;
global.Request = Request;
global.Response = Response;
}
exports.Headers = Headers;
exports.Request = Request;
exports.Response = Response;
exports.fetch = fetch;
Object.defineProperty(exports, '__esModule', { value: true });
})));

Просмотреть файл

@ -29,16 +29,17 @@
"license": "MIT",
"sideEffects": false,
"devDependencies": {
"@types/qunit": "^2.5.3",
"@types/qunit": "^2.19.3",
"@types/sinon": "4.3.3",
"grunt": "^1.5.3",
"grunt-contrib-qunit": "^5.0.1",
"grunt-contrib-qunit": "^6.2.1",
"@nevware21/grunt-ts-plugin": "^0.4.3",
"@nevware21/ts-async": "^0.1.0",
"@rollup/plugin-commonjs": "^18.0.0",
"@rollup/plugin-node-resolve": "^11.2.1",
"@rollup/plugin-replace": "^2.3.3",
"rollup": "^2.32.0",
"typescript": "^4.3.4",
"typescript": "^4.9.3",
"tslib": "^2.0.0",
"qunit": "^2.11.2",
"sinon": "^7.3.1",
@ -50,6 +51,6 @@
},
"dependencies": {
"@microsoft/dynamicproto-js": "^1.1.7",
"@nevware21/ts-utils": "^0.6.0"
"@nevware21/ts-utils": "^0.7.0"
}
}

Просмотреть файл

@ -15,7 +15,6 @@ function loadFetchModule(moduleLoader, name) {
window.Headers = window.Headers || polyFetch.Headers;
window.Response = window.Response || polyFetch.Response;
window.Request = window.Request || polyFetch.Request;
window.Promise = window.Promise || SimpleSyncPromise;
var usePolyFetch = getParameterByName("polyFetch");
if (usePolyFetch) {
@ -38,7 +37,7 @@ function loadCommonModules(moduleLoader) {
moduleLoader.add("@microsoft/dynamicproto-js", "./node_modules/@microsoft/dynamicproto-js/lib/dist/umd/dynamicproto-js", true);
// Load ts-utils
moduleLoader.add("@nevware21/ts-utils", "./node_modules/@nevware21/ts-utils/dist/umd/ts-utils");
moduleLoader.add("@nevware21/ts-utils", "./node_modules/@nevware21/ts-utils/dist/es5/umd/ts-utils");
}
function ModuleLoader(config) {
@ -51,7 +50,7 @@ function ModuleLoader(config) {
function doModuleCb(moduleDef, theModule, cb) {
if (theModule) {
cb(module);
cb(theModule);
} else {
// Module was loaded, but has not yet created and instance -- so create one
console && console.log("Module [" + moduleDef.name + "] loaded - creating instance - " + moduleDef.name);

Просмотреть файл

@ -1,88 +0,0 @@
/**
* Implementing a simple synchronous promise interface as PhantomJS doesn't support / implement the es6 Promise as used by fetch
*/
function SimpleSyncPromise(executor) {
var _self = this;
var _state = "pending";
var _settledValue = null;
var _queue = [];
_self.then = function (onResolved, onRejected) {
return new SimpleSyncPromise(function (resolve, reject) {
// Queue the new promise returned to be resolved or rejected
// when this promise settles.
_enqueue(onResolved, onRejected, resolve, reject);
});
};
_self["catch"] = function (onRejected) {
// Just return an empty promise as this doesn't support rejection
return _self.then(null, onRejected);
}
function _enqueue(onResolved, onRejected, resolve, reject) {
_queue.push(function () {
var value;
try {
if (_state === "resolved") {
value = typeof onResolved === "function" ? onResolved(_settledValue) : _settledValue;
} else {
value = typeof onRejected === "function" ? onRejected(_settledValue) : _settledValue;
}
if (value instanceof SimpleSyncPromise) {
// The called handlers returned a new promise, so the chained promise
// will follow the state of this promise.
value.then(resolve, reject);
} else if (_state === "rejected" && typeof onRejected !== "function") {
// If there wasn't an onRejected handler and this promise is rejected, then
// the chained promise also rejects with the same reason.
reject(value);
} else {
// If this promise is fulfilled, then the chained promise is also fulfilled
// with either the settled value of this promise (if no onFulfilled handler
// was available) or the return value of the handler. If this promise is
// rejected and there was an onRejected handler, then the chained promise is
// fulfilled with the return value of the handler.
resolve(value);
}
} catch (e) {
reject(e);
}
});
if (_state !== "pending") {
_processQueue();
}
}
function _processQueue() {
if (_queue.length > 0) {
var pending = _queue.slice();
_queue = [];
for (var i = 0, len = pending.length; i < len; ++i) {
pending[i]();
}
}
}
function _resolve(value) {
if (_state === "pending") {
_settledValue = value;
_state = "resolved";
_processQueue();
}
}
function _reject(reason) {
if (_state === "pending") {
_settledValue = reason;
_state = "rejected";
_processQueue();
}
}
(function _initialize() {
try {
executor(_resolve, _reject);
} catch (e) {
_reject(e);
}
})();
}

394
common/config/rush/npm-shrinkwrap.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -474,10 +474,12 @@ export class AnalyticsPluginTests extends AITestClass {
// Act
appInsights.trackException({exception: new Error(), severityLevel: SeverityLevel.Critical});
appInsights.trackException({error: new Error(), severityLevel: SeverityLevel.Critical});
appInsights.trackException({exception: "Critical Exception" as any, severityLevel: SeverityLevel.Critical});
appInsights.trackException("Critical Exception" as any);
this.clock.tick(1);
// Test
Assert.ok(senderStub.calledTwice, "Telemetry is sent when master switch is on");
Assert.equal(4, senderStub.callCount, "Telemetry is sent when master switch is on");
}
});
}
@ -544,6 +546,58 @@ export class AnalyticsPluginTests extends AITestClass {
Assert.equal(SeverityLevel.Error, trackStub.firstCall.args[0].baseData.severityLevel);
}
});
this.testCase({
name: "TrackExceptionTests: trackException with a string as the exception",
test: () => {
// setup
const plugin = new ChannelPlugin();
const core = new AppInsightsCore();
this.onDone(() => {
core.unload(false);
});
core.initialize(
{instrumentationKey: "ikey"},
[plugin]
);
const appInsights = new AnalyticsPlugin();
core.addPlugin(appInsights);
const trackStub = this.sandbox.stub(appInsights.core, "track");
// Test
appInsights.trackException({exception: new Error("Critical Exception"), severityLevel: SeverityLevel.Critical});
Assert.ok(trackStub.calledOnce, "single exception is tracked");
Assert.equal(SeverityLevel.Critical, trackStub.firstCall.args[0].baseData.severityLevel);
Assert.equal("Critical Exception", trackStub.firstCall.args[0].baseData.exceptions[0].message);
trackStub.reset();
appInsights.trackException({exception: "String Exception" as any, severityLevel: SeverityLevel.Error});
Assert.ok(trackStub.calledOnce, "single exception is tracked");
Assert.equal(SeverityLevel.Error, trackStub.firstCall.args[0].baseData.severityLevel);
Assert.equal("String Exception", trackStub.firstCall.args[0].baseData.exceptions[0].message);
trackStub.reset();
appInsights.trackException("Direct String Exception" as any);
Assert.ok(trackStub.calledOnce, "single exception is tracked");
Assert.equal("string: Direct String Exception", trackStub.firstCall.args[0].baseData.exceptions[0].message);
trackStub.reset();
appInsights.trackException(new Error("Wrapped String Exception") as any);
Assert.ok(trackStub.calledOnce, "single exception is tracked");
Assert.equal("Wrapped String Exception", trackStub.firstCall.args[0].baseData.exceptions[0].message);
trackStub.reset();
appInsights.trackException(null as any);
Assert.ok(trackStub.calledOnce, "single exception is tracked");
Assert.equal("not_specified", trackStub.firstCall.args[0].baseData.exceptions[0].message, JSON.stringify(trackStub.firstCall.args[0].baseData.exceptions[0]));
}
});
}
private addOnErrorTests(): void {

Просмотреть файл

@ -5,21 +5,20 @@
<meta charset="utf-8">
<meta http-equiv="Cache-control" content="no-Cache" />
<title>Tests for Application Insights JavaScript Analytics Extension</title>
<link rel="stylesheet" href="../../../common/Tests//External/qunit-1.23.1.css">
<link rel="stylesheet" href="../../../common/Tests/External/qunit-2.9.3.css">
<script src="../../../common/Tests/Selenium/ExceptionHelper.js"></script>
<!-- <script src="http://sinonjs.org/releases/sinon-2.3.8.js" crossorigin="anonymous"></script> -->
<!-- <script src="../../../common/Tests/External/sinon-2.3.8.js" crossorigin="anonymous"></script> -->
<script src="../../../common/Tests/External/sinon-7.3.1.js"></script> -->
<!-- <script src="http://cdnjs.cloudflare.com/ajax/libs/require.js/2.2.0/require.js" crossorigin="anonymous"></script> -->
<script src="../../../common/Tests/External/require-2.2.0.js"></script>
<!-- <script src="../../../common/Tests/External/require-2.3.6.js" crossorigin="anonymous"></script> -->
<script src="../../../common/Tests/External/require-2.3.6.js"></script>
<script src="../../../common/Tests/Selenium/ModuleLoader.js"></script>
<script src="../../../common/Tests/Selenium/SimpleSyncPromise.js"></script>
<script>
var modules = new ModuleLoader({
baseUrl: '../',
paths: {
qunit: "../../common/Tests/External/qunit-1.23.1",
"whatwg-fetch": "../../common/Tests/External/whatwg-fetch.3.0.0"
qunit: "../../common/Tests/External/qunit-2.9.3",
"whatwg-fetch": "../../common/Tests/External/whatwg-fetch.3.6.2"
}
});

Просмотреть файл

@ -32,7 +32,7 @@
"@microsoft/applicationinsights-properties-js": "2.8.9",
"@microsoft/applicationinsights-channel-js": "2.8.9",
"@microsoft/api-extractor": "^7.18.1",
"typescript": "^4.3.4",
"typescript": "^4.9.3",
"tslib": "^2.0.0",
"globby": "^11.0.0",
"magic-string": "^0.25.7",
@ -44,7 +44,7 @@
"rollup": "^2.32.0",
"grunt": "^1.5.3",
"grunt-cli": "^1.4.3",
"grunt-contrib-qunit": "^5.0.1",
"grunt-contrib-qunit": "^6.2.1",
"@nevware21/grunt-ts-plugin": "^0.4.3",
"@nevware21/grunt-eslint-ts": "^0.2.2",
"qunit": "^2.11.2",
@ -58,7 +58,7 @@
"@microsoft/applicationinsights-shims": "2.0.2",
"@microsoft/applicationinsights-core-js": "2.8.9",
"@microsoft/applicationinsights-common": "2.8.9",
"@nevware21/ts-utils": "^0.6.0"
"@nevware21/ts-utils": "^0.7.0"
},
"license": "MIT"
}

Просмотреть файл

@ -21,7 +21,7 @@ import {
mergeEvtNamespace, objDefineAccessors, onConfigChange, safeGetCookieMgr, strUndefined, throwError
} from "@microsoft/applicationinsights-core-js";
import { PropertiesPlugin } from "@microsoft/applicationinsights-properties-js";
import { objDeepFreeze, objDefineProp, scheduleTimeout, strIndexOf } from "@nevware21/ts-utils";
import { isError, objDeepFreeze, objDefineProp, scheduleTimeout, strIndexOf } from "@nevware21/ts-utils";
import { IAppInsightsInternal, PageViewManager } from "./Telemetry/PageViewManager";
import { PageViewPerformanceManager } from "./Telemetry/PageViewPerformanceManager";
import { PageVisitTimeManager } from "./Telemetry/PageVisitTimeManager";
@ -400,7 +400,17 @@ export class AnalyticsPlugin extends BaseTelemetryPlugin implements IAppInsights
* @param systemProperties
*/
_self.sendExceptionInternal = (exception: IExceptionTelemetry, customProperties?: { [key: string]: any }, systemProperties?: { [key: string]: any }) => {
const theError = exception.exception || exception.error || new Error(strNotSpecified);
// Adding additional edge cases to handle
// - Not passing anything (null / undefined)
const theError = (exception && (exception.exception || exception.error)) ||
// - Handle someone calling trackException based of v1 API where the exception was the Error
isError(exception) && exception ||
// - Handles no error being defined and instead of creating a new Error() instance attempt to map so any stacktrace
// is preserved and does not list ApplicationInsights code as the source
{ name: (exception && typeof exception) as string, message: exception as any || strNotSpecified };
// If no exception object was passed assign to an empty object to avoid internal exceptions
exception = exception || {};
let exceptionPartB = new Exception(
_self.diagLog(),
theError,

Просмотреть файл

@ -5,18 +5,17 @@
<meta charset="utf-8">
<meta http-equiv="Cache-control" content="no-Cache" />
<title>Tests for Application Insights JavaScript API</title>
<link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-1.23.1.css">
<script src="https://sinonjs.org/releases/sinon-2.3.8.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.2.0/require.js"></script>
<link rel="stylesheet" href="../../../common/Tests/External/qunit-2.9.3.css">
<script src="../../../common/Tests/External/sinon-2.3.8.js"></script>
<script src="../../../common/Tests/External/require-2.3.6.js"></script>
<script src="../../../common/Tests/Selenium/ModuleLoader.js"></script>
<script src="../../../common/Tests/Selenium/SimpleSyncPromise.js"></script>
<script>
var modules = new ModuleLoader({
baseUrl: '../',
paths: {
qunit: "../../common/Tests/External/qunit-1.23.1",
"whatwg-fetch": "../../common/Tests/External/whatwg-fetch.3.0.0"
qunit: "../../common/Tests/External/qunit-2.9.3",
"whatwg-fetch": "../../common/Tests/External/whatwg-fetch.3.6.2"
}
});

Просмотреть файл

@ -26,7 +26,7 @@
"@microsoft/applicationinsights-rollup-plugin-uglify3-js": "1.0.0",
"@microsoft/applicationinsights-rollup-es5": "1.0.0",
"@microsoft/api-extractor": "^7.18.1",
"typescript": "^4.3.4",
"typescript": "^4.9.3",
"tslib": "^2.0.0",
"globby": "^11.0.0",
"magic-string": "^0.25.7",
@ -37,7 +37,7 @@
"rollup": "^2.32.0",
"grunt": "^1.5.3",
"grunt-cli": "^1.4.3",
"grunt-contrib-qunit": "^5.0.1",
"grunt-contrib-qunit": "^6.2.1",
"@nevware21/grunt-ts-plugin": "^0.4.3",
"@nevware21/grunt-eslint-ts": "^0.2.2"
},
@ -50,7 +50,7 @@
"@microsoft/applicationinsights-core-js": "2.8.9",
"@microsoft/applicationinsights-common": "2.8.9",
"@microsoft/applicationinsights-properties-js": "2.8.9",
"@nevware21/ts-utils": "^0.6.0"
"@nevware21/ts-utils": "^0.7.0"
},
"repository": {
"type": "git",

Просмотреть файл

@ -28,11 +28,11 @@
"@microsoft/applicationinsights-rollup-plugin-uglify3-js": "1.0.0",
"@microsoft/applicationinsights-rollup-es5": "1.0.0",
"@microsoft/api-extractor": "^7.18.1",
"typescript": "^4.3.4",
"typescript": "^4.9.3",
"tslib": "^2.0.0",
"grunt": "^1.5.3",
"grunt-cli": "^1.4.3",
"grunt-contrib-qunit": "^5.0.1",
"grunt-contrib-qunit": "^6.2.1",
"@nevware21/grunt-ts-plugin": "^0.4.3",
"@nevware21/grunt-eslint-ts": "^0.2.2",
"globby": "^11.0.0",
@ -51,7 +51,7 @@
"@microsoft/applicationinsights-common": "2.8.9",
"@microsoft/applicationinsights-core-js": "2.8.9",
"@microsoft/applicationinsights-shims": "2.0.2",
"@nevware21/ts-utils": "^0.6.0"
"@nevware21/ts-utils": "^0.7.0"
},
"license": "MIT"
}

Просмотреть файл

@ -1,5 +1,6 @@
import { SinonStub } from "sinon";
import { Assert, AITestClass, PollingAssert } from "@microsoft/ai-test-framework";
import { createSyncPromise } from "@nevware21/ts-async";
import { AjaxMonitor } from "../../../src/ajax";
import { DisabledPropertyName, IConfig, DistributedTracingModes, RequestHeaders, IDependencyTelemetry, IRequestContext, formatTraceParent, createTraceParent } from "@microsoft/applicationinsights-common";
import {
@ -23,7 +24,7 @@ function hookFetch<T>(executor: (resolve: (value?: T | PromiseLike<T>) => void,
input,
init
});
return new window["SimpleSyncPromise"](executor);
return createSyncPromise(executor);
}
return calls;
@ -722,6 +723,7 @@ export class AjaxTests extends AITestClass {
data = trackStub.args[1][0].baseData;
Assert.equal("Ajax", data.type, "request is Ajax type");
Assert.equal(undefined, data.properties.responseText, "xhr request's reponse error is not stored in part C");
Assert.equal(undefined, data.properties.aborted, "The aborted flag should not be set");
}
});
@ -767,6 +769,116 @@ export class AjaxTests extends AITestClass {
}
});
this.testCase({
name: "Ajax: xhr abort is tracked as part C data when enableAjaxErrorStatusText flag is true",
test: () => {
this._ajax = new AjaxMonitor();
let appInsightsCore = new AppInsightsCore();
let coreConfig: IConfiguration & IConfig = { instrumentationKey: "abc", disableAjaxTracking: false, enableAjaxErrorStatusText: true };
appInsightsCore.initialize(coreConfig, [this._ajax, new TestChannelPlugin()]);
var trackStub = this.sandbox.stub(appInsightsCore, "track");
// act
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://microsoft.com");
xhr.send();
xhr.abort();
// assert
Assert.ok(trackStub.calledOnce, "track is called");
let data = trackStub.args[0][0].baseData;
Assert.equal("Ajax", data.type, "request is Ajax type");
Assert.equal(0, data.responseCode, "Check the response code");
Assert.equal(true, data.properties.aborted, "The aborted flag should be set");
Assert.notEqual(undefined, data.properties.responseText, "xhr request's reponse error is stored in part C");
Assert.strictEqual("", data.properties.responseText, "Check the status Text");
}
});
this.testCase({
name: "Ajax: xhr abort is tracked as part C data when enableAjaxErrorStatusText flag is false",
test: () => {
this._ajax = new AjaxMonitor();
let appInsightsCore = new AppInsightsCore();
let coreConfig: IConfiguration & IConfig = { instrumentationKey: "abc", disableAjaxTracking: false, enableAjaxErrorStatusText: false };
appInsightsCore.initialize(coreConfig, [this._ajax, new TestChannelPlugin()]);
var trackStub = this.sandbox.stub(appInsightsCore, "track");
// act
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://microsoft.com");
xhr.send();
xhr.abort();
// assert
Assert.ok(trackStub.calledOnce, "track is called");
let data = trackStub.args[0][0].baseData;
Assert.equal("Ajax", data.type, "request is Ajax type");
Assert.equal(0, data.responseCode, "Check the response code");
Assert.equal(true, data.properties.aborted, "The aborted flag should be set");
Assert.equal(undefined, data.properties.responseText, "xhr request's reponse error is stored in part C");
}
});
this.testCase({
name: "Ajax: xhr respond with status code zero is tracked as part C data when enableAjaxErrorStatusText flag is true",
test: () => {
this._ajax = new AjaxMonitor();
let appInsightsCore = new AppInsightsCore();
let coreConfig: IConfiguration & IConfig = { instrumentationKey: "abc", disableAjaxTracking: false, enableAjaxErrorStatusText: true };
appInsightsCore.initialize(coreConfig, [this._ajax, new TestChannelPlugin()]);
var trackStub = this.sandbox.stub(appInsightsCore, "track");
// act
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://microsoft.com");
xhr.send();
(<any>xhr).respond(0);
// assert
Assert.ok(trackStub.calledOnce, "track is called");
let data = trackStub.args[0][0].baseData;
Assert.equal("Ajax", data.type, "request is Ajax type");
Assert.equal(0, data.responseCode, "Check the response code");
Assert.equal(undefined, data.properties.aborted, "The aborted flag should be set");
Assert.notEqual(undefined, data.properties.responseText, "xhr request's reponse error is stored in part C");
Assert.strictEqual("", data.properties.responseText, "Check the status Text");
}
});
this.testCase({
name: "Ajax: xhr respond with status code zero is tracked as part C data when enableAjaxErrorStatusText flag is false",
test: () => {
this._ajax = new AjaxMonitor();
let appInsightsCore = new AppInsightsCore();
let coreConfig: IConfiguration & IConfig = { instrumentationKey: "abc", disableAjaxTracking: false, enableAjaxErrorStatusText: false };
appInsightsCore.initialize(coreConfig, [this._ajax, new TestChannelPlugin()]);
var trackStub = this.sandbox.stub(appInsightsCore, "track");
// act
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://microsoft.com");
xhr.send();
(<any>xhr).respond(0);
// assert
Assert.ok(trackStub.calledOnce, "track is called");
let data = trackStub.args[0][0].baseData;
Assert.equal("Ajax", data.type, "request is Ajax type");
Assert.equal(0, data.responseCode, "Check the response code");
Assert.equal(undefined, data.properties.aborted, "The aborted flag should be set");
Assert.equal(undefined, data.properties.responseText, "xhr request's reponse error is stored in part C");
}
});
this.testCaseAsync({
name: "Fetch: fetch with disabled flag isn't tracked",
stepDelay: 10,
@ -1123,6 +1235,108 @@ export class AjaxTests extends AITestClass {
}]
});
this.testCaseAsync({
name: "Fetch: Respond with status 0 and no status text",
stepDelay: 10,
autoComplete: false,
timeOut: 10000,
steps: [ (testContext) => {
hookFetch((resolve) => {
AITestClass.orgSetTimeout(function() {
resolve({
headers: new Headers(),
ok: true,
body: null,
bodyUsed: false,
redirected: false,
status: 0,
statusText: "Blocked",
trailer: null,
type: "basic",
url: "https://httpbin.org/status/200"
});
}, 0);
});
this._ajax = new AjaxMonitor();
let dependencyFields = hookTrackDependencyInternal(this._ajax);
let appInsightsCore = new AppInsightsCore();
let coreConfig = { instrumentationKey: "", disableFetchTracking: false };
appInsightsCore.initialize(coreConfig, [this._ajax, new TestChannelPlugin()]);
let fetchSpy = this.sandbox.spy(appInsightsCore, "track")
let throwSpy = this.sandbox.spy(appInsightsCore.logger, "throwInternal");
// Act
Assert.ok(fetchSpy.notCalled, "No fetch called yet");
fetch("https://httpbin.org/status/200", {method: "post", [DisabledPropertyName]: false}).then(() => {
// Assert
Assert.ok(fetchSpy.calledOnce, "createFetchRecord called once after using fetch");
let data = fetchSpy.args[0][0].baseData;
Assert.equal("Fetch", data.type, "request is Fetch type");
Assert.ok(throwSpy.notCalled, "Make sure we didn't fail internally");
Assert.equal(1, dependencyFields.length, "trackDependencyDataInternal was called");
Assert.ok(dependencyFields[0].dependency.startTime, "startTime was specified before trackDependencyDataInternal was called");
Assert.equal(0, dependencyFields[0].dependency.responseCode, "Check the response code");
Assert.equal(undefined, dependencyFields[0].dependency.properties.responseText);
testContext.testDone();
}, () => {
Assert.ok(false, "fetch failed!");
testContext.testDone();
});
}]
});
this.testCaseAsync({
name: "Fetch: Respond with status 0 and no status text",
stepDelay: 10,
autoComplete: false,
timeOut: 10000,
steps: [ (testContext) => {
hookFetch((resolve) => {
AITestClass.orgSetTimeout(function() {
resolve({
headers: new Headers(),
ok: true,
body: null,
bodyUsed: false,
redirected: false,
status: 0,
statusText: "Blocked",
trailer: null,
type: "basic",
url: "https://httpbin.org/status/200"
});
}, 0);
});
this._ajax = new AjaxMonitor();
let dependencyFields = hookTrackDependencyInternal(this._ajax);
let appInsightsCore = new AppInsightsCore();
let coreConfig = { instrumentationKey: "", disableFetchTracking: false, enableAjaxErrorStatusText: true };
appInsightsCore.initialize(coreConfig, [this._ajax, new TestChannelPlugin()]);
let fetchSpy = this.sandbox.spy(appInsightsCore, "track")
let throwSpy = this.sandbox.spy(appInsightsCore.logger, "throwInternal");
// Act
Assert.ok(fetchSpy.notCalled, "No fetch called yet");
fetch("https://httpbin.org/status/200", {method: "post", [DisabledPropertyName]: false}).then(() => {
// Assert
Assert.ok(fetchSpy.calledOnce, "createFetchRecord called once after using fetch");
let data = fetchSpy.args[0][0].baseData;
Assert.equal("Fetch", data.type, "request is Fetch type");
Assert.ok(throwSpy.notCalled, "Make sure we didn't fail internally");
Assert.equal(1, dependencyFields.length, "trackDependencyDataInternal was called");
Assert.ok(dependencyFields[0].dependency.startTime, "startTime was specified before trackDependencyDataInternal was called");
Assert.equal(0, dependencyFields[0].dependency.responseCode, "Check the response code");
Assert.equal("Blocked", dependencyFields[0].dependency!.properties.responseText);
testContext.testDone();
}, () => {
Assert.ok(false, "fetch failed!");
testContext.testDone();
});
}]
});
this.testCaseAsync({
name: "Fetch: fetch addDependencyInitializer adding context",
stepDelay: 10,
@ -2947,7 +3161,12 @@ export class AjaxPerfTrackTests extends AITestClass {
.concat(PollingAssert.createPollingAssert(() => {
let trackStub = this._context["trackStub"] as SinonStub;
if (this._context["fetchComplete"]) {
Assert.ok(trackStub.notCalled, "No fetch called yet");
Assert.ok(trackStub.calledOnce, "track is called");
let data = trackStub.args[0][0].baseData;
Assert.equal("Fetch", data.type, "request is Fetch type");
let props = data.properties;
Assert.notEqual(undefined, props, "Should contain properties");
Assert.equal(undefined, props.ajaxPerf, "No performance data should exist");
return true;
}
@ -3283,7 +3502,7 @@ export class AjaxFrozenTests extends AITestClass {
return false;
}, 'response received', 60, 1000) as any)
});
// This is currently a manual test as we don't have hooks / mocks defined to automated this today
// this.testCaseAsync({
// name: "AjaxFrozenTests: check frozen prototype",

Просмотреть файл

@ -5,18 +5,17 @@
<meta charset="utf-8">
<meta http-equiv="Cache-control" content="no-Cache" />
<title>Tests for Application Insights JavaScript API</title>
<link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-1.23.1.css">
<script src="http://sinonjs.org/releases/sinon-2.3.8.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/require.js/2.2.0/require.js"></script>
<link rel="stylesheet" href="../../../common/Tests/External/qunit-2.9.3.css">
<script src="../../../common/Tests/External/sinon-2.3.8.js"></script>
<script src="../../../common/Tests/External/require-2.3.6.js"></script>
<script src="../../../common/Tests/Selenium/ModuleLoader.js"></script>
<script src="../../../common/Tests/Selenium/SimpleSyncPromise.js"></script>
<script>
var modules = new ModuleLoader({
baseUrl: '../',
paths: {
qunit: "../../common/Tests/External/qunit-1.23.1",
"whatwg-fetch": "../../common/Tests/External/whatwg-fetch.3.0.0"
qunit: "../../common/Tests/External/qunit-2.9.3",
"whatwg-fetch": "../../common/Tests/External/whatwg-fetch.3.6.2"
}
});
@ -32,6 +31,9 @@
// Load Common
modules.add("@microsoft/applicationinsights-common", "./node_modules/@microsoft/applicationinsights-common/browser/applicationinsights-common");
// Load Common
modules.add("@nevware21/ts-async", "./node_modules/@nevware21/ts-async/dist/es5/umd/ts-async");
var testModule = modules.add("Tests/Unit/src/dependencies.tests", "./Unit/dist/dependencies.tests.js")
testModule.run = function (tests) {
console && console.log("Starting tests");

Просмотреть файл

@ -26,15 +26,16 @@
"ai-restore": "grunt deps-restore"
},
"devDependencies": {
"@nevware21/ts-async": "^0.1.0",
"@microsoft/ai-test-framework": "0.0.1",
"@microsoft/applicationinsights-rollup-plugin-uglify3-js": "1.0.0",
"@microsoft/applicationinsights-rollup-es5": "1.0.0",
"@microsoft/api-extractor": "^7.18.1",
"typescript": "^4.3.4",
"typescript": "^4.9.3",
"tslib": "^2.0.0",
"grunt": "^1.5.3",
"grunt-cli": "^1.4.3",
"grunt-contrib-qunit": "^5.0.1",
"grunt-contrib-qunit": "^6.2.1",
"@nevware21/grunt-ts-plugin": "^0.4.3",
"@nevware21/grunt-eslint-ts": "^0.2.2",
"globby": "^11.0.0",
@ -55,7 +56,7 @@
"@microsoft/applicationinsights-shims": "2.0.2",
"@microsoft/applicationinsights-core-js": "2.8.9",
"@microsoft/applicationinsights-common": "2.8.9",
"@nevware21/ts-utils": "^0.6.0"
"@nevware21/ts-utils": "^0.7.0"
},
"license": "MIT"
}

Просмотреть файл

@ -23,6 +23,11 @@ export interface IDependencyInitializerDetails {
* The context that the application can assigned via the dependency listener(s)
*/
context?: { [key: string]: any };
/**
* [Optional] A flag that indicates whether the client request was manually aborted by the `abort()`
*/
aborted?: boolean;
}
/**

Просмотреть файл

@ -51,6 +51,13 @@ export interface IDependencyListenerDetails {
* [Optional] Context that the application can assign that will also be passed to any dependency initializer
*/
context?: { [key: string]: any };
/**
* [Optional] A flag that indicates whether the client request was manually aborted by the `abort()`,
* as listeners are called just before the request is sent it is unlikely that an application would have
* called `abort` before `send` this is also available in the dependency initializer.
*/
aborted?: boolean;
}
/**

Просмотреть файл

@ -25,7 +25,7 @@ import { IAjaxRecordResponse, ajaxRecord } from "./ajaxRecord";
const AJAX_MONITOR_PREFIX = "ai.ajxmn.";
const strDiagLog = "diagLog";
const strAjaxData = "ajaxData";
const strFetch = "fetch";
const STR_FETCH = "fetch";
const ERROR_HEADER = "Failed to monitor XMLHttpRequest";
const ERROR_PREFIX = ", monitoring data for this ajax call ";
@ -49,11 +49,11 @@ function _supportsFetch(): (input: RequestInfo, init?: RequestInit) => Promise<R
if (!_global ||
isNullOrUndefined((_global as any).Request) ||
isNullOrUndefined((_global as any).Request[strPrototype]) ||
isNullOrUndefined(_global[strFetch])) {
isNullOrUndefined(_global[STR_FETCH])) {
return null;
}
return _global[strFetch];
return _global[STR_FETCH];
}
/**
@ -198,7 +198,8 @@ function _processDependencyListeners(listeners: _IInternalDependencyHandler<Depe
traceId: ajaxData.traceID,
spanId: ajaxData.spanID,
traceFlags: ajaxData.traceFlags,
context: ajaxData.context || {}
context: ajaxData.context || {},
aborted: !!ajaxData.aborted
};
_processDependencyContainer(core, listeners, details, "listener");
@ -559,7 +560,7 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
_enableResponseHeaderTracking = _extensionConfig.enableResponseHeaderTracking;
if (!_disableFetchTracking && !_fetchInitialized) {
_addHook(InstrumentFunc(global, strFetch, {
_addHook(InstrumentFunc(global, STR_FETCH, {
ns: _evtNamespace,
// Add request hook
req: (callDetails: IInstrumentCallDetails, input, init) => {
@ -585,12 +586,12 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
callDetails.rslt = callDetails.rslt.then((response: any) => {
_reportFetchMetrics(callDetails, (response||{}).status, input, response, fetchData, () => {
let ajaxResponse:IAjaxRecordResponse = {
statusText: response.statusText,
statusText: (response||{}).statusText,
headerMap: null,
correlationContext: _getFetchCorrelationContext(response)
};
if (_enableResponseHeaderTracking) {
if (_enableResponseHeaderTracking && response) {
const responseHeaderMap = {};
response.headers.forEach((value: string, name: string) => { // @skip-minify
if (_canIncludeHeaders(name)) {
@ -607,7 +608,7 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
return response;
})
.catch((reason: any) => {
_reportFetchMetrics(callDetails, 0, input, null, fetchData, null, { error: reason.message });
_reportFetchMetrics(callDetails, 0, input, null, fetchData, null, { error: reason.message || dumpObj(reason) });
throw reason;
});
}
@ -626,7 +627,7 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
// Note: Polyfill implementations that don't support the "polyfill" tag are not supported
// the workaround is to add a polyfill property to your fetch implementation before initializing
// App Insights
_addHook(InstrumentFunc(global, strFetch, {
_addHook(InstrumentFunc(global, STR_FETCH, {
ns: _evtNamespace,
req: (callDetails: IInstrumentCallDetails, input, init) => {
// Just call so that we record any disabled URL
@ -640,7 +641,7 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
if (isPolyfill) {
// retag the instrumented fetch with the same polyfill settings this is mostly for testing
// But also supports multiple App Insights usages
(global[strFetch] as any).polyfill = isPolyfill;
(global[STR_FETCH] as any).polyfill = isPolyfill;
}
}
@ -1107,7 +1108,7 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
ajaxData.requestHeaders = requestHeaders;
_createMarkId("fetch", ajaxData);
_createMarkId(STR_FETCH, ajaxData);
return ajaxData;
}
@ -1153,7 +1154,7 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
ajaxData.responseFinishedTime = dateTimeUtilsNow();
ajaxData.status = status;
_findPerfResourceEntry("fetch", ajaxData, () => {
_findPerfResourceEntry(STR_FETCH, ajaxData, () => {
const dependency = ajaxData.CreateTrackItem("Fetch", _enableRequestHeaderTracking, getResponse);
let properties;
@ -1219,7 +1220,8 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
item: dependency,
properties: properties,
sysProperties: systemProperties,
context: ajaxData ? ajaxData.context : null
context: ajaxData ? ajaxData.context : null,
aborted: ajaxData ? !!ajaxData.aborted : false
};
result = _processDependencyContainer(core, initializers, details, "initializer");

Просмотреть файл

@ -240,7 +240,7 @@ export class ajaxRecord {
public xhrMonitoringState: XHRMonitoringState;
// <summary>Determines whether or not JavaScript exception occured in xhr.onreadystatechange code. 1 if occured, otherwise 0.</summary>
// <summary>Determines whether or not JavaScript exception occurred in xhr.onreadystatechange code. 1 if occurred, otherwise 0.</summary>
public clientFailure: number;
/**
@ -339,6 +339,11 @@ export class ajaxRecord {
[STR_PROPERTIES]: { HttpMethod: self.method }
} as IDependencyTelemetry;
let props = dependency[STR_PROPERTIES];
if (self.aborted) {
props.aborted = true;
}
if (self.requestSentTime) {
// Set the correct dependency start time
dependency.startTime = new Date();
@ -350,7 +355,6 @@ export class ajaxRecord {
if (enableRequestHeaderTracking) {
if (objKeys(self.requestHeaders).length > 0) {
let props = dependency.properties = dependency.properties || {};
props.requestHeaders = self.requestHeaders;
}
}
@ -367,19 +371,21 @@ export class ajaxRecord {
if (response.headerMap) {
if (objKeys(response.headerMap).length > 0) {
let props = dependency.properties = dependency.properties || {};
props.responseHeaders = response.headerMap;
}
}
if (self.errorStatusText && self.status >= 400) {
const responseType = response.type;
let props = dependency.properties = dependency.properties || {};
if (responseType === "" || responseType === "text") {
props.responseText = response.responseText ? response.statusText + " - " + response[strResponseText] : response.statusText;
}
if (responseType === "json") {
props.responseText = response.response ? response.statusText + " - " + JSON.stringify(response.response) : response.statusText;
if (self.errorStatusText) {
if (self.status >= 400) {
const responseType = response.type;
if (responseType === "" || responseType === "text") {
props.responseText = response.responseText ? response.statusText + " - " + response[strResponseText] : response.statusText;
}
if (responseType === "json") {
props.responseText = response.response ? response.statusText + " - " + JSON.stringify(response.response) : response.statusText;
}
} else if (self.status === 0) {
props.responseText = response.statusText || "";
}
}
}

Просмотреть файл

@ -5,18 +5,17 @@
<meta charset="utf-8">
<meta http-equiv="Cache-control" content="no-Cache" />
<title>Tests for Application Insights JavaScript API</title>
<link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-1.23.1.css">
<script src="https://sinonjs.org/releases/sinon-2.3.8.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.2.0/require.js"></script>
<link rel="stylesheet" href="../../../common/Tests/External/qunit-2.9.3.css">
<script src="../../../common/Tests/External/sinon-2.3.8.js"></script>
<script src="../../../common/Tests/External/require-2.3.6.js"></script>
<script src="../../../common/Tests/Selenium/ModuleLoader.js"></script>
<script src="../../../common/Tests/Selenium/SimpleSyncPromise.js"></script>
<script>
var modules = new ModuleLoader({
baseUrl: '../',
paths: {
qunit: "../../common/Tests/External/qunit-1.23.1",
"whatwg-fetch": "../../common/Tests/External/whatwg-fetch.3.0.0"
qunit: "../../common/Tests/External/qunit-2.9.3",
"whatwg-fetch": "../../common/Tests/External/whatwg-fetch.3.6.2"
}
});

Просмотреть файл

@ -30,7 +30,7 @@
"@microsoft/applicationinsights-rollup-plugin-uglify3-js": "1.0.0",
"@microsoft/applicationinsights-rollup-es5": "1.0.0",
"@microsoft/api-extractor": "^7.18.1",
"typescript": "^4.3.4",
"typescript": "^4.9.3",
"tslib": "^2.0.0",
"grunt": "^1.5.3",
"grunt-cli": "^1.4.3",
@ -52,7 +52,7 @@
"@microsoft/dynamicproto-js": "^1.1.7",
"@microsoft/applicationinsights-shims": "2.0.2",
"@microsoft/applicationinsights-core-js": "2.8.9",
"@nevware21/ts-utils": "^0.6.0"
"@nevware21/ts-utils": "^0.7.0"
},
"license": "MIT"
}

Просмотреть файл

@ -5,18 +5,17 @@
<meta charset="utf-8">
<meta http-equiv="Cache-control" content="no-Cache" />
<title>Tests for Application Insights JavaScript Properties Plugin</title>
<link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-1.23.1.css">
<script src="https://sinonjs.org/releases/sinon-2.3.8.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.2.0/require.js"></script>
<link rel="stylesheet" href="../../../common/Tests/External/qunit-2.9.3.css">
<script src="../../../common/Tests/External/sinon-2.3.8.js"></script>
<script src="../../../common/Tests/External/require-2.3.6.js"></script>
<script src="../../../common/Tests/Selenium/ModuleLoader.js"></script>
<script src="../../../common/Tests/Selenium/SimpleSyncPromise.js"></script>
<script>
var modules = new ModuleLoader({
baseUrl: '../',
paths: {
qunit: "../../common/Tests/External/qunit-1.23.1",
"whatwg-fetch": "../../common/Tests/External/whatwg-fetch.3.0.0"
qunit: "../../common/Tests/External/qunit-2.9.3",
"whatwg-fetch": "../../common/Tests/External/whatwg-fetch.3.6.2"
}
});

Просмотреть файл

@ -30,11 +30,11 @@
"@microsoft/applicationinsights-rollup-plugin-uglify3-js": "1.0.0",
"@microsoft/applicationinsights-rollup-es5": "1.0.0",
"@microsoft/api-extractor": "^7.18.1",
"typescript": "^4.3.4",
"typescript": "^4.9.3",
"tslib": "^2.0.0",
"grunt": "^1.5.3",
"grunt-cli": "^1.4.3",
"grunt-contrib-qunit": "^5.0.1",
"grunt-contrib-qunit": "^6.2.1",
"@nevware21/grunt-ts-plugin": "^0.4.3",
"@nevware21/grunt-eslint-ts": "^0.2.2",
"globby": "^11.0.0",
@ -56,7 +56,7 @@
"@microsoft/applicationinsights-shims": "2.0.2",
"@microsoft/applicationinsights-core-js": "2.8.9",
"@microsoft/applicationinsights-common": "2.8.9",
"@nevware21/ts-utils": "^0.6.0"
"@nevware21/ts-utils": "^0.7.0"
},
"license": "MIT"
}

Просмотреть файл

@ -42,8 +42,8 @@
"@microsoft/rush": "5.82.1",
"@nevware21/grunt-eslint-ts": "^0.2.2",
"@nevware21/grunt-ts-plugin": "^0.4.3",
"@typescript-eslint/eslint-plugin": "^4.28.0",
"@typescript-eslint/parser": "^4.28.0",
"@typescript-eslint/eslint-plugin": "^5.46.1",
"@typescript-eslint/parser": "^5.46.1",
"archiver": "^5.3.0",
"chromium": "^3.0.2",
"connect": "^3.7.0",
@ -57,12 +57,11 @@
"grunt-cli": "^1.4.3",
"grunt-contrib-connect": "^3.0.0",
"grunt-contrib-copy": "^1.0.0",
"grunt-contrib-qunit": "^5.0.1",
"grunt-contrib-uglify": "^5.0.1",
"grunt-string-replace": "^1.3.1",
"puppeteer": "^13.1.3",
"typedoc": "^0.22.8",
"typescript": "^4.3.4",
"whatwg-fetch": "^3.0.0"
"grunt-contrib-qunit": "^6.2.1",
"grunt-contrib-uglify": "^5.2.1",
"puppeteer": "19.2.0",
"typedoc": "^0.23.22",
"typescript": "^4.9.3",
"whatwg-fetch": "^3.6.2"
}
}

Просмотреть файл

@ -172,6 +172,7 @@ export class ThrottleMgrTest extends AITestClass {
daysOfMonth: undefined
} as IThrottleInterval
} as IThrottleMgrConfig;
let throttleMgr = new ThrottleMgr(config, this._core);
let actualConfig = throttleMgr.getConfig();
Assert.deepEqual(expectedConfig, actualConfig);
@ -215,7 +216,7 @@ export class ThrottleMgrTest extends AITestClass {
let canThrottle = throttleMgr.canThrottle();
Assert.equal(canThrottle, true, "should throttle");
}
});

Просмотреть файл

@ -5,18 +5,17 @@
<meta charset="utf-8">
<meta http-equiv="Cache-control" content="no-Cache" />
<title>Tests for Application Insights JavaScript API</title>
<link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-1.23.1.css">
<script src="https://sinonjs.org/releases/sinon-2.3.8.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.2.0/require.js"></script>
<link rel="stylesheet" href="../../../common/Tests/External/qunit-2.9.3.css">
<script src="../../../common/Tests/External/sinon-2.3.8.js"></script>
<script src="../../../common/Tests/External/require-2.3.6.js"></script>
<script src="../../../common/Tests/Selenium/ModuleLoader.js"></script>
<script src="../../../common/Tests/Selenium/SimpleSyncPromise.js"></script>
<script>
var modules = new ModuleLoader({
baseUrl: '../',
paths: {
qunit: "../../common/Tests/External/qunit-1.23.1",
"whatwg-fetch": "../../common/Tests/External/whatwg-fetch.3.0.0"
qunit: "../../common/Tests/External/qunit-2.9.3",
"whatwg-fetch": "../../common/Tests/External/whatwg-fetch.3.6.2"
}
});

Просмотреть файл

@ -32,7 +32,7 @@
"@microsoft/api-extractor": "^7.18.1",
"grunt": "^1.5.3",
"grunt-cli": "^1.4.3",
"grunt-contrib-qunit": "^5.0.1",
"grunt-contrib-qunit": "^6.2.1",
"@nevware21/grunt-ts-plugin": "^0.4.3",
"@nevware21/grunt-eslint-ts": "^0.2.2",
"@rollup/plugin-commonjs": "^18.0.0",
@ -40,7 +40,7 @@
"@rollup/plugin-replace": "^2.3.3",
"rollup-plugin-cleanup": "^3.2.1",
"rollup": "^2.32.0",
"typescript": "^4.3.4",
"typescript": "^4.9.3",
"tslib": "^2.0.0",
"globby": "^11.0.0",
"magic-string": "^0.25.7",
@ -53,7 +53,7 @@
"@microsoft/applicationinsights-shims": "2.0.2",
"@microsoft/applicationinsights-core-js": "2.8.9",
"@microsoft/dynamicproto-js": "^1.1.7",
"@nevware21/ts-utils": "^0.6.0"
"@nevware21/ts-utils": "^0.7.0"
},
"license": "MIT"
}

Просмотреть файл

@ -1,6 +1,6 @@
import {
IAppInsightsCore, IDiagnosticLogger, _eInternalMessageId, _throwInternal, arrForEach, eLoggingSeverity, isNotNullOrUndefined,
isNullOrUndefined, randomValue, safeGetLogger, strTrim, arrIndexOf
IAppInsightsCore, IDiagnosticLogger, _eInternalMessageId, _throwInternal, arrForEach, arrIndexOf, eLoggingSeverity, isNotNullOrUndefined,
isNullOrUndefined, randomValue, safeGetLogger, strTrim
} from "@microsoft/applicationinsights-core-js";
import { IThrottleMsgKey } from "./Enums";
import { IThrottleInterval, IThrottleLocalStorageObj, IThrottleMgrConfig, IThrottleResult } from "./Interfaces/IThrottleMgr";

Просмотреть файл

@ -5,18 +5,17 @@
<meta charset="utf-8">
<meta http-equiv="Cache-control" content="no-Cache" />
<title>Tests for Application Insights JavaScript Core SDK</title>
<link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-1.23.1.css">
<script src="http://sinonjs.org/releases/sinon-2.3.8.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/require.js/2.2.0/require.js"></script>
<link rel="stylesheet" href="../../../common/Tests/External/qunit-2.9.3.css">
<script src="../../../common/Tests/External/sinon-2.3.8.js"></script>
<script src="../../../common/Tests/External/require-2.3.6.js"></script>
<script src="../../../common/Tests/Selenium/ModuleLoader.js"></script>
<script src="../../../common/Tests/Selenium/SimpleSyncPromise.js"></script>
<script>
var modules = new ModuleLoader({
baseUrl: '../',
paths: {
qunit: "../../common/Tests/External/qunit-1.23.1",
"whatwg-fetch": "../../common/Tests/External/whatwg-fetch.3.0.0"
qunit: "../../common/Tests/External/qunit-2.9.3",
"whatwg-fetch": "../../common/Tests/External/whatwg-fetch.3.6.2"
}
});

Просмотреть файл

@ -26,9 +26,9 @@ const verifyArray = <T>() => <U extends NoRepeats<U> & readonly T[]>(
function _expectException(cb: () => void, message: string) {
try {
cb();
QUnit.ok(false, "Expected an exception: " + (message || ""));
Assert.ok(false, "Expected an exception: " + (message || ""));
} catch (e) {
QUnit.ok(true, message);
Assert.ok(true, message);
}
}
export class DynamicConfigTests extends AITestClass {
@ -732,8 +732,8 @@ export class DynamicConfigTests extends AITestClass {
// Assigning a property to a read-only property is allowed
theConfig.extensionConfig.hello = "World";
QUnit.assert.equal("World", theConfig.extensionConfig.hello, "Hello should be assigned")
QUnit.assert.deepEqual({}, theConfig.extensionConfig.test, "test should be assigned")
Assert.equal("World", theConfig.extensionConfig.hello, "Hello should be assigned")
Assert.deepEqual({}, theConfig.extensionConfig.test, "test should be assigned")
handler.rdOnly(theConfig, "anArray");
_expectException(() => {
@ -742,11 +742,11 @@ export class DynamicConfigTests extends AITestClass {
// Assigning a property to a read-only property is allowed
theConfig.anArray.hello = "World";
QUnit.assert.equal("World", theConfig.anArray.hello, "Hello should be assigned")
Assert.equal("World", theConfig.anArray.hello, "Hello should be assigned")
theConfig.anArray[0] = 0;
QUnit.assert.equal(0, theConfig.anArray[0], "0");
QUnit.assert.equal(2, theConfig.anArray[1], "2");
QUnit.assert.equal(3, theConfig.anArray[2], "3");
Assert.equal(0, theConfig.anArray[0], "0");
Assert.equal(2, theConfig.anArray[1], "2");
Assert.equal(3, theConfig.anArray[2], "3");
}
});

Просмотреть файл

@ -5,19 +5,18 @@
<meta charset="utf-8">
<meta http-equiv="Cache-control" content="no-Cache" />
<title>Tests for Application Insights JavaScript Core SDK</title>
<link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-1.23.1.css">
<script src="http://sinonjs.org/releases/sinon-2.3.8.js"></script>
<!-- <script src="http://cdnjs.cloudflare.com/ajax/libs/require.js/2.2.0/require.js"></script> -->
<script src="../../../common/Tests/External/require-2.2.0.js"></script>
<link rel="stylesheet" href="../../../common/Tests/External/qunit-2.9.3.css">
<script src="../../../common/Tests/External/sinon-2.3.8.js"></script>
<!-- <script src="../../../common/Tests/External/require-2.3.6.js"></script> -->
<script src="../../../common/Tests/External/require-2.3.6.js"></script>
<script src="../../../common/Tests/Selenium/ModuleLoader.js"></script>
<script src="../../../common/Tests/Selenium/SimpleSyncPromise.js"></script>
<script>
var modules = new ModuleLoader({
baseUrl: '../',
paths: {
qunit: "../../common/Tests/External/qunit-1.23.1",
"whatwg-fetch": "../../common/Tests/External/whatwg-fetch.3.0.0"
qunit: "../../common/Tests/External/qunit-2.9.3",
"whatwg-fetch": "../../common/Tests/External/whatwg-fetch.3.6.2"
}
});

Просмотреть файл

@ -44,7 +44,7 @@
"@microsoft/api-extractor": "^7.18.1",
"grunt": "^1.5.3",
"grunt-cli": "^1.4.3",
"grunt-contrib-qunit": "^5.0.1",
"grunt-contrib-qunit": "^6.2.1",
"@nevware21/grunt-ts-plugin": "^0.4.3",
"@nevware21/grunt-eslint-ts": "^0.2.2",
"globby": "^11.0.0",
@ -55,7 +55,7 @@
"@rollup/plugin-replace": "^2.3.3",
"rollup-plugin-cleanup": "^3.2.1",
"rollup": "^2.32.0",
"typescript": "^4.3.4",
"typescript": "^4.9.3",
"tslib": "^2.0.0",
"qunit": "^2.11.2",
"sinon": "^7.3.1"
@ -66,6 +66,6 @@
"dependencies": {
"@microsoft/applicationinsights-shims": "2.0.2",
"@microsoft/dynamicproto-js": "^1.1.7",
"@nevware21/ts-utils": "^0.6.0"
"@nevware21/ts-utils": "^0.7.0"
}
}

Просмотреть файл

@ -23,7 +23,7 @@
"devDependencies": {
"@microsoft/applicationinsights-rollup-plugin-uglify3-js": "1.0.0",
"@microsoft/applicationinsights-rollup-es5": "1.0.0",
"typescript": "^4.3.4",
"typescript": "^4.9.3",
"tslib": "^2.0.0",
"magic-string": "^0.25.7",
"@rollup/plugin-commonjs": "^18.0.0",
@ -33,7 +33,7 @@
"rollup": "^2.32.0",
"grunt": "^1.5.3",
"grunt-cli": "^1.4.3",
"grunt-contrib-qunit": "^5.0.1",
"grunt-contrib-qunit": "^6.2.1",
"@nevware21/grunt-ts-plugin": "^0.4.3",
"@nevware21/grunt-eslint-ts": "^0.2.2"
},

Просмотреть файл

@ -46,7 +46,7 @@
"@microsoft/applicationinsights-common": "2.8.9",
"@microsoft/applicationinsights-shims": "2.0.2",
"@microsoft/dynamicproto-js": "^1.1.7",
"@nevware21/ts-utils": "^0.6.0",
"@nevware21/ts-utils": "^0.7.0",
"file-saver": "^2.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
@ -72,7 +72,7 @@
"rollup-plugin-peer-deps-external": "^2.2.4",
"@nevware21/grunt-ts-plugin": "^0.4.3",
"@nevware21/grunt-eslint-ts": "^0.2.2",
"typescript": "^4.3.4",
"typescript": "^4.9.3",
"archiver": "^5.3.0"
}
}

Просмотреть файл

@ -6,15 +6,15 @@ var MAX_IMPORT_LENGTH = 140;
var IMPORT_INDENT_PREFIX = " ";
var AutoGeneratedConstFile =
"// Copyright (c) Microsoft Corporation. All rights reserved.\n" +
"// Licensed under the MIT License.\n" +
"// @skip-file-minify\n\n" +
"// ##############################################################\n" +
"// AUTO GENERATED FILE: This file is Auto Generated during build.\n" +
"// ##############################################################\n\n" +
"// ###########################################################################################################################################\n" +
"// Note: DON'T Export these const from the package as we are still targeting IE this will export a mutable variables that someone could change\n" +
"// ###########################################################################################################################################\n\n";
"// Copyright (c) Microsoft Corporation. All rights reserved.\r\n" +
"// Licensed under the MIT License.\r\n" +
"// @skip-file-minify\r\n\r\n" +
"// ##############################################################\r\n" +
"// AUTO GENERATED FILE: This file is Auto Generated during build.\r\n" +
"// ##############################################################\r\n\r\n" +
"// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r\n" +
"// Note: DON'T Export these const from the package as we are still targeting ES3 this will export a mutable variables that someone could change!!!\r\n" +
"// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r\n\r\n";
const encodeValues = ".();[]:";
const defaultGeneratedConstantFile = "./src/__DynamicConstants.ts";
@ -190,7 +190,7 @@ function readInternalConstants(theReplacements, src, from) {
}
function removeUnusedImports(parsedFile) {
//const detectImports = /^import[\s]*\{([^}]*)\}[\s]*from[\s]*\"(.*)\";$/gm;
//const detectImports = /^import[\s]*\{([^}]*)\}[\s]*from[\s]*[\"'](.*)[\"'];$/gm;
let orgSrc = parsedFile.src;
var changed = false;
@ -504,7 +504,7 @@ function replaceValues(parsedFile, theOptions, theName, values) {
});
}
newContent += theLine + "\n";
newContent += theLine.replace(/\r$/, "") + "\r\n";
if (orgLine != theLine) {
changed = true;
}
@ -674,7 +674,7 @@ function extractComments(src) {
}
function extractImports(src, theImports) {
let extractAllImports = /^[ \t]*import\s*(\{([^}]+)\}|([^;]+)|(\*))[\s]*from[\s]*\"(.*)\"(.*)$/gm;
let extractAllImports = /^[ \t]*import\s*(\{([^}]+)\}|([^;]+)|(\*))[\s]*from[\s]*[\"'](.*)[\"'](.*)$/gm;
var orgSrc = src;
var matches = extractAllImports.exec(orgSrc);
@ -728,7 +728,7 @@ function extractBanner(src, theBanner) {
}
idx++;
theBanner.push(theLine);
theBanner.push(theLine.replace(/\r$/, ""));
if (theLine.length === 0) {
// Stop at first blank line keeping the blank line
@ -738,7 +738,7 @@ function extractBanner(src, theBanner) {
// Some files have a blank line before the existing use strict
if (lines[idx] && lines[idx].trim().startsWith("\"use strict\";")) {
theBanner.push(lines[idx]);
theBanner.push(lines[idx].replace(/\r$/, ""));
idx++;
}
@ -770,15 +770,15 @@ function parseFile(filename, src) {
function formatImport(theImport, maxImportWidth) {
var newImport = theImport.org || "";
if (newImport) {
newImport += "\n";
newImport += "\r\n";
}
if (theImport.type === 2) {
if (theImport.values.length > 0) {
theImport.values.sort();
newImport = "import { " + theImport.values.join(", ") + " } from \"" + theImport.src + "\";\n";
newImport = "import { " + theImport.values.join(", ") + " } from \"" + theImport.src + "\";\r\n";
if (newImport.length > maxImportWidth) {
newImport = "import {\n";
newImport = "import {\r\n";
var theImports = theImport.values.join(", ");
var importLines = [];
while (theImports.length > maxImportWidth - 4) {
@ -791,8 +791,8 @@ function formatImport(theImport, maxImportWidth) {
theImports = theImports.substring(idx + 1).trim();
}
importLines.push(IMPORT_INDENT_PREFIX + theImports);
newImport += importLines.join("\n") + "\n";
newImport += "} from \"" + theImport.src + "\";\n";
newImport += importLines.join("\r\n") + "\r\n";
newImport += "} from \"" + theImport.src + "\";\r\n";
}
} else {
// Nothing to be imported so don't emit the import
@ -806,7 +806,7 @@ function formatImport(theImport, maxImportWidth) {
function formatFile(parsedFile, maxImportWidth) {
var newContent = "";
if (parsedFile.banner.length > 0) {
newContent += parsedFile.banner.join("\n") + "\n";
newContent += parsedFile.banner.join("\r\n") + "\r\n";
}
if (parsedFile.imports.length > 0) {
@ -835,11 +835,11 @@ function formatFile(parsedFile, maxImportWidth) {
}
if (importContent) {
newContent += importContent + "\n";
newContent += importContent + "\r\n";
}
}
newContent += parsedFile.src.trim() + "\n";
newContent += parsedFile.src.trim() + "\r\n";
return newContent;
}
@ -1262,7 +1262,7 @@ function minifyNamesFn(grunt) {
newValues.forEach((name) => {
if (name) {
let dupCheckValue = name.value.toUpperCase();
generatedConstants += "export const " + createDynamicName(name.value, added.indexOf(dupCheckValue) !== -1) + " = \"" + name.value + "\"; // Count: " + name.count + "\n";
generatedConstants += "export const " + createDynamicName(name.value, added.indexOf(dupCheckValue) !== -1) + " = \"" + name.value + "\"; // Count: " + name.count + "\r\n";
added.push(dupCheckValue);
}
});

Просмотреть файл

@ -9,13 +9,12 @@
<script src="https://sinonjs.org/releases/sinon-2.3.8.js"></script>
<script src="../../../common/Tests/External/require-2.2.0.js"></script>
<script src="../../../common/Tests/Selenium/ModuleLoader.js"></script>
<script src="../../../common/Tests/Selenium/SimpleSyncPromise.js"></script>
<script>
var modules = new ModuleLoader({
baseUrl: '../',
paths: {
qunit: "../../common/Tests/External/qunit-1.23.1",
qunit: "../../common/Tests/External/qunit-2.9.3",
"magic-string": "../../common/Tests/External/magic-string.umd",
}
});
@ -44,4 +43,29 @@
<div id="error-message"></div>
</body>
</html>
// Load Core
modules.add("@microsoft/applicationinsights-core-js", "./node_modules/@microsoft/applicationinsights-core-js/browser/applicationinsights-core-js");
// Load Common
modules.add("@microsoft/applicationinsights-common", "./node_modules/@microsoft/applicationinsights-common/browser/applicationinsights-common");
var testModule = modules.add("Tests/Unit/src/prop.tests", "./Unit/dist/prop.tests.js")
testModule.run = function (tests) {
console && console.log("Starting tests");
QUnit.start();
tests.runTests();
};
modules.run();
</script>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<div id="error-message"></div>
</body>
</html>

Просмотреть файл

@ -5,9 +5,12 @@
"noImplicitAny": false,
"module": "amd",
"moduleResolution": "Node",
"target": "es5",
"target": "es6",
"importHelpers": true,
"noEmitHelpers": true,
"skipLibCheck": true,
"alwaysStrict": true,
"declaration": true
},
},
"files": []
}
}

Просмотреть файл

@ -32,11 +32,12 @@
"license": "MIT",
"sideEffects": false,
"devDependencies": {
"@types/qunit": "^2.19.3",
"@microsoft/ai-test-framework": "0.0.1",
"@microsoft/applicationinsights-rollup-plugin-uglify3-js": "1.0.0",
"grunt": "^1.5.3",
"grunt-cli": "^1.4.3",
"grunt-contrib-qunit": "^5.0.1",
"grunt-contrib-qunit": "^6.2.1",
"@nevware21/grunt-ts-plugin": "^0.4.3",
"@nevware21/grunt-eslint-ts": "^0.2.2",
"@rollup/plugin-commonjs": "^18.0.0",
@ -44,7 +45,7 @@
"@rollup/plugin-replace": "^2.3.3",
"rollup-plugin-minify-es": "^1.1.1",
"rollup": "^2.32.0",
"typescript": "^4.3.4",
"typescript": "^4.9.3",
"tslib": "^2.0.0",
"magic-string": "^0.25.7",
"chromium": "^3.0.2"

Просмотреть файл

@ -27,7 +27,7 @@
"devDependencies": {
"grunt": "^1.5.3",
"grunt-cli": "^1.4.3",
"grunt-contrib-qunit": "^5.0.1",
"grunt-contrib-qunit": "^6.2.1",
"@nevware21/grunt-ts-plugin": "^0.4.3",
"@nevware21/grunt-eslint-ts": "^0.2.2",
"@rollup/plugin-commonjs": "^18.0.0",
@ -35,7 +35,7 @@
"@rollup/plugin-replace": "^2.3.3",
"rollup-plugin-minify-es": "^1.1.1",
"rollup": "^2.32.0",
"typescript": "^4.3.4",
"typescript": "^4.9.3",
"tslib": "^2.0.0"
},
"peerDependencies": {

Просмотреть файл

@ -63,19 +63,19 @@ export class ShimsTests extends AITestClass {
name: "__objAssignImplFn should be assigned values to target",
test: () => {
let t = __objAssignFnImpl({}, {a:1}, {b:2});
QUnit.equal(t.a, 1, "Checking expected value");
QUnit.equal(t.b, 2, "Checking expected value");
QUnit.assert.equal(t.a, 1, "Checking expected value");
QUnit.assert.equal(t.b, 2, "Checking expected value");
// check overwrite
t = __objAssignFnImpl({a:0}, {a:1}, {b:2});
QUnit.equal(t.a, 1, "Checking expected value");
QUnit.equal(t.b, 2, "Checking expected value");
QUnit.assert.equal(t.a, 1, "Checking expected value");
QUnit.assert.equal(t.b, 2, "Checking expected value");
// check target
t = __objAssignFnImpl({x:0}, {a:1}, {b:2});
QUnit.equal(t.x, 0, "Checking expected value");
QUnit.equal(t.a, 1, "Checking expected value");
QUnit.equal(t.b, 2, "Checking expected value");
QUnit.assert.equal(t.x, 0, "Checking expected value");
QUnit.assert.equal(t.a, 1, "Checking expected value");
QUnit.assert.equal(t.b, 2, "Checking expected value");
}
});
@ -83,19 +83,19 @@ export class ShimsTests extends AITestClass {
name: "__assignFn should be assigned values to target",
test: () => {
let t = __assignFn({}, {a:1}, {b:2});
QUnit.equal(t.a, 1, "Checking expected value");
QUnit.equal(t.b, 2, "Checking expected value");
QUnit.assert.equal(t.a, 1, "Checking expected value");
QUnit.assert.equal(t.b, 2, "Checking expected value");
// check overwrite
t = __assignFn({a:0}, {a:1}, {b:2});
QUnit.equal(t.a, 1, "Checking expected value");
QUnit.equal(t.b, 2, "Checking expected value");
QUnit.assert.equal(t.a, 1, "Checking expected value");
QUnit.assert.equal(t.b, 2, "Checking expected value");
// check target
t = __assignFn({x:0}, {a:1}, {b:2});
QUnit.equal(t.x, 0, "Checking expected value");
QUnit.equal(t.a, 1, "Checking expected value");
QUnit.equal(t.b, 2, "Checking expected value");
QUnit.assert.equal(t.x, 0, "Checking expected value");
QUnit.assert.equal(t.a, 1, "Checking expected value");
QUnit.assert.equal(t.b, 2, "Checking expected value");
}
});

Просмотреть файл

@ -5,18 +5,17 @@
<meta charset="utf-8">
<meta http-equiv="Cache-control" content="no-Cache" />
<title>Tests for Shims</title>
<link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-1.23.1.css">
<script src="http://sinonjs.org/releases/sinon-2.3.8.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/require.js/2.2.0/require.js"></script>
<link rel="stylesheet" href="../../../common/Tests/External/qunit-2.9.3.css">
<script src="../../../common/Tests/External/sinon-2.3.8.js"></script>
<script src="../../../common/Tests/External/require-2.3.6.js"></script>
<script src="../../../common/Tests/Selenium/ModuleLoader.js"></script>
<script src="../../../common/Tests/Selenium/SimpleSyncPromise.js"></script>
<script>
var modules = new ModuleLoader({
baseUrl: '../',
paths: {
qunit: "../../common/Tests/External/qunit-1.23.1",
"whatwg-fetch": "../../common/Tests/External/whatwg-fetch.3.0.0"
qunit: "../../common/Tests/External/qunit-2.9.3",
"whatwg-fetch": "../../common/Tests/External/whatwg-fetch.3.6.2"
}
});

Просмотреть файл

@ -34,12 +34,13 @@
"**/TsLibGlobals.ts"
],
"devDependencies": {
"@types/qunit": "^2.19.3",
"@microsoft/ai-test-framework": "0.0.1",
"@microsoft/applicationinsights-rollup-plugin-uglify3-js": "1.0.0",
"@microsoft/applicationinsights-rollup-es5" : "1.0.0",
"grunt": "^1.5.3",
"grunt-cli": "^1.4.3",
"grunt-contrib-qunit": "^5.0.1",
"grunt-contrib-qunit": "^6.2.1",
"@nevware21/grunt-ts-plugin": "^0.4.3",
"@nevware21/grunt-eslint-ts": "^0.2.2",
"@rollup/plugin-commonjs": "^18.0.0",
@ -47,7 +48,7 @@
"@rollup/plugin-replace": "^2.3.3",
"rollup-plugin-minify-es": "^1.1.1",
"rollup": "^2.32.0",
"typescript": "^4.3.4"
"typescript": "^4.9.3"
},
"dependencies": {
}