mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
1 line
6.9 KiB
JSON
1 line
6.9 KiB
JSON
{"ast":null,"code":"import { bindReporter } from './lib/bindReporter.js';\nimport { initMetric } from './lib/initMetric.js';\nimport { observe } from './lib/observe.js';\nimport { onHidden } from './lib/onHidden.js';\n\n/*\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// https://wicg.github.io/layout-instability/#sec-layout-shift\n\nvar getCLS = (onReport, reportAllChanges) => {\n var metric = initMetric('CLS', 0);\n let report;\n let sessionValue = 0;\n let sessionEntries = [];\n var entryHandler = entry => {\n // Only count layout shifts without recent user input.\n // TODO: Figure out why entry can be undefined\n if (entry && !entry.hadRecentInput) {\n var firstSessionEntry = sessionEntries[0];\n var lastSessionEntry = sessionEntries[sessionEntries.length - 1];\n\n // If the entry occurred less than 1 second after the previous entry and\n // less than 5 seconds after the first entry in the session, include the\n // entry in the current session. Otherwise, start a new session.\n if (sessionValue && sessionEntries.length !== 0 && entry.startTime - lastSessionEntry.startTime < 1000 && entry.startTime - firstSessionEntry.startTime < 5000) {\n sessionValue += entry.value;\n sessionEntries.push(entry);\n } else {\n sessionValue = entry.value;\n sessionEntries = [entry];\n }\n\n // If the current session value is larger than the current CLS value,\n // update CLS and the entries contributing to it.\n if (sessionValue > metric.value) {\n metric.value = sessionValue;\n metric.entries = sessionEntries;\n if (report) {\n report();\n }\n }\n }\n };\n var po = observe('layout-shift', entryHandler);\n if (po) {\n report = bindReporter(onReport, metric, reportAllChanges);\n onHidden(() => {\n po.takeRecords().map(entryHandler);\n report(true);\n });\n }\n};\nexport { getCLS };","map":{"version":3,"names":["bindReporter","initMetric","observe","onHidden","getCLS","onReport","reportAllChanges","metric","report","sessionValue","sessionEntries","entryHandler","entry","hadRecentInput","firstSessionEntry","lastSessionEntry","length","startTime","value","push","entries","po","takeRecords","map"],"sources":["C:/Users/eudes.inacio/GabineteDigital/gabinete-digital-fo/node_modules/@sentry/tracing/esm/browser/web-vitals/getCLS.js"],"sourcesContent":["import { bindReporter } from './lib/bindReporter.js';\nimport { initMetric } from './lib/initMetric.js';\nimport { observe } from './lib/observe.js';\nimport { onHidden } from './lib/onHidden.js';\n\n/*\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// https://wicg.github.io/layout-instability/#sec-layout-shift\n\nvar getCLS = (onReport, reportAllChanges) => {\n var metric = initMetric('CLS', 0);\n let report;\n\n let sessionValue = 0;\n let sessionEntries = [];\n\n var entryHandler = (entry) => {\n // Only count layout shifts without recent user input.\n // TODO: Figure out why entry can be undefined\n if (entry && !entry.hadRecentInput) {\n var firstSessionEntry = sessionEntries[0];\n var lastSessionEntry = sessionEntries[sessionEntries.length - 1];\n\n // If the entry occurred less than 1 second after the previous entry and\n // less than 5 seconds after the first entry in the session, include the\n // entry in the current session. Otherwise, start a new session.\n if (\n sessionValue &&\n sessionEntries.length !== 0 &&\n entry.startTime - lastSessionEntry.startTime < 1000 &&\n entry.startTime - firstSessionEntry.startTime < 5000\n ) {\n sessionValue += entry.value;\n sessionEntries.push(entry);\n } else {\n sessionValue = entry.value;\n sessionEntries = [entry];\n }\n\n // If the current session value is larger than the current CLS value,\n // update CLS and the entries contributing to it.\n if (sessionValue > metric.value) {\n metric.value = sessionValue;\n metric.entries = sessionEntries;\n if (report) {\n report();\n }\n }\n }\n };\n\n var po = observe('layout-shift', entryHandler );\n if (po) {\n report = bindReporter(onReport, metric, reportAllChanges);\n\n onHidden(() => {\n po.takeRecords().map(entryHandler );\n report(true);\n });\n }\n};\n\nexport { getCLS };\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,uBAAuB;AACpD,SAASC,UAAU,QAAQ,qBAAqB;AAChD,SAASC,OAAO,QAAQ,kBAAkB;AAC1C,SAASC,QAAQ,QAAQ,mBAAmB;;AAE5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,IAAIC,MAAM,GAAGA,CAACC,QAAQ,EAAEC,gBAAgB,KAAK;EAC3C,IAAIC,MAAM,GAAGN,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC;EACjC,IAAIO,MAAM;EAEV,IAAIC,YAAY,GAAG,CAAC;EACpB,IAAIC,cAAc,GAAG,EAAE;EAEvB,IAAIC,YAAY,GAAIC,KAAK,IAAK;IAC5B;IACA;IACA,IAAIA,KAAK,IAAI,CAACA,KAAK,CAACC,cAAc,EAAE;MAClC,IAAIC,iBAAiB,GAAGJ,cAAc,CAAC,CAAC,CAAC;MACzC,IAAIK,gBAAgB,GAAGL,cAAc,CAACA,cAAc,CAACM,MAAM,GAAG,CAAC,CAAC;;MAEhE;MACA;MACA;MACA,IACEP,YAAY,IACZC,cAAc,CAACM,MAAM,KAAK,CAAC,IAC3BJ,KAAK,CAACK,SAAS,GAAGF,gBAAgB,CAACE,SAAS,GAAG,IAAI,IACnDL,KAAK,CAACK,SAAS,GAAGH,iBAAiB,CAACG,SAAS,GAAG,IAAI,EACpD;QACAR,YAAY,IAAIG,KAAK,CAACM,KAAK;QAC3BR,cAAc,CAACS,IAAI,CAACP,KAAK,CAAC;MAC5B,CAAC,MAAM;QACLH,YAA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