tfcconnection-zola/.shadow-cljs/builds/app/dev/goog-js/goog.labs.useragent.highentropy.highentropyvalue.js

1 line
13 KiB
JavaScript

["^ ","~:resource-id",["~:shadow.build.classpath/resource","goog/labs/useragent/highentropy/highentropyvalue.js"],"~:js","goog.loadModule(function(exports) {\n \"use strict\";\n goog.module(\"goog.labs.userAgent.highEntropy.highEntropyValue\");\n const util = goog.require(\"goog.labs.userAgent.util\");\n const {compareVersions} = goog.require(\"goog.string.internal\");\n class AsyncValue {\n getIfLoaded() {\n }\n load() {\n }\n }\n exports.AsyncValue = AsyncValue;\n class HighEntropyValue {\n constructor(key) {\n this.key_ = key;\n this.value_ = undefined;\n this.promise_ = undefined;\n this.pending_ = false;\n }\n getIfLoaded() {\n const userAgentData = util.getUserAgentData();\n if (!userAgentData) {\n return undefined;\n }\n return this.value_;\n }\n async load() {\n const userAgentData = util.getUserAgentData();\n if (!userAgentData) {\n return undefined;\n }\n if (!this.promise_) {\n this.pending_ = true;\n this.promise_ = (async() => {\n try {\n const dataValues = await userAgentData.getHighEntropyValues([this.key_]);\n this.value_ = dataValues[this.key_];\n return this.value_;\n } finally {\n this.pending_ = false;\n }\n })();\n }\n return await this.promise_;\n }\n resetForTesting() {\n if (this.pending_) {\n throw new Error(\"Unsafe call to resetForTesting\");\n }\n this.promise_ = undefined;\n this.value_ = undefined;\n this.pending_ = false;\n }\n }\n exports.HighEntropyValue = HighEntropyValue;\n class Version {\n constructor(versionString) {\n this.versionString_ = versionString;\n }\n toVersionStringForLogging() {\n return this.versionString_;\n }\n isAtLeast(version) {\n return compareVersions(this.versionString_, version) >= 0;\n }\n }\n exports.Version = Version;\n return exports;\n});\n","~:source","/**\n * @license\n * Copyright The Closure Library Authors.\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/**\n * @fileoverview Provides helper classes and objects to work with High Entropy\n * user agent values.\n */\n\ngoog.module('goog.labs.userAgent.highEntropy.highEntropyValue');\n\nconst util = goog.require('goog.labs.userAgent.util');\nconst {compareVersions} = goog.require('goog.string.internal');\n\n/**\n * Represents a value that can be asynchronously loaded.\n * @interface\n * @template VALUE_TYPE\n */\nclass AsyncValue {\n /**\n * Get the value represented by this AsyncValue instance, if it was\n * previously requested.\n * @return {VALUE_TYPE|undefined}\n */\n getIfLoaded() {}\n\n /**\n * Request the value represented by this AsyncValue instance.\n * @return {!Promise<VALUE_TYPE>}\n */\n load() {}\n}\nexports.AsyncValue = AsyncValue;\n\n/**\n * Represents a high-entropy value.\n * High-entropy values must be specifically requested from the Promise-based\n * Client Hints API.\n * @template VALUE_TYPE The type of the value wrapped by this HighEntropyValue\n * instance.\n * @implements {AsyncValue<VALUE_TYPE>}\n */\nclass HighEntropyValue {\n /**\n * Constructs a new HighEntropyValue instance.\n * @param {string} key The name of the high-entropy value, used when\n * requesting it from the browser.\n */\n constructor(key) {\n /**\n * The key used to request the high-entropy value from the browser.\n * @const {string}\n * @private\n */\n this.key_ = key;\n\n /**\n * The value represented by this HighEntropyValue instance. If it hasn't\n * been successfully requested yet, its value will be undefined.\n * @type {VALUE_TYPE|undefined}\n * @protected\n */\n this.value_ = undefined;\n\n /**\n * The high-entropy value request. If it hasn't been requested yet, this\n * value will be undefined.\n * @type {!Promise<VALUE_TYPE>|undefined}\n * @private\n */\n this.promise_ = undefined;\n\n this.pending_ = false;\n }\n\n /**\n * @return {VALUE_TYPE|undefined}\n * @override\n */\n getIfLoaded() {\n const userAgentData = util.getUserAgentData();\n if (!userAgentData) {\n return undefined;\n }\n return this.value_;\n }\n\n /**\n * @return {!Promise<VALUE_TYPE>}\n * @override\n */\n async load() {\n const userAgentData = util.getUserAgentData();\n if (!userAgentData) return undefined;\n if (!this.promise_) {\n this.pending_ = true;\n this.promise_ = (async () => {\n try {\n const dataValues =\n await userAgentData.getHighEntropyValues([this.key_]);\n this.value_ =\n /** @type {!Object<string, VALUE_TYPE>} */ (\n dataValues)[this.key_];\n return this.value_;\n } finally {\n this.pending_ = false;\n }\n })();\n }\n return await this.promise_;\n }\n\n resetForTesting() {\n if (this.pending_) {\n // There is a pending request that may set this.value_ at any time.\n // Therefore, it can't be guaranteed that this object is actually in a\n // clean state.\n throw new Error('Unsafe call to resetForTesting');\n }\n this.promise_ = undefined;\n this.value_ = undefined;\n this.pending_ = false;\n }\n}\nexports.HighEntropyValue = HighEntropyValue;\n\n/**\n * An object that wraps a version string.\n * This allows for easy version comparisons.\n */\nclass Version {\n /**\n * @param {string} versionString The underlying version string.\n */\n constructor(versionString) {\n /**\n * @const {string}\n * @private\n */\n this.versionString_ = versionString;\n }\n\n /**\n * Returns the underlying version string.\n * @return {string}\n */\n toVersionStringForLogging() {\n return this.versionString_;\n }\n\n /**\n * Returns true if the underlying version string is equal to or greater than\n * the given version.\n * @param {string} version The version to compare against.\n * @return {boolean}\n */\n isAtLeast(version) {\n return compareVersions(this.versionString_, version) >= 0;\n }\n}\nexports.Version = Version;\n","~:compiled-at",1684858197893,"~:source-map-json","{\n\"version\":3,\n\"file\":\"goog.labs.useragent.highentropy.highentropyvalue.js\",\n\"lineCount\":70,\n\"mappings\":\"AAAA,IAAA,CAAA,UAAA,CAAA,QAAA,CAAA,OAAA,CAAA;AAAA,cAAA;AAWAA,MAAKC,CAAAA,MAAL,CAAY,kDAAZ,CAAA;AAEA,QAAMC,OAAOF,IAAKG,CAAAA,OAAL,CAAa,0BAAb,CAAb;AACA,QAAM,CAACC,eAAD,CAAA,GAAoBJ,IAAKG,CAAAA,OAAL,CAAa,sBAAb,CAA1B;AAOA,OAAME,WAAN;AAMEC,eAAW,EAAG;;AAMdC,QAAI,EAAG;;AAZT;AAcAC,SAAQH,CAAAA,UAAR,GAAqBA,UAArB;AAUA,OAAMI,iBAAN;AAMEC,eAAW,CAACC,GAAD,CAAM;AAMf,UAAKC,CAAAA,IAAL,GAAYD,GAAZ;AAQA,UAAKE,CAAAA,MAAL,GAAcC,SAAd;AAQA,UAAKC,CAAAA,QAAL,GAAgBD,SAAhB;AAEA,UAAKE,CAAAA,QAAL,GAAgB,KAAhB;AAx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B;AAU5BE,aAAS,CAACC,OAAD,CAAU;AACjB,aAAOxB,eAAA,CAAgB,IAAKqB,CAAAA,cAArB,EAAqCG,OAArC,CAAP,IAAwD,CAAxD;AADiB;AA1BrB;AA8BApB,SAAQe,CAAAA,OAAR,GAAkBA,OAAlB;AAnKA,SAAA,OAAA;AAAA,CAAA,CAAA;;\",\n\"sources\":[\"goog/labs/useragent/highentropy/highentropyvalue.js\"],\n\"sourcesContent\":[\"/**\\n * @license\\n * Copyright The Closure Library Authors.\\n * SPDX-License-Identifier: Apache-2.0\\n */\\n\\n/**\\n * @fileoverview Provides helper classes and objects to work with High Entropy\\n * user agent values.\\n */\\n\\ngoog.module('goog.labs.userAgent.highEntropy.highEntropyValue');\\n\\nconst util = goog.require('goog.labs.userAgent.util');\\nconst {compareVersions} = goog.require('goog.string.internal');\\n\\n/**\\n * Represents a value that can be asynchronously loaded.\\n * @interface\\n * @template VALUE_TYPE\\n */\\nclass AsyncValue {\\n /**\\n * Get the value represented by this AsyncValue instance, if it was\\n * previously requested.\\n * @return {VALUE_TYPE|undefined}\\n */\\n getIfLoaded() {}\\n\\n /**\\n * Request the value represented by this AsyncValue instance.\\n * @return {!Promise<VALUE_TYPE>}\\n */\\n load() {}\\n}\\nexports.AsyncValue = AsyncValue;\\n\\n/**\\n * Represents a high-entropy value.\\n * High-entropy values must be specifically requested from the Promise-based\\n * Client Hints API.\\n * @template VALUE_TYPE The type of the value wrapped by this HighEntropyValue\\n * instance.\\n * @implements {AsyncValue<VALUE_TYPE>}\\n */\\nclass HighEntropyValue {\\n /**\\n * Constructs a new HighEntropyValue instance.\\n * @param {string} key The name of the high-entropy value, used when\\n * requesting it from the browser.\\n */\\n constructor(key) {\\n /**\\n * The key used to request the high-entropy value from the browser.\\n * @const {string}\\n * @private\\n */\\n this.key_ = key;\\n\\n /**\\n * The value represented by this HighEntropyValue instance. If it hasn't\\n * been successfully requested yet, its value will be undefined.\\n * @type {VALUE_TYPE|undefined}\\n * @protected\\n */\\n this.value_ = undefined;\\n\\n /**\\n * The high-entropy value request. If it hasn't been requested yet, this\\n * value will be undefined.\\n * @type {!Promise<VALUE_TYPE>|undefined}\\n * @private\\n */\\n this.promise_ = undefined;\\n\\n this.pending_ = false;\\n }\\n\\n /**\\n * @return {VALUE_TYPE|undefined}\\n * @override\\n */\\n getIfLoaded() {\\n const userAgentData = util.getUserAgentData();\\n if (!userAgentData) {\\n return undefined;\\n }\\n return this.value_;\\n }\\n\\n /**\\n * @return {!Promise<VALUE_TYPE>}\\n * @override\\n */\\n async load() {\\n const userAgentData = util.getUserAgentData();\\n if (!userAgentData) return undefined;\\n if (!this.promise_) {\\n this.pending_ = true;\\n this.promise_ = (async () => {\\n try {\\n const dataValues =\\n await userAgentData.getHighEntropyValues([this.key_]);\\n this.value_ =\\n /** @type {!Object<string, VALUE_TYPE>} */ (\\n dataValues)[this.key_];\\n return this.value_;\\n } finally {\\n this.pending_ = false;\\n }\\n })();\\n }\\n return await this.promise_;\\n }\\n\\n resetForTesting() {\\n if (this.pending_) {\\n // There is a pending request that may set this.value_ at any time.\\n // Therefore, it can't be guaranteed that this object is actually in a\\n // clean state.\\n throw new Error('Unsafe call to resetForTesting');\\n }\\n this.promise_ = undefined;\\n this.value_ = undefined;\\n this.pending_ = false;\\n }\\n}\\nexports.HighEntropyValue = HighEntropyValue;\\n\\n/**\\n * An object that wraps a version string.\\n * This allows for easy version comparisons.\\n */\\nclass Version {\\n /**\\n * @param {string} versionString The underlying version string.\\n */\\n constructor(versionString) {\\n /**\\n * @const {string}\\n * @private\\n */\\n this.versionString_ = versionString;\\n }\\n\\n /**\\n * Returns the underlying version string.\\n * @return {string}\\n */\\n toVersionStringForLogging() {\\n return this.versionString_;\\n }\\n\\n /**\\n * Returns true if the underlying version string is equal to or greater than\\n * the given version.\\n * @param {string} version The version to compare against.\\n * @return {boolean}\\n */\\n isAtLeast(version) {\\n return compareVersions(this.versionString_, version) >= 0;\\n }\\n}\\nexports.Version = Version;\\n\"],\n\"names\":[\"goog\",\"module\",\"util\",\"require\",\"compareVersions\",\"AsyncValue\",\"getIfLoaded\",\"load\",\"exports\",\"HighEntropyValue\",\"constructor\",\"key\",\"key_\",\"value_\",\"undefined\",\"promise_\",\"pending_\",\"userAgentData\",\"getUserAgentData\",\"dataValues\",\"getHighEntropyValues\",\"resetForTesting\",\"Error\",\"Version\",\"versionString\",\"versionString_\",\"toVersionStringForLogging\",\"isAtLeast\",\"version\"]\n}\n"]