@typespec/ts-http-runtime 1.0.0-alpha.20240619.3 → 1.0.0-alpha.20240621.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userAgentPlatform-browser.d.mts","sourceRoot":"","sources":["../../../src/util/userAgentPlatform-browser.mts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;
|
|
1
|
+
{"version":3,"file":"userAgentPlatform-browser.d.mts","sourceRoot":"","sources":["../../../src/util/userAgentPlatform-browser.mts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAmCD;;GAEG;AACH,wBAAsB,uBAAuB,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBrF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userAgentPlatform-browser.mjs","sourceRoot":"","sources":["../../../src/util/userAgentPlatform-browser.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAsBD,SAAS,qBAAqB,CAC5B,MAA4C;IAE5C,
|
|
1
|
+
{"version":3,"file":"userAgentPlatform-browser.mjs","sourceRoot":"","sources":["../../../src/util/userAgentPlatform-browser.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAsBD,SAAS,qBAAqB,CAC5B,MAA4C;IAE5C,MAAM,UAAU,GAAG,CAAC,eAAe,EAAE,gBAAgB,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;IAC5E,KAAK,MAAM,KAAK,IAAI,UAAU,EAAE,CAAC;QAC/B,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;QACzD,IAAI,UAAU,EAAE,CAAC;YACf,OAAO,UAAU,CAAC;QACpB,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,GAAwB;IACpE,MAAM,cAAc,GAAG,UAAU,CAAC,SAAwB,CAAC;IAC3D,IAAI,UAAU,GAAG,SAAS,CAAC;IAC3B,IAAI,cAAc,CAAC,aAAa,EAAE,CAAC;QACjC,MAAM,aAAa,GAAG,MAAM,cAAc,CAAC,aAAa,CAAC,oBAAoB,CAAC;YAC5E,cAAc;YACd,iBAAiB;SAClB,CAAC,CAAC;QACH,UAAU,GAAG,GAAG,aAAa,CAAC,YAAY,IAAI,aAAa,CAAC,QAAQ,IAAI,aAAa,CAAC,eAAe,EAAE,CAAC;QAExG,4BAA4B;QAC5B,MAAM,KAAK,GAAG,qBAAqB,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAC1D,IAAI,KAAK,EAAE,CAAC;YACV,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;SAAM,IAAI,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,QAAQ,EAAE,CAAC;QACpC,UAAU,GAAG,cAAc,CAAC,QAAQ,CAAC;IACvC,CAAC;IAED,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;AAC5B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * @internal\n */\nexport function getHeaderName(): string {\n return \"x-ms-useragent\";\n}\n\ninterface NavigatorEx extends Navigator {\n userAgentData?: {\n brands: { brand: string; version: string }[];\n mobile: boolean;\n platform?: string;\n getHighEntropyValues: (hints: string[]) => Promise<{\n architecture: string;\n bitness: string;\n brands: { brand: string; version: string }[];\n formFactor: string;\n fullVersionList: { brand: string; version: string }[];\n mobile: boolean;\n model: string;\n platform: string;\n platformVersion: string;\n wow64: boolean;\n }>;\n };\n}\n\nfunction getBrandVersionString(\n brands: { brand: string; version: string }[],\n): { brand: string; version: string } | undefined {\n const brandOrder = [\"Google Chrome\", \"Microsoft Edge\", \"Brave\", \"Chromium\"];\n for (const brand of brandOrder) {\n const foundBrand = brands.find((b) => b.brand === brand);\n if (foundBrand) {\n return foundBrand;\n }\n }\n return undefined;\n}\n\n/**\n * @internal\n */\nexport async function setPlatformSpecificData(map: Map<string, string>): Promise<void> {\n const localNavigator = globalThis.navigator as NavigatorEx;\n let osPlatform = \"unknown\";\n if (localNavigator.userAgentData) {\n const entropyValues = await localNavigator.userAgentData.getHighEntropyValues([\n \"architecture\",\n \"platformVersion\",\n ]);\n osPlatform = `${entropyValues.architecture}-${entropyValues.platform}-${entropyValues.platformVersion}`;\n\n // Get the brand and version\n const brand = getBrandVersionString(entropyValues.brands);\n if (brand) {\n map.set(brand.brand, brand.version);\n }\n } else if (localNavigator?.platform) {\n osPlatform = localNavigator.platform;\n }\n\n map.set(\"OS\", osPlatform);\n}\n"]}
|
|
@@ -7,20 +7,12 @@ export function getHeaderName() {
|
|
|
7
7
|
return "x-ms-useragent";
|
|
8
8
|
}
|
|
9
9
|
function getBrandVersionString(brands) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const chrome = brands.find((b) => b.brand === "Google Chrome");
|
|
17
|
-
if (chrome) {
|
|
18
|
-
return chrome;
|
|
19
|
-
}
|
|
20
|
-
// Check for Chromium
|
|
21
|
-
const chromium = brands.find((b) => b.brand === "Chromium");
|
|
22
|
-
if (chromium) {
|
|
23
|
-
return chromium;
|
|
10
|
+
const brandOrder = ["Google Chrome", "Microsoft Edge", "Brave", "Chromium"];
|
|
11
|
+
for (const brand of brandOrder) {
|
|
12
|
+
const foundBrand = brands.find((b) => b.brand === brand);
|
|
13
|
+
if (foundBrand) {
|
|
14
|
+
return foundBrand;
|
|
15
|
+
}
|
|
24
16
|
}
|
|
25
17
|
return undefined;
|
|
26
18
|
}
|
package/package.json
CHANGED