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
2.8 KiB
Plaintext
1 line
2.8 KiB
Plaintext
{"version":3,"file":"initMetric.js","sources":["../../../../../src/metrics/web-vitals/lib/initMetric.ts"],"sourcesContent":["/*\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\nimport { WINDOW } from '../../../types';\nimport type { MetricType } from '../types';\nimport { generateUniqueID } from './generateUniqueID';\nimport { getActivationStart } from './getActivationStart';\nimport { getNavigationEntry } from './getNavigationEntry';\n\nexport const initMetric = <MetricName extends MetricType['name']>(name: MetricName, value: number = -1) => {\n const navEntry = getNavigationEntry();\n let navigationType: MetricType['navigationType'] = 'navigate';\n\n if (navEntry) {\n if (WINDOW.document?.prerendering || getActivationStart() > 0) {\n navigationType = 'prerender';\n } else if (WINDOW.document?.wasDiscarded) {\n navigationType = 'restore';\n } else if (navEntry.type) {\n navigationType = navEntry.type.replace(/_/g, '-') as MetricType['navigationType'];\n }\n }\n\n // Use `entries` type specific for the metric.\n const entries: Extract<MetricType, { name: MetricName }>['entries'] = [];\n\n return {\n name,\n value,\n rating: 'good' as const, // If needed, will be updated when reported. `const` to keep the type from widening to `string`.\n delta: 0,\n entries,\n id: generateUniqueID(),\n navigationType,\n };\n};\n"],"names":["getNavigationEntry","WINDOW","getActivationStart","generateUniqueID"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAQO,MAAM,UAAA,GAAa,CAAwC,IAAI,EAAc,KAAK,GAAW,EAAE,KAAK;AAC3G,EAAE,MAAM,QAAA,GAAWA,qCAAkB,EAAE;AACvC,EAAE,IAAI,cAAc,GAAiC,UAAU;;AAE/D,EAAE,IAAI,QAAQ,EAAE;AAChB,IAAI,IAAIC,YAAM,CAAC,QAAQ,EAAE,YAAA,IAAgBC,qCAAkB,EAAC,GAAI,CAAC,EAAE;AACnE,MAAM,cAAA,GAAiB,WAAW;AAClC,IAAI,CAAA,MAAO,IAAID,YAAM,CAAC,QAAQ,EAAE,YAAY,EAAE;AAC9C,MAAM,cAAA,GAAiB,SAAS;AAChC,IAAI,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE;AAC9B,MAAM,cAAA,GAAiB,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAA;AACtD,IAAI;AACJ,EAAE;;AAEF;AACA,EAAE,MAAM,OAAO,GAAyD,EAAE;;AAE1E,EAAE,OAAO;AACT,IAAI,IAAI;AACR,IAAI,KAAK;AACT,IAAI,MAAM,EAAE,MAAA;AACZ,IAAI,KAAK,EAAE,CAAC;AACZ,IAAI,OAAO;AACX,IAAI,EAAE,EAAEE,iCAAgB,EAAE;AAC1B,IAAI,cAAc;AAClB,GAAG;AACH;;;;"} |