Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
1 line
3.5 KiB
Plaintext
1 line
3.5 KiB
Plaintext
{"version":3,"file":"LayoutShiftManager.js","sources":["../../../../../src/metrics/web-vitals/lib/LayoutShiftManager.ts"],"sourcesContent":["/* eslint-disable jsdoc/require-jsdoc */\n/*\n * Copyright 2024 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\nexport class LayoutShiftManager {\n // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility\n _onAfterProcessingUnexpectedShift?: (entry: LayoutShift) => void;\n\n // eslint-disable-next-line @sentry-internal/sdk/no-class-field-initializers, @typescript-eslint/explicit-member-accessibility\n _sessionValue = 0;\n // eslint-disable-next-line @sentry-internal/sdk/no-class-field-initializers, @typescript-eslint/explicit-member-accessibility\n _sessionEntries: LayoutShift[] = [];\n\n // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility\n _processEntry(entry: LayoutShift) {\n // Only count layout shifts without recent user input.\n if (entry.hadRecentInput) return;\n\n const firstSessionEntry = this._sessionEntries[0];\n // This previously used `this._sessionEntries.at(-1)` but that is ES2022. We support ES2021 and earlier.\n const lastSessionEntry = this._sessionEntries[this._sessionEntries.length - 1];\n\n // If the entry occurred less than 1 second after the previous entry\n // and less than 5 seconds after the first entry in the session,\n // include the entry in the current session. Otherwise, start a new\n // session.\n if (\n this._sessionValue &&\n firstSessionEntry &&\n lastSessionEntry &&\n entry.startTime - lastSessionEntry.startTime < 1000 &&\n entry.startTime - firstSessionEntry.startTime < 5000\n ) {\n this._sessionValue += entry.value;\n this._sessionEntries.push(entry);\n } else {\n this._sessionValue = entry.value;\n this._sessionEntries = [entry];\n }\n\n this._onAfterProcessingUnexpectedShift?.(entry);\n }\n}\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEO,MAAM,kBAAA,CAAmB,CAAA,WAAA,GAAA,EAAA,kBAAA,CAAA,SAAA,CAAA,MAAA,CAAA,IAAA,CAAA,IAAA,CAAA,CAAA,kBAAA,CAAA,SAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,CAAA,CAAA;AAChC;;AAGA;AACA,EAAA,MAAA,GAAA,CAAA,IAAA,CAAE,aAAA,GAAgB,EAAA;AAClB;AACA,EAAA,OAAA,GAAA,CAAA,IAAA,CAAE,eAAe,GAAkB,GAAC;;AAEpC;AACA,EAAE,aAAa,CAAC,KAAK,EAAe;AACpC;AACA,IAAI,IAAI,KAAK,CAAC,cAAc,EAAE;;AAE9B,IAAI,MAAM,oBAAoB,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC;AACrD;AACA,IAAI,MAAM,gBAAA,GAAmB,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,eAAe,CAAC,MAAA,GAAS,CAAC,CAAC;;AAElF;AACA;AACA;AACA;AACA,IAAI;AACJ,MAAM,IAAI,CAAC,aAAA;AACX,MAAM,iBAAA;AACN,MAAM,gBAAA;AACN,MAAM,KAAK,CAAC,SAAA,GAAY,gBAAgB,CAAC,SAAA,GAAY,IAAA;AACrD,MAAM,KAAK,CAAC,SAAA,GAAY,iBAAiB,CAAC,YAAY;AACtD,MAAM;AACN,MAAM,IAAI,CAAC,aAAA,IA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