diff --git a/index.js b/index.js index c359059..03a0df6 100644 --- a/index.js +++ b/index.js @@ -348,6 +348,7 @@ app.get('/', (req, res) => { + @@ -509,5 +510,5 @@ app.get('/v1/airlines/name/:name', (req, res) => { }); app.listen(port, () => { - console.log(`Example app listening at http://localhost:${port}`); + console.log(`Aerokey running live at http://localhost:${port}`); }); diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json index b946d21..2d86e93 100644 --- a/node_modules/.package-lock.json +++ b/node_modules/.package-lock.json @@ -4,6 +4,41 @@ "lockfileVersion": 3, "requires": true, "packages": { + "node_modules/@vercel/speed-insights": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@vercel/speed-insights/-/speed-insights-1.1.0.tgz", + "integrity": "sha512-rAXxuhhO4mlRGC9noa5F7HLMtGg8YF1zAN6Pjd1Ny4pII4cerhtwSG4vympbCl+pWkH7nBS9kVXRD4FAn54dlg==", + "hasInstallScript": true, + "license": "Apache-2.0", + "peerDependencies": { + "@sveltejs/kit": "^1 || ^2", + "next": ">= 13", + "react": "^18 || ^19 || ^19.0.0-rc", + "svelte": ">= 4", + "vue": "^3", + "vue-router": "^4" + }, + "peerDependenciesMeta": { + "@sveltejs/kit": { + "optional": true + }, + "next": { + "optional": true + }, + "react": { + "optional": true + }, + "svelte": { + "optional": true + }, + "vue": { + "optional": true + }, + "vue-router": { + "optional": true + } + } + }, "node_modules/accepts": { "version": "1.3.8", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", diff --git a/node_modules/@vercel/speed-insights/.eslintrc.cjs b/node_modules/@vercel/speed-insights/.eslintrc.cjs new file mode 100644 index 0000000..1cf9818 --- /dev/null +++ b/node_modules/@vercel/speed-insights/.eslintrc.cjs @@ -0,0 +1,7 @@ +module.exports = { + extends: '../../.eslintrc.cjs', + rules: { + 'tsdoc/syntax': 'off', + }, + ignorePatterns: ['jest.setup.ts'], +}; diff --git a/node_modules/@vercel/speed-insights/LICENSE b/node_modules/@vercel/speed-insights/LICENSE new file mode 100644 index 0000000..3eb9904 --- /dev/null +++ b/node_modules/@vercel/speed-insights/LICENSE @@ -0,0 +1,190 @@ + Apache License + Version 2.0, January 2004 + https://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, +and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by +the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all +other entities that control, are controlled by, or are under common +control with that entity. For the purposes of this definition, +"control" means (i) the power, direct or indirect, to cause the +direction or management of such entity, whether by contract or +otherwise, or (ii) ownership of fifty percent (50%) or more of the +outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity +exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, +including but not limited to software source code, documentation +source, and configuration files. + +"Object" form shall mean any form resulting from mechanical +transformation or translation of a Source form, including but +not limited to compiled object code, generated documentation, +and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or +Object form, made available under the License, as indicated by a +copyright notice that is included in or attached to the work +(an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object +form, that is based on (or derived from) the Work and for which the +editorial revisions, annotations, elaborations, or other modifications +represent, as a whole, an original work of authorship. For the purposes +of this License, Derivative Works shall not include works that remain +separable from, or merely link (or bind by name) to the interfaces of, +the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including +the original version of the Work and any modifications or additions +to that Work or Derivative Works thereof, that is intentionally +submitted to Licensor for inclusion in the Work by the copyright owner +or by an individual or Legal Entity authorized to submit on behalf of +the copyright owner. For the purposes of this definition, "submitted" +means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, +and issue tracking systems that are managed by, or on behalf of, the +Licensor for the purpose of discussing and improving the Work, but +excluding communication that is conspicuously marked or otherwise +designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity +on behalf of whom a Contribution has been received by Licensor and +subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + +(a) You must give any other recipients of the Work or +Derivative Works a copy of this License; and + +(b) You must cause any modified files to carry prominent notices +stating that You changed the files; and + +(c) You must retain, in the Source form of any Derivative Works +that You distribute, all copyright, patent, trademark, and +attribution notices from the Source form of the Work, +excluding those notices that do not pertain to any part of +the Derivative Works; and + +(d) If the Work includes a "NOTICE" text file as part of its +distribution, then any Derivative Works that You distribute must +include a readable copy of the attribution notices contained +within such NOTICE file, excluding those notices that do not +pertain to any part of the Derivative Works, in at least one +of the following places: within a NOTICE text file distributed +as part of the Derivative Works; within the Source form or +documentation, if provided along with the Derivative Works; or, +within a display generated by the Derivative Works, if and +wherever such third-party notices normally appear. The contents +of the NOTICE file are for informational purposes only and +do not modify the License. You may add Your own attribution +notices within Derivative Works that You distribute, alongside +or as an addendum to the NOTICE text from the Work, provided +that such additional attribution notices cannot be construed +as modifying the License. + +You may add Your own copyright statement to Your modifications and +may provide additional or different license terms and conditions +for use, reproduction, or distribution of Your modifications, or +for any such Derivative Works as a whole, provided Your use, +reproduction, and distribution of the Work otherwise complies with +the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +Copyright 2023 Vercel, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/node_modules/@vercel/speed-insights/README.md b/node_modules/@vercel/speed-insights/README.md new file mode 100644 index 0000000..7a3443e --- /dev/null +++ b/node_modules/@vercel/speed-insights/README.md @@ -0,0 +1,49 @@ +![Speed Insights](https://github.com/vercel/speed-insights/blob/main/.github/banner.png) + +
Vercel Speed Insights
+
Performance insights for your website
+
+
+Website + · +Documentation + · +Twitter +
+ +## Overview + +`@vercel/speed-insights` automatically tracks web vitals and other performance metrics for your website. + +This package does **not** track data in development mode. + +It has 1st class integration with: + +| Framework | Package | +| --------- | ---------------------------------- | +| Next.js | `@vercel/speed-insights/next` | +| Nuxt | `@vercel/speed-insights/nuxt` | +| Sveltekit | `@vercel/speed-insights/sveltekit` | +| Remix | `@vercel/speed-insights/remix` | +| React | `@vercel/speed-insights/react` | +| Astro | `@vercel/speed-insights/astro` | +| Vue | `@vercel/speed-insights/vue` | + +It also supports other frameworks, vanilla JS and static websites. + +## Quickstart + +1. Enable Vercel Speed Insights for a project in the [Vercel Dashboard](https://vercel.com/d?to=%2F%5Bteam%5D%2F%5Bproject%5D%2Fspeed-insights&title=Open+Web+Analytics). +2. Add the `@vercel/speed-insights` package to your project +3. Inject Speed Insights to your app + + - If you are using **Next.js**, **React**, **Nuxt** or **Vue** you can use the framework-specific `` component to inject the script into your app. + - If you are using **Sveltekit**, you can use the `injectSpeedInsights()` function `@vercel/speed-insights/sveltekit` in your top-level `+layout.js/ts` file. + - For other frameworks, you can use the `inject` function add the tracking script to your app. + - If you want to use Vercel Speed Insights on a static site without npm, follow the instructions in the [documentation](https://vercel.com/docs/speed-insights/quickstart). + +4. Deploy your app to Vercel and see data flowing in. + +## Documentation + +Find more details about this package in our [documentation](https://vercel.com/docs/speed-insights/quickstart). diff --git a/node_modules/@vercel/speed-insights/dist/astro/component.ts b/node_modules/@vercel/speed-insights/dist/astro/component.ts new file mode 100644 index 0000000..e673447 --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/astro/component.ts @@ -0,0 +1,3 @@ +// @ts-expect-error typescript doesn't handle ./index.astro properly, but it's needed to generate types +// eslint-disable-next-line import/no-default-export, no-useless-rename -- Exporting everything doesn't yield the desired outcome +export { default as default } from './index.astro'; diff --git a/node_modules/@vercel/speed-insights/dist/astro/index.astro b/node_modules/@vercel/speed-insights/dist/astro/index.astro new file mode 100644 index 0000000..a50f5b1 --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/astro/index.astro @@ -0,0 +1,39 @@ +--- +// Since this file will not be bundled by Tsup, it is referencing bundled files relative to dist/astro/ +import type { SpeedInsightsProps } from '../index.d.ts'; +type Props = Omit; + +const propsStr = JSON.stringify(Astro.props); +const paramsStr = JSON.stringify(Astro.params); +--- + + + + diff --git a/node_modules/@vercel/speed-insights/dist/index.d.mts b/node_modules/@vercel/speed-insights/dist/index.d.mts new file mode 100644 index 0000000..4d27c44 --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/index.d.mts @@ -0,0 +1,57 @@ +interface SpeedInsightsProps { + dsn?: string; + sampleRate?: number; + route?: string | null; + beforeSend?: BeforeSendMiddleware; + debug?: boolean; + scriptSrc?: string; + endpoint?: string; +} +type EventTypes = 'vital'; +interface Event { + type: EventTypes; + url: string; +} +type BeforeSendMiddleware = (data: Event) => Event | null | undefined | false; +interface Functions { + beforeSend?: BeforeSendMiddleware; +} +interface SpeedInsights { + queue: [T, Functions[T]][]; + addAction: (action: T, data: Functions[T]) => void; +} +declare global { + interface Window { + /** Base interface to track events */ + si?: SpeedInsights['addAction']; + /** Queue for speed insights datapoints, before the library is loaded */ + siq?: SpeedInsights['queue']; + sil?: boolean; + /** used by Astro component only */ + speedInsightsBeforeSend?: BeforeSendMiddleware; + } +} + +declare function computeRoute(pathname: string | null, pathParams: Record | null): string | null; + +/** + * Injects the Vercel Speed Insights script into the page head and starts tracking page views. Read more in our [documentation](https://vercel.com/docs/speed-insights). + * @param [props] - Speed Insights options. + * @param [props.debug] - Whether to enable debug logging in development. Defaults to `true`. + * @param [props.beforeSend] - A middleware function to modify events before they are sent. Should return the event object or `null` to cancel the event. + * @param [props.sampleRate] - When setting to 0.5, 50% of the events will be sent to Vercel Speed Insights. Defaults to `1`. + * @param [props.route] - The dynamic route of the page. + * @param [props.dsn] - The DSN of the project to send events to. Only required when self-hosting. + */ +declare function injectSpeedInsights(props?: SpeedInsightsProps & { + framework?: string; +}): { + setRoute: (route: string | null) => void; +} | null; + +declare const _default: { + injectSpeedInsights: typeof injectSpeedInsights; + computeRoute: typeof computeRoute; +}; + +export { SpeedInsightsProps, computeRoute, _default as default, injectSpeedInsights }; diff --git a/node_modules/@vercel/speed-insights/dist/index.d.ts b/node_modules/@vercel/speed-insights/dist/index.d.ts new file mode 100644 index 0000000..4d27c44 --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/index.d.ts @@ -0,0 +1,57 @@ +interface SpeedInsightsProps { + dsn?: string; + sampleRate?: number; + route?: string | null; + beforeSend?: BeforeSendMiddleware; + debug?: boolean; + scriptSrc?: string; + endpoint?: string; +} +type EventTypes = 'vital'; +interface Event { + type: EventTypes; + url: string; +} +type BeforeSendMiddleware = (data: Event) => Event | null | undefined | false; +interface Functions { + beforeSend?: BeforeSendMiddleware; +} +interface SpeedInsights { + queue: [T, Functions[T]][]; + addAction: (action: T, data: Functions[T]) => void; +} +declare global { + interface Window { + /** Base interface to track events */ + si?: SpeedInsights['addAction']; + /** Queue for speed insights datapoints, before the library is loaded */ + siq?: SpeedInsights['queue']; + sil?: boolean; + /** used by Astro component only */ + speedInsightsBeforeSend?: BeforeSendMiddleware; + } +} + +declare function computeRoute(pathname: string | null, pathParams: Record | null): string | null; + +/** + * Injects the Vercel Speed Insights script into the page head and starts tracking page views. Read more in our [documentation](https://vercel.com/docs/speed-insights). + * @param [props] - Speed Insights options. + * @param [props.debug] - Whether to enable debug logging in development. Defaults to `true`. + * @param [props.beforeSend] - A middleware function to modify events before they are sent. Should return the event object or `null` to cancel the event. + * @param [props.sampleRate] - When setting to 0.5, 50% of the events will be sent to Vercel Speed Insights. Defaults to `1`. + * @param [props.route] - The dynamic route of the page. + * @param [props.dsn] - The DSN of the project to send events to. Only required when self-hosting. + */ +declare function injectSpeedInsights(props?: SpeedInsightsProps & { + framework?: string; +}): { + setRoute: (route: string | null) => void; +} | null; + +declare const _default: { + injectSpeedInsights: typeof injectSpeedInsights; + computeRoute: typeof computeRoute; +}; + +export { SpeedInsightsProps, computeRoute, _default as default, injectSpeedInsights }; diff --git a/node_modules/@vercel/speed-insights/dist/index.js b/node_modules/@vercel/speed-insights/dist/index.js new file mode 100644 index 0000000..2d62da0 --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/index.js @@ -0,0 +1,153 @@ +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __export = (target, all) => { + for (var name2 in all) + __defProp(target, name2, { get: all[name2], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/generic.ts +var generic_exports = {}; +__export(generic_exports, { + computeRoute: () => computeRoute, + default: () => generic_default, + injectSpeedInsights: () => injectSpeedInsights +}); +module.exports = __toCommonJS(generic_exports); + +// package.json +var name = "@vercel/speed-insights"; +var version = "1.1.0"; + +// src/queue.ts +var initQueue = () => { + if (window.si) + return; + window.si = function a(...params) { + (window.siq = window.siq || []).push(params); + }; +}; + +// src/utils.ts +function isBrowser() { + return typeof window !== "undefined"; +} +function detectEnvironment() { + try { + const env = process.env.NODE_ENV; + if (env === "development" || env === "test") { + return "development"; + } + } catch (e) { + } + return "production"; +} +function isDevelopment() { + return detectEnvironment() === "development"; +} +function computeRoute(pathname, pathParams) { + if (!pathname || !pathParams) { + return pathname; + } + let result = pathname; + try { + const entries = Object.entries(pathParams); + for (const [key, value] of entries) { + if (!Array.isArray(value)) { + const matcher = turnValueToRegExp(value); + if (matcher.test(result)) { + result = result.replace(matcher, `/[${key}]`); + } + } + } + for (const [key, value] of entries) { + if (Array.isArray(value)) { + const matcher = turnValueToRegExp(value.join("/")); + if (matcher.test(result)) { + result = result.replace(matcher, `/[...${key}]`); + } + } + } + return result; + } catch (e) { + return pathname; + } +} +function turnValueToRegExp(value) { + return new RegExp(`/${escapeRegExp(value)}(?=[/?#]|$)`); +} +function escapeRegExp(string) { + return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); +} + +// src/generic.ts +var SCRIPT_URL = "https://va.vercel-scripts.com/v1/speed-insights"; +var PROD_SCRIPT_URL = `${SCRIPT_URL}/script.js`; +var DEV_SCRIPT_URL = `${SCRIPT_URL}/script.debug.js`; +var PROXY_SCRIPT_URL = "/_vercel/speed-insights/script.js"; +function injectSpeedInsights(props = {}) { + var _a; + if (!isBrowser() || props.route === null) + return null; + initQueue(); + const isSelfHosted = Boolean(props.dsn); + const productionScript = isSelfHosted ? PROD_SCRIPT_URL : PROXY_SCRIPT_URL; + const src = props.scriptSrc || (isDevelopment() ? DEV_SCRIPT_URL : productionScript); + if (document.head.querySelector(`script[src*="${src}"]`)) + return null; + if (props.beforeSend) { + (_a = window.si) == null ? void 0 : _a.call(window, "beforeSend", props.beforeSend); + } + const script = document.createElement("script"); + script.src = src; + script.defer = true; + script.dataset.sdkn = name + (props.framework ? `/${props.framework}` : ""); + script.dataset.sdkv = version; + if (props.sampleRate) { + script.dataset.sampleRate = props.sampleRate.toString(); + } + if (props.route) { + script.dataset.route = props.route; + } + if (props.endpoint) { + script.dataset.endpoint = props.endpoint; + } + if (props.dsn) { + script.dataset.dsn = props.dsn; + } + if (isDevelopment() && props.debug === false) { + script.dataset.debug = "false"; + } + script.onerror = () => { + console.log( + `[Vercel Speed Insights] Failed to load script from ${src}. Please check if any content blockers are enabled and try again.` + ); + }; + document.head.appendChild(script); + return { + setRoute: (route) => { + script.dataset.route = route ?? void 0; + } + }; +} +var generic_default = { + injectSpeedInsights, + computeRoute +}; +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + computeRoute, + injectSpeedInsights +}); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/node_modules/@vercel/speed-insights/dist/index.js.map b/node_modules/@vercel/speed-insights/dist/index.js.map new file mode 100644 index 0000000..3aa6aa1 --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/generic.ts","../package.json","../src/queue.ts","../src/utils.ts"],"sourcesContent":["import { name as packageName, version } from '../package.json';\nimport { initQueue } from './queue';\nimport type { SpeedInsightsProps } from './types';\nimport { isBrowser, isDevelopment, computeRoute } from './utils';\n\nconst SCRIPT_URL = 'https://va.vercel-scripts.com/v1/speed-insights';\nconst PROD_SCRIPT_URL = `${SCRIPT_URL}/script.js`;\nconst DEV_SCRIPT_URL = `${SCRIPT_URL}/script.debug.js`;\nconst PROXY_SCRIPT_URL = '/_vercel/speed-insights/script.js';\n\n/**\n * Injects the Vercel Speed Insights script into the page head and starts tracking page views. Read more in our [documentation](https://vercel.com/docs/speed-insights).\n * @param [props] - Speed Insights options.\n * @param [props.debug] - Whether to enable debug logging in development. Defaults to `true`.\n * @param [props.beforeSend] - A middleware function to modify events before they are sent. Should return the event object or `null` to cancel the event.\n * @param [props.sampleRate] - When setting to 0.5, 50% of the events will be sent to Vercel Speed Insights. Defaults to `1`.\n * @param [props.route] - The dynamic route of the page.\n * @param [props.dsn] - The DSN of the project to send events to. Only required when self-hosting.\n */\nfunction injectSpeedInsights(\n props: SpeedInsightsProps & {\n framework?: string;\n } = {},\n): {\n setRoute: (route: string | null) => void;\n} | null {\n // When route is null, it means that pages router is not ready yet. Will resolve soon\n if (!isBrowser() || props.route === null) return null;\n\n initQueue();\n\n const isSelfHosted = Boolean(props.dsn);\n\n const productionScript = isSelfHosted ? PROD_SCRIPT_URL : PROXY_SCRIPT_URL;\n\n const src =\n props.scriptSrc || (isDevelopment() ? DEV_SCRIPT_URL : productionScript);\n\n if (document.head.querySelector(`script[src*=\"${src}\"]`)) return null;\n\n if (props.beforeSend) {\n window.si?.('beforeSend', props.beforeSend);\n }\n\n const script = document.createElement('script');\n script.src = src;\n script.defer = true;\n script.dataset.sdkn =\n packageName + (props.framework ? `/${props.framework}` : '');\n script.dataset.sdkv = version;\n\n if (props.sampleRate) {\n script.dataset.sampleRate = props.sampleRate.toString();\n }\n if (props.route) {\n script.dataset.route = props.route;\n }\n if (props.endpoint) {\n script.dataset.endpoint = props.endpoint;\n }\n if (props.dsn) {\n script.dataset.dsn = props.dsn;\n }\n if (isDevelopment() && props.debug === false) {\n script.dataset.debug = 'false';\n }\n\n script.onerror = (): void => {\n // eslint-disable-next-line no-console -- Logging is okay here\n console.log(\n `[Vercel Speed Insights] Failed to load script from ${src}. Please check if any content blockers are enabled and try again.`,\n );\n };\n\n document.head.appendChild(script);\n\n return {\n setRoute: (route: string | null): void => {\n script.dataset.route = route ?? undefined;\n },\n };\n}\n\nexport { injectSpeedInsights, computeRoute };\nexport type { SpeedInsightsProps };\n\n// eslint-disable-next-line import/no-default-export -- Allow default export\nexport default {\n injectSpeedInsights,\n computeRoute,\n};\n","{\n \"name\": \"@vercel/speed-insights\",\n \"version\": \"1.1.0\",\n \"description\": \"Speed Insights is a tool for measuring web performance and providing suggestions for improvement.\",\n \"keywords\": [\n \"speed-insights\",\n \"vercel\"\n ],\n \"repository\": {\n \"url\": \"github:vercel/speed-insights\",\n \"directory\": \"packages/web\"\n },\n \"license\": \"Apache-2.0\",\n \"exports\": {\n \"./package.json\": \"./package.json\",\n \".\": {\n \"browser\": \"./dist/index.mjs\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\"\n },\n \"./astro\": {\n \"import\": \"./dist/astro/component.ts\"\n },\n \"./next\": {\n \"browser\": \"./dist/next/index.mjs\",\n \"import\": \"./dist/next/index.mjs\",\n \"require\": \"./dist/next/index.js\"\n },\n \"./nuxt\": {\n \"browser\": \"./dist/nuxt/index.mjs\",\n \"import\": \"./dist/nuxt/index.mjs\",\n \"require\": \"./dist/nuxt/index.js\"\n },\n \"./react\": {\n \"browser\": \"./dist/react/index.mjs\",\n \"import\": \"./dist/react/index.mjs\",\n \"require\": \"./dist/react/index.js\"\n },\n \"./remix\": {\n \"browser\": \"./dist/remix/index.mjs\",\n \"import\": \"./dist/remix/index.mjs\",\n \"require\": \"./dist/remix/index.js\"\n },\n \"./sveltekit\": {\n \"svelte\": \"./dist/sveltekit/index.mjs\",\n \"types\": \"./dist/sveltekit/index.d.ts\"\n },\n \"./vue\": {\n \"browser\": \"./dist/vue/index.mjs\",\n \"import\": \"./dist/vue/index.mjs\",\n \"require\": \"./dist/vue/index.js\"\n }\n },\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \"*\": [\n \"dist/index.d.ts\"\n ],\n \"react\": [\n \"dist/react/index.d.ts\"\n ],\n \"next\": [\n \"dist/next/index.d.ts\"\n ],\n \"nuxt\": [\n \"dist/nuxt/index.d.ts\"\n ],\n \"remix\": [\n \"dist/remix/index.d.ts\"\n ],\n \"sveltekit\": [\n \"dist/sveltekit/index.d.ts\"\n ],\n \"vue\": [\n \"dist/vue/index.d.ts\"\n ]\n }\n },\n \"scripts\": {\n \"build\": \"tsup && pnpm copy-astro\",\n \"copy-astro\": \"cp -R src/astro dist/\",\n \"dev\": \"pnpm copy-astro && tsup --watch\",\n \"postinstall\": \"node scripts/postinstall.mjs\",\n \"lint\": \"eslint .\",\n \"lint-fix\": \"eslint . --fix\",\n \"test\": \"jest\",\n \"type-check\": \"tsc --noEmit\"\n },\n \"devDependencies\": {\n \"@jest/globals\": \"^29.7.0\",\n \"@remix-run/react\": \"^2.5.0\",\n \"@sveltejs/kit\": \"^2.7\",\n \"@swc/core\": \"^1.3.103\",\n \"@swc/jest\": \"^0.2.29\",\n \"@testing-library/jest-dom\": \"^6.6.3\",\n \"@testing-library/react\": \"^16.0.1\",\n \"@types/node\": \"^20.11.4\",\n \"@types/react\": \"^18.2.48\",\n \"copyfiles\": \"^2.4.1\",\n \"jest\": \"^29.7.0\",\n \"jest-environment-jsdom\": \"^29.7.0\",\n \"next\": \"^14.0.4\",\n \"react\": \"^18.2.0\",\n \"react-dom\": \"^18.2.0\",\n \"svelte\": \"^5\",\n \"tsup\": \"7.2.0\",\n \"vue\": \"^3.4.14\",\n \"vue-router\": \"^4.2.5\"\n },\n \"peerDependencies\": {\n \"@sveltejs/kit\": \"^1 || ^2\",\n \"next\": \">= 13\",\n \"react\": \"^18 || ^19 || ^19.0.0-rc\",\n \"svelte\": \">= 4\",\n \"vue\": \"^3\",\n \"vue-router\": \"^4\"\n },\n \"peerDependenciesMeta\": {\n \"@sveltejs/kit\": {\n \"optional\": true\n },\n \"next\": {\n \"optional\": true\n },\n \"react\": {\n \"optional\": true\n },\n \"svelte\": {\n \"optional\": true\n },\n \"vue\": {\n \"optional\": true\n },\n \"vue-router\": {\n \"optional\": true\n }\n }\n}\n","export const initQueue = (): void => {\n // initialize va until script is loaded\n if (window.si) return;\n\n window.si = function a(...params): void {\n (window.siq = window.siq || []).push(params);\n };\n};\n","export function isBrowser(): boolean {\n return typeof window !== 'undefined';\n}\n\nfunction detectEnvironment(): 'development' | 'production' {\n try {\n const env = process.env.NODE_ENV;\n if (env === 'development' || env === 'test') {\n return 'development';\n }\n } catch (e) {\n // do nothing, this is okay\n }\n return 'production';\n}\n\nexport function isProduction(): boolean {\n return detectEnvironment() === 'production';\n}\n\nexport function isDevelopment(): boolean {\n return detectEnvironment() === 'development';\n}\n\nexport function computeRoute(\n pathname: string | null,\n pathParams: Record | null,\n): string | null {\n if (!pathname || !pathParams) {\n return pathname;\n }\n\n let result = pathname;\n try {\n const entries = Object.entries(pathParams);\n // simple keys must be handled first\n for (const [key, value] of entries) {\n if (!Array.isArray(value)) {\n const matcher = turnValueToRegExp(value);\n if (matcher.test(result)) {\n result = result.replace(matcher, `/[${key}]`);\n }\n }\n }\n // array values next\n for (const [key, value] of entries) {\n if (Array.isArray(value)) {\n const matcher = turnValueToRegExp(value.join('/'));\n if (matcher.test(result)) {\n result = result.replace(matcher, `/[...${key}]`);\n }\n }\n }\n return result;\n } catch (e) {\n return pathname;\n }\n}\n\nfunction turnValueToRegExp(value: string): RegExp {\n return new RegExp(`/${escapeRegExp(value)}(?=[/?#]|$)`);\n}\n\nfunction escapeRegExp(string: string): string {\n return string.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCE,WAAQ;AACR,cAAW;;;ACFN,IAAM,YAAY,MAAY;AAEnC,MAAI,OAAO;AAAI;AAEf,SAAO,KAAK,SAAS,KAAK,QAAc;AACtC,KAAC,OAAO,MAAM,OAAO,OAAO,CAAC,GAAG,KAAK,MAAM;AAAA,EAC7C;AACF;;;ACPO,SAAS,YAAqB;AACnC,SAAO,OAAO,WAAW;AAC3B;AAEA,SAAS,oBAAkD;AACzD,MAAI;AACF,UAAM,MAAM,QAAQ,IAAI;AACxB,QAAI,QAAQ,iBAAiB,QAAQ,QAAQ;AAC3C,aAAO;AAAA,IACT;AAAA,EACF,SAAS,GAAG;AAAA,EAEZ;AACA,SAAO;AACT;AAMO,SAAS,gBAAyB;AACvC,SAAO,kBAAkB,M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I,SAAS,KAAK,cAAc,gBAAgB,GAAG,IAAI;AAAG,WAAO;AAEjE,MAAI,MAAM,YAAY;AACpB,iBAAO,OAAP,gCAAY,cAAc,MAAM;AAAA,EAClC;AAEA,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,SAAO,MAAM;AACb,SAAO,QAAQ;AACf,SAAO,QAAQ,OACb,QAAe,MAAM,YAAY,IAAI,MAAM,SAAS,KAAK;AAC3D,SAAO,QAAQ,OAAO;AAEtB,MAAI,MAAM,YAAY;AACpB,WAAO,QAAQ,aAAa,MAAM,WAAW,SAAS;AAAA,EACxD;AACA,MAAI,MAAM,OAAO;AACf,WAAO,QAAQ,QAAQ,MAAM;AAAA,EAC/B;AACA,MAAI,MAAM,UAAU;AAClB,WAAO,QAAQ,WAAW,MAAM;AAAA,EAClC;AACA,MAAI,MAAM,KAAK;AACb,WAAO,QAAQ,MAAM,MAAM;AAAA,EAC7B;AACA,MAAI,cAAc,KAAK,MAAM,UAAU,OAAO;AAC5C,WAAO,QAAQ,QAAQ;AAAA,EACzB;AAEA,SAAO,UAAU,MAAY;AAE3B,YAAQ;AAAA,MACN,sDAAsD,GAAG;AAAA,IAC3D;AAAA,EACF;AAEA,WAAS,KAAK,YAAY,MAAM;AAEhC,SAAO;AAAA,IACL,UAAU,CAAC,UAA+B;AACxC,aAAO,QAAQ,QAAQ,SAAS;AAAA,IAClC;AAAA,EACF;AACF;AAMA,IAAO,kBAAQ;AAAA,EACb;AAAA,EACA;AACF;","names":[]} \ No newline at end of file diff --git a/node_modules/@vercel/speed-insights/dist/index.mjs b/node_modules/@vercel/speed-insights/dist/index.mjs new file mode 100644 index 0000000..af8542a --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/index.mjs @@ -0,0 +1,125 @@ +// package.json +var name = "@vercel/speed-insights"; +var version = "1.1.0"; + +// src/queue.ts +var initQueue = () => { + if (window.si) + return; + window.si = function a(...params) { + (window.siq = window.siq || []).push(params); + }; +}; + +// src/utils.ts +function isBrowser() { + return typeof window !== "undefined"; +} +function detectEnvironment() { + try { + const env = process.env.NODE_ENV; + if (env === "development" || env === "test") { + return "development"; + } + } catch (e) { + } + return "production"; +} +function isDevelopment() { + return detectEnvironment() === "development"; +} +function computeRoute(pathname, pathParams) { + if (!pathname || !pathParams) { + return pathname; + } + let result = pathname; + try { + const entries = Object.entries(pathParams); + for (const [key, value] of entries) { + if (!Array.isArray(value)) { + const matcher = turnValueToRegExp(value); + if (matcher.test(result)) { + result = result.replace(matcher, `/[${key}]`); + } + } + } + for (const [key, value] of entries) { + if (Array.isArray(value)) { + const matcher = turnValueToRegExp(value.join("/")); + if (matcher.test(result)) { + result = result.replace(matcher, `/[...${key}]`); + } + } + } + return result; + } catch (e) { + return pathname; + } +} +function turnValueToRegExp(value) { + return new RegExp(`/${escapeRegExp(value)}(?=[/?#]|$)`); +} +function escapeRegExp(string) { + return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); +} + +// src/generic.ts +var SCRIPT_URL = "https://va.vercel-scripts.com/v1/speed-insights"; +var PROD_SCRIPT_URL = `${SCRIPT_URL}/script.js`; +var DEV_SCRIPT_URL = `${SCRIPT_URL}/script.debug.js`; +var PROXY_SCRIPT_URL = "/_vercel/speed-insights/script.js"; +function injectSpeedInsights(props = {}) { + var _a; + if (!isBrowser() || props.route === null) + return null; + initQueue(); + const isSelfHosted = Boolean(props.dsn); + const productionScript = isSelfHosted ? PROD_SCRIPT_URL : PROXY_SCRIPT_URL; + const src = props.scriptSrc || (isDevelopment() ? DEV_SCRIPT_URL : productionScript); + if (document.head.querySelector(`script[src*="${src}"]`)) + return null; + if (props.beforeSend) { + (_a = window.si) == null ? void 0 : _a.call(window, "beforeSend", props.beforeSend); + } + const script = document.createElement("script"); + script.src = src; + script.defer = true; + script.dataset.sdkn = name + (props.framework ? `/${props.framework}` : ""); + script.dataset.sdkv = version; + if (props.sampleRate) { + script.dataset.sampleRate = props.sampleRate.toString(); + } + if (props.route) { + script.dataset.route = props.route; + } + if (props.endpoint) { + script.dataset.endpoint = props.endpoint; + } + if (props.dsn) { + script.dataset.dsn = props.dsn; + } + if (isDevelopment() && props.debug === false) { + script.dataset.debug = "false"; + } + script.onerror = () => { + console.log( + `[Vercel Speed Insights] Failed to load script from ${src}. Please check if any content blockers are enabled and try again.` + ); + }; + document.head.appendChild(script); + return { + setRoute: (route) => { + script.dataset.route = route ?? void 0; + } + }; +} +var generic_default = { + injectSpeedInsights, + computeRoute +}; +export { + computeRoute, + generic_default as default, + injectSpeedInsights +}; +//# sourceMappingURL=index.mjs.map \ No newline at end of file diff --git a/node_modules/@vercel/speed-insights/dist/index.mjs.map b/node_modules/@vercel/speed-insights/dist/index.mjs.map new file mode 100644 index 0000000..b49f60f --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"sources":["../package.json","../src/queue.ts","../src/utils.ts","../src/generic.ts"],"sourcesContent":["{\n \"name\": \"@vercel/speed-insights\",\n \"version\": \"1.1.0\",\n \"description\": \"Speed Insights is a tool for measuring web performance and providing suggestions for improvement.\",\n \"keywords\": [\n \"speed-insights\",\n \"vercel\"\n ],\n \"repository\": {\n \"url\": \"github:vercel/speed-insights\",\n \"directory\": \"packages/web\"\n },\n \"license\": \"Apache-2.0\",\n \"exports\": {\n \"./package.json\": \"./package.json\",\n \".\": {\n \"browser\": \"./dist/index.mjs\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\"\n },\n \"./astro\": {\n \"import\": \"./dist/astro/component.ts\"\n },\n \"./next\": {\n \"browser\": \"./dist/next/index.mjs\",\n \"import\": \"./dist/next/index.mjs\",\n \"require\": \"./dist/next/index.js\"\n },\n \"./nuxt\": {\n \"browser\": \"./dist/nuxt/index.mjs\",\n \"import\": \"./dist/nuxt/index.mjs\",\n \"require\": \"./dist/nuxt/index.js\"\n },\n \"./react\": {\n \"browser\": \"./dist/react/index.mjs\",\n \"import\": \"./dist/react/index.mjs\",\n \"require\": \"./dist/react/index.js\"\n },\n \"./remix\": {\n \"browser\": \"./dist/remix/index.mjs\",\n \"import\": \"./dist/remix/index.mjs\",\n \"require\": \"./dist/remix/index.js\"\n },\n \"./sveltekit\": {\n \"svelte\": \"./dist/sveltekit/index.mjs\",\n \"types\": \"./dist/sveltekit/index.d.ts\"\n },\n \"./vue\": {\n \"browser\": \"./dist/vue/index.mjs\",\n \"import\": \"./dist/vue/index.mjs\",\n \"require\": \"./dist/vue/index.js\"\n }\n },\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \"*\": [\n \"dist/index.d.ts\"\n ],\n \"react\": [\n \"dist/react/index.d.ts\"\n ],\n \"next\": [\n \"dist/next/index.d.ts\"\n ],\n \"nuxt\": [\n \"dist/nuxt/index.d.ts\"\n ],\n \"remix\": [\n \"dist/remix/index.d.ts\"\n ],\n \"sveltekit\": [\n \"dist/sveltekit/index.d.ts\"\n ],\n \"vue\": [\n \"dist/vue/index.d.ts\"\n ]\n }\n },\n \"scripts\": {\n \"build\": \"tsup && pnpm copy-astro\",\n \"copy-astro\": \"cp -R src/astro dist/\",\n \"dev\": \"pnpm copy-astro && tsup --watch\",\n \"postinstall\": \"node scripts/postinstall.mjs\",\n \"lint\": \"eslint .\",\n \"lint-fix\": \"eslint . --fix\",\n \"test\": \"jest\",\n \"type-check\": \"tsc --noEmit\"\n },\n \"devDependencies\": {\n \"@jest/globals\": \"^29.7.0\",\n \"@remix-run/react\": \"^2.5.0\",\n \"@sveltejs/kit\": \"^2.7\",\n \"@swc/core\": \"^1.3.103\",\n \"@swc/jest\": \"^0.2.29\",\n \"@testing-library/jest-dom\": \"^6.6.3\",\n \"@testing-library/react\": \"^16.0.1\",\n \"@types/node\": \"^20.11.4\",\n \"@types/react\": \"^18.2.48\",\n \"copyfiles\": \"^2.4.1\",\n \"jest\": \"^29.7.0\",\n \"jest-environment-jsdom\": \"^29.7.0\",\n \"next\": \"^14.0.4\",\n \"react\": \"^18.2.0\",\n \"react-dom\": \"^18.2.0\",\n \"svelte\": \"^5\",\n \"tsup\": \"7.2.0\",\n \"vue\": \"^3.4.14\",\n \"vue-router\": \"^4.2.5\"\n },\n \"peerDependencies\": {\n \"@sveltejs/kit\": \"^1 || ^2\",\n \"next\": \">= 13\",\n \"react\": \"^18 || ^19 || ^19.0.0-rc\",\n \"svelte\": \">= 4\",\n \"vue\": \"^3\",\n \"vue-router\": \"^4\"\n },\n \"peerDependenciesMeta\": {\n \"@sveltejs/kit\": {\n \"optional\": true\n },\n \"next\": {\n \"optional\": true\n },\n \"react\": {\n \"optional\": true\n },\n \"svelte\": {\n \"optional\": true\n },\n \"vue\": {\n \"optional\": true\n },\n \"vue-router\": {\n \"optional\": true\n }\n }\n}\n","export const initQueue = (): void => {\n // initialize va until script is loaded\n if (window.si) return;\n\n window.si = function a(...params): void {\n (window.siq = window.siq || []).push(params);\n };\n};\n","export function isBrowser(): boolean {\n return typeof window !== 'undefined';\n}\n\nfunction detectEnvironment(): 'development' | 'production' {\n try {\n const env = process.env.NODE_ENV;\n if (env === 'development' || env === 'test') {\n return 'development';\n }\n } catch (e) {\n // do nothing, this is okay\n }\n return 'production';\n}\n\nexport function isProduction(): boolean {\n return detectEnvironment() === 'production';\n}\n\nexport function isDevelopment(): boolean {\n return detectEnvironment() === 'development';\n}\n\nexport function computeRoute(\n pathname: string | null,\n pathParams: Record | null,\n): string | null {\n if (!pathname || !pathParams) {\n return pathname;\n }\n\n let result = pathname;\n try {\n const entries = Object.entries(pathParams);\n // simple keys must be handled first\n for (const [key, value] of entries) {\n if (!Array.isArray(value)) {\n const matcher = turnValueToRegExp(value);\n if (matcher.test(result)) {\n result = result.replace(matcher, `/[${key}]`);\n }\n }\n }\n // array values next\n for (const [key, value] of entries) {\n if (Array.isArray(value)) {\n const matcher = turnValueToRegExp(value.join('/'));\n if (matcher.test(result)) {\n result = result.replace(matcher, `/[...${key}]`);\n }\n }\n }\n return result;\n } catch (e) {\n return pathname;\n }\n}\n\nfunction turnValueToRegExp(value: string): RegExp {\n return new RegExp(`/${escapeRegExp(value)}(?=[/?#]|$)`);\n}\n\nfunction escapeRegExp(string: string): string {\n return string.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n","import { name as packageName, version } from '../package.json';\nimport { initQueue } from './queue';\nimport type { SpeedInsightsProps } from './types';\nimport { isBrowser, isDevelopment, computeRoute } from './utils';\n\nconst SCRIPT_URL = 'https://va.vercel-scripts.com/v1/speed-insights';\nconst PROD_SCRIPT_URL = `${SCRIPT_URL}/script.js`;\nconst DEV_SCRIPT_URL = `${SCRIPT_URL}/script.debug.js`;\nconst PROXY_SCRIPT_URL = '/_vercel/speed-insights/script.js';\n\n/**\n * Injects the Vercel Speed Insights script into the page head and starts tracking page views. Read more in our [documentation](https://vercel.com/docs/speed-insights).\n * @param [props] - Speed Insights options.\n * @param [props.debug] - Whether to enable debug logging in development. Defaults to `true`.\n * @param [props.beforeSend] - A middleware function to modify events before they are sent. Should return the event object or `null` to cancel the event.\n * @param [props.sampleRate] - When setting to 0.5, 50% of the events will be sent to Vercel Speed Insights. Defaults to `1`.\n * @param [props.route] - The dynamic route of the page.\n * @param [props.dsn] - The DSN of the project to send events to. Only required when self-hosting.\n */\nfunction injectSpeedInsights(\n props: SpeedInsightsProps & {\n framework?: string;\n } = {},\n): {\n setRoute: (route: string | null) => void;\n} | null {\n // When route is null, it means that pages router is not ready yet. Will resolve soon\n if (!isBrowser() || props.route === null) return null;\n\n initQueue();\n\n const isSelfHosted = Boolean(props.dsn);\n\n const productionScript = isSelfHosted ? PROD_SCRIPT_URL : PROXY_SCRIPT_URL;\n\n const src =\n props.scriptSrc || (isDevelopment() ? DEV_SCRIPT_URL : productionScript);\n\n if (document.head.querySelector(`script[src*=\"${src}\"]`)) return null;\n\n if (props.beforeSend) {\n window.si?.('beforeSend', props.beforeSend);\n }\n\n const script = document.createElement('script');\n script.src = src;\n script.defer = true;\n script.dataset.sdkn =\n packageName + (props.framework ? `/${props.framework}` : '');\n script.dataset.sdkv = version;\n\n if (props.sampleRate) {\n script.dataset.sampleRate = props.sampleRate.toString();\n }\n if (props.route) {\n script.dataset.route = props.route;\n }\n if (props.endpoint) {\n script.dataset.endpoint = props.endpoint;\n }\n if (props.dsn) {\n script.dataset.dsn = props.dsn;\n }\n if (isDevelopment() && props.debug === false) {\n script.dataset.debug = 'false';\n }\n\n script.onerror = (): void => {\n // eslint-disable-next-line no-console -- Logging is okay here\n console.log(\n `[Vercel Speed Insights] Failed to load script from ${src}. Please check if any content blockers are enabled and try again.`,\n );\n };\n\n document.head.appendChild(script);\n\n return {\n setRoute: (route: string | null): void => {\n script.dataset.route = route ?? undefined;\n },\n };\n}\n\nexport { injectSpeedInsights, computeRoute };\nexport type { SpeedInsightsProps };\n\n// eslint-disable-next-line import/no-default-export -- Allow default export\nexport default {\n injectSpeedInsights,\n computeRoute,\n};\n"],"mappings":";AACE,WAAQ;AACR,cAAW;;;ACFN,IAAM,YAAY,MAAY;AAEnC,MAAI,OAAO;AAAI;AAEf,SAAO,KAAK,SAAS,KAAK,QAAc;AACtC,KAAC,OAAO,MAAM,OAAO,OAAO,CAAC,GAAG,KAAK,MAAM;AAAA,EAC7C;AACF;;;ACPO,SAAS,YAAqB;AACnC,SAAO,OAAO,WAAW;AAC3B;AAEA,SAAS,oBAAkD;AACzD,MAAI;AACF,UAAM,MAAM,QAAQ,IAAI;AACxB,QAAI,QAAQ,iBAAiB,QAAQ,QAAQ;AAC3C,aAAO;AAAA,IACT;AAAA,EACF,SAAS,GAAG;AAAA,EAEZ;AACA,SAAO;AACT;AAMO,SAAS,gBAAyB;AACvC,SAAO,kBAAkB,MAAM;AACjC;AAEO,SAAS,aACd,UACA,YACe;AACf,MAAI,CAAC,YAAY,CAAC,YAAY;AAC5B,WAAO;AAAA,EACT;AAEA,MAAI,SAAS;AACb,MAAI;AACF,UAAM,UAAU,OAAO,QAAQ,UAAU;AAEzC,eAAW,CAAC,KAAK,KAAK,KAA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QAAQ;AACf,SAAO,QAAQ,OACb,QAAe,MAAM,YAAY,IAAI,MAAM,SAAS,KAAK;AAC3D,SAAO,QAAQ,OAAO;AAEtB,MAAI,MAAM,YAAY;AACpB,WAAO,QAAQ,aAAa,MAAM,WAAW,SAAS;AAAA,EACxD;AACA,MAAI,MAAM,OAAO;AACf,WAAO,QAAQ,QAAQ,MAAM;AAAA,EAC/B;AACA,MAAI,MAAM,UAAU;AAClB,WAAO,QAAQ,WAAW,MAAM;AAAA,EAClC;AACA,MAAI,MAAM,KAAK;AACb,WAAO,QAAQ,MAAM,MAAM;AAAA,EAC7B;AACA,MAAI,cAAc,KAAK,MAAM,UAAU,OAAO;AAC5C,WAAO,QAAQ,QAAQ;AAAA,EACzB;AAEA,SAAO,UAAU,MAAY;AAE3B,YAAQ;AAAA,MACN,sDAAsD,GAAG;AAAA,IAC3D;AAAA,EACF;AAEA,WAAS,KAAK,YAAY,MAAM;AAEhC,SAAO;AAAA,IACL,UAAU,CAAC,UAA+B;AACxC,aAAO,QAAQ,QAAQ,SAAS;AAAA,IAClC;AAAA,EACF;AACF;AAMA,IAAO,kBAAQ;AAAA,EACb;AAAA,EACA;AACF;","names":[]} \ No newline at end of file diff --git a/node_modules/@vercel/speed-insights/dist/next/index.d.mts b/node_modules/@vercel/speed-insights/dist/next/index.d.mts new file mode 100644 index 0000000..e692f2c --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/next/index.d.mts @@ -0,0 +1,38 @@ +interface SpeedInsightsProps { + dsn?: string; + sampleRate?: number; + route?: string | null; + beforeSend?: BeforeSendMiddleware; + debug?: boolean; + scriptSrc?: string; + endpoint?: string; +} +type EventTypes = 'vital'; +interface Event { + type: EventTypes; + url: string; +} +type BeforeSendMiddleware = (data: Event) => Event | null | undefined | false; +interface Functions { + beforeSend?: BeforeSendMiddleware; +} +interface SpeedInsights$1 { + queue: [T, Functions[T]][]; + addAction: (action: T, data: Functions[T]) => void; +} +declare global { + interface Window { + /** Base interface to track events */ + si?: SpeedInsights$1['addAction']; + /** Queue for speed insights datapoints, before the library is loaded */ + siq?: SpeedInsights$1['queue']; + sil?: boolean; + /** used by Astro component only */ + speedInsightsBeforeSend?: BeforeSendMiddleware; + } +} + +type Props = Omit; +declare function SpeedInsights(props: Props): null; + +export { SpeedInsights }; diff --git a/node_modules/@vercel/speed-insights/dist/next/index.d.ts b/node_modules/@vercel/speed-insights/dist/next/index.d.ts new file mode 100644 index 0000000..e692f2c --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/next/index.d.ts @@ -0,0 +1,38 @@ +interface SpeedInsightsProps { + dsn?: string; + sampleRate?: number; + route?: string | null; + beforeSend?: BeforeSendMiddleware; + debug?: boolean; + scriptSrc?: string; + endpoint?: string; +} +type EventTypes = 'vital'; +interface Event { + type: EventTypes; + url: string; +} +type BeforeSendMiddleware = (data: Event) => Event | null | undefined | false; +interface Functions { + beforeSend?: BeforeSendMiddleware; +} +interface SpeedInsights$1 { + queue: [T, Functions[T]][]; + addAction: (action: T, data: Functions[T]) => void; +} +declare global { + interface Window { + /** Base interface to track events */ + si?: SpeedInsights$1['addAction']; + /** Queue for speed insights datapoints, before the library is loaded */ + siq?: SpeedInsights$1['queue']; + sil?: boolean; + /** used by Astro component only */ + speedInsightsBeforeSend?: BeforeSendMiddleware; + } +} + +type Props = Omit; +declare function SpeedInsights(props: Props): null; + +export { SpeedInsights }; diff --git a/node_modules/@vercel/speed-insights/dist/next/index.js b/node_modules/@vercel/speed-insights/dist/next/index.js new file mode 100644 index 0000000..679937f --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/next/index.js @@ -0,0 +1,208 @@ +"use client"; +"use strict"; +var __create = Object.create; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __getProtoOf = Object.getPrototypeOf; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __export = (target, all) => { + for (var name2 in all) + __defProp(target, name2, { get: all[name2], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( + // If the importer is in node compatibility mode or this is not an ESM + // file that has been converted to a CommonJS file using a Babel- + // compatible transform (i.e. "__esModule" has not been set), then set + // "default" to the CommonJS "module.exports" for node compatibility. + isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, + mod +)); +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/nextjs/index.tsx +var nextjs_exports = {}; +__export(nextjs_exports, { + SpeedInsights: () => SpeedInsights2 +}); +module.exports = __toCommonJS(nextjs_exports); +var import_react2 = __toESM(require("react")); + +// src/react/index.tsx +var import_react = require("react"); + +// package.json +var name = "@vercel/speed-insights"; +var version = "1.1.0"; + +// src/queue.ts +var initQueue = () => { + if (window.si) + return; + window.si = function a(...params) { + (window.siq = window.siq || []).push(params); + }; +}; + +// src/utils.ts +function isBrowser() { + return typeof window !== "undefined"; +} +function detectEnvironment() { + try { + const env = process.env.NODE_ENV; + if (env === "development" || env === "test") { + return "development"; + } + } catch (e) { + } + return "production"; +} +function isDevelopment() { + return detectEnvironment() === "development"; +} +function computeRoute(pathname, pathParams) { + if (!pathname || !pathParams) { + return pathname; + } + let result = pathname; + try { + const entries = Object.entries(pathParams); + for (const [key, value] of entries) { + if (!Array.isArray(value)) { + const matcher = turnValueToRegExp(value); + if (matcher.test(result)) { + result = result.replace(matcher, `/[${key}]`); + } + } + } + for (const [key, value] of entries) { + if (Array.isArray(value)) { + const matcher = turnValueToRegExp(value.join("/")); + if (matcher.test(result)) { + result = result.replace(matcher, `/[...${key}]`); + } + } + } + return result; + } catch (e) { + return pathname; + } +} +function turnValueToRegExp(value) { + return new RegExp(`/${escapeRegExp(value)}(?=[/?#]|$)`); +} +function escapeRegExp(string) { + return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); +} + +// src/generic.ts +var SCRIPT_URL = "https://va.vercel-scripts.com/v1/speed-insights"; +var PROD_SCRIPT_URL = `${SCRIPT_URL}/script.js`; +var DEV_SCRIPT_URL = `${SCRIPT_URL}/script.debug.js`; +var PROXY_SCRIPT_URL = "/_vercel/speed-insights/script.js"; +function injectSpeedInsights(props = {}) { + var _a; + if (!isBrowser() || props.route === null) + return null; + initQueue(); + const isSelfHosted = Boolean(props.dsn); + const productionScript = isSelfHosted ? PROD_SCRIPT_URL : PROXY_SCRIPT_URL; + const src = props.scriptSrc || (isDevelopment() ? DEV_SCRIPT_URL : productionScript); + if (document.head.querySelector(`script[src*="${src}"]`)) + return null; + if (props.beforeSend) { + (_a = window.si) == null ? void 0 : _a.call(window, "beforeSend", props.beforeSend); + } + const script = document.createElement("script"); + script.src = src; + script.defer = true; + script.dataset.sdkn = name + (props.framework ? `/${props.framework}` : ""); + script.dataset.sdkv = version; + if (props.sampleRate) { + script.dataset.sampleRate = props.sampleRate.toString(); + } + if (props.route) { + script.dataset.route = props.route; + } + if (props.endpoint) { + script.dataset.endpoint = props.endpoint; + } + if (props.dsn) { + script.dataset.dsn = props.dsn; + } + if (isDevelopment() && props.debug === false) { + script.dataset.debug = "false"; + } + script.onerror = () => { + console.log( + `[Vercel Speed Insights] Failed to load script from ${src}. Please check if any content blockers are enabled and try again.` + ); + }; + document.head.appendChild(script); + return { + setRoute: (route) => { + script.dataset.route = route ?? void 0; + } + }; +} + +// src/react/index.tsx +function SpeedInsights(props) { + (0, import_react.useEffect)(() => { + var _a; + if (props.beforeSend) { + (_a = window.si) == null ? void 0 : _a.call(window, "beforeSend", props.beforeSend); + } + }, [props.beforeSend]); + const setScriptRoute = (0, import_react.useRef)(null); + (0, import_react.useEffect)(() => { + if (!setScriptRoute.current) { + const script = injectSpeedInsights({ + framework: props.framework || "react", + ...props + }); + if (script) { + setScriptRoute.current = script.setRoute; + } + } else if (props.route) { + setScriptRoute.current(props.route); + } + }, [props.route]); + return null; +} + +// src/nextjs/utils.ts +var import_navigation = require("next/navigation.js"); +var useRoute = () => { + const params = (0, import_navigation.useParams)(); + const searchParams = (0, import_navigation.useSearchParams)() || new URLSearchParams(); + const path = (0, import_navigation.usePathname)(); + if (!params) { + return null; + } + const finalParams = Object.keys(params).length ? params : Object.fromEntries(searchParams.entries()); + return computeRoute(path, finalParams); +}; + +// src/nextjs/index.tsx +function SpeedInsightsComponent(props) { + const route = useRoute(); + return /* @__PURE__ */ import_react2.default.createElement(SpeedInsights, { route, ...props, framework: "next" }); +} +function SpeedInsights2(props) { + return /* @__PURE__ */ import_react2.default.createElement(import_react2.Suspense, { fallback: null }, /* @__PURE__ */ import_react2.default.createElement(SpeedInsightsComponent, { ...props })); +} +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + SpeedInsights +}); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/node_modules/@vercel/speed-insights/dist/next/index.js.map b/node_modules/@vercel/speed-insights/dist/next/index.js.map new file mode 100644 index 0000000..45b134c --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/next/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/nextjs/index.tsx","../../src/react/index.tsx","../../package.json","../../src/queue.ts","../../src/utils.ts","../../src/generic.ts","../../src/nextjs/utils.ts"],"sourcesContent":["import React, { Suspense } from 'react';\nimport { SpeedInsights as SpeedInsightsScript } from '../react';\nimport type { SpeedInsightsProps } from '../types';\nimport { useRoute } from './utils';\n\ntype Props = Omit;\n\nfunction SpeedInsightsComponent(props: Props): React.ReactElement {\n const route = useRoute();\n\n return ;\n}\n\nexport function SpeedInsights(props: Props): null {\n // Because of incompatible types between ReactNode in React 19 and React 18 we return null (which is also what we render)\n return (\n \n \n \n ) as never;\n}\n","'use client';\nimport { useEffect, useRef } from 'react';\nimport type { SpeedInsightsProps } from '../types';\nimport { computeRoute, injectSpeedInsights } from '../generic';\n\nexport function SpeedInsights(\n props: SpeedInsightsProps & {\n framework?: string;\n },\n): JSX.Element | null {\n useEffect(() => {\n if (props.beforeSend) {\n window.si?.('beforeSend', props.beforeSend);\n }\n }, [props.beforeSend]);\n\n const setScriptRoute = useRef<((path: string) => void) | null>(null);\n useEffect(() => {\n if (!setScriptRoute.current) {\n const script = injectSpeedInsights({\n framework: props.framework || 'react',\n ...props,\n });\n if (script) {\n setScriptRoute.current = script.setRoute;\n }\n } else if (props.route) {\n setScriptRoute.current(props.route);\n }\n }, [props.route]);\n\n return null;\n}\n\nexport { computeRoute };\n","{\n \"name\": \"@vercel/speed-insights\",\n \"version\": \"1.1.0\",\n \"description\": \"Speed Insights is a tool for measuring web performance and providing suggestions for improvement.\",\n \"keywords\": [\n \"speed-insights\",\n \"vercel\"\n ],\n \"repository\": {\n \"url\": \"github:vercel/speed-insights\",\n \"directory\": \"packages/web\"\n },\n \"license\": \"Apache-2.0\",\n \"exports\": {\n \"./package.json\": \"./package.json\",\n \".\": {\n \"browser\": \"./dist/index.mjs\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\"\n },\n \"./astro\": {\n \"import\": \"./dist/astro/component.ts\"\n },\n \"./next\": {\n \"browser\": \"./dist/next/index.mjs\",\n \"import\": \"./dist/next/index.mjs\",\n \"require\": \"./dist/next/index.js\"\n },\n \"./nuxt\": {\n \"browser\": \"./dist/nuxt/index.mjs\",\n \"import\": \"./dist/nuxt/index.mjs\",\n \"require\": \"./dist/nuxt/index.js\"\n },\n \"./react\": {\n \"browser\": \"./dist/react/index.mjs\",\n \"import\": \"./dist/react/index.mjs\",\n \"require\": \"./dist/react/index.js\"\n },\n \"./remix\": {\n \"browser\": \"./dist/remix/index.mjs\",\n \"import\": \"./dist/remix/index.mjs\",\n \"require\": \"./dist/remix/index.js\"\n },\n \"./sveltekit\": {\n \"svelte\": \"./dist/sveltekit/index.mjs\",\n \"types\": \"./dist/sveltekit/index.d.ts\"\n },\n \"./vue\": {\n \"browser\": \"./dist/vue/index.mjs\",\n \"import\": \"./dist/vue/index.mjs\",\n \"require\": \"./dist/vue/index.js\"\n }\n },\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \"*\": [\n \"dist/index.d.ts\"\n ],\n \"react\": [\n \"dist/react/index.d.ts\"\n ],\n \"next\": [\n \"dist/next/index.d.ts\"\n ],\n \"nuxt\": [\n \"dist/nuxt/index.d.ts\"\n ],\n \"remix\": [\n \"dist/remix/index.d.ts\"\n ],\n \"sveltekit\": [\n \"dist/sveltekit/index.d.ts\"\n ],\n \"vue\": [\n \"dist/vue/index.d.ts\"\n ]\n }\n },\n \"scripts\": {\n \"build\": \"tsup && pnpm copy-astro\",\n \"copy-astro\": \"cp -R src/astro dist/\",\n \"dev\": \"pnpm copy-astro && tsup --watch\",\n \"postinstall\": \"node scripts/postinstall.mjs\",\n \"lint\": \"eslint .\",\n \"lint-fix\": \"eslint . --fix\",\n \"test\": \"jest\",\n \"type-check\": \"tsc --noEmit\"\n },\n \"devDependencies\": {\n \"@jest/globals\": \"^29.7.0\",\n \"@remix-run/react\": \"^2.5.0\",\n \"@sveltejs/kit\": \"^2.7\",\n \"@swc/core\": \"^1.3.103\",\n \"@swc/jest\": \"^0.2.29\",\n \"@testing-library/jest-dom\": \"^6.6.3\",\n \"@testing-library/react\": \"^16.0.1\",\n \"@types/node\": \"^20.11.4\",\n \"@types/react\": \"^18.2.48\",\n \"copyfiles\": \"^2.4.1\",\n \"jest\": \"^29.7.0\",\n \"jest-environment-jsdom\": \"^29.7.0\",\n \"next\": \"^14.0.4\",\n \"react\": \"^18.2.0\",\n \"react-dom\": \"^18.2.0\",\n \"svelte\": \"^5\",\n \"tsup\": \"7.2.0\",\n \"vue\": \"^3.4.14\",\n \"vue-router\": \"^4.2.5\"\n },\n \"peerDependencies\": {\n \"@sveltejs/kit\": \"^1 || ^2\",\n \"next\": \">= 13\",\n \"react\": \"^18 || ^19 || ^19.0.0-rc\",\n \"svelte\": \">= 4\",\n \"vue\": \"^3\",\n \"vue-router\": \"^4\"\n },\n \"peerDependenciesMeta\": {\n \"@sveltejs/kit\": {\n \"optional\": true\n },\n \"next\": {\n \"optional\": true\n },\n \"react\": {\n \"optional\": true\n },\n \"svelte\": {\n \"optional\": true\n },\n \"vue\": {\n \"optional\": true\n },\n \"vue-router\": {\n \"optional\": true\n }\n }\n}\n","export const initQueue = (): void => {\n // initialize va until script is loaded\n if (window.si) return;\n\n window.si = function a(...params): void {\n (window.siq = window.siq || []).push(params);\n };\n};\n","export function isBrowser(): boolean {\n return typeof window !== 'undefined';\n}\n\nfunction detectEnvironment(): 'development' | 'production' {\n try {\n const env = process.env.NODE_ENV;\n if (env === 'development' || env === 'test') {\n return 'development';\n }\n } catch (e) {\n // do nothing, this is okay\n }\n return 'production';\n}\n\nexport function isProduction(): boolean {\n return detectEnvironment() === 'production';\n}\n\nexport function isDevelopment(): boolean {\n return detectEnvironment() === 'development';\n}\n\nexport function computeRoute(\n pathname: string | null,\n pathParams: Record | null,\n): string | null {\n if (!pathname || !pathParams) {\n return pathname;\n }\n\n let result = pathname;\n try {\n const entries = Object.entries(pathParams);\n // simple keys must be handled first\n for (const [key, value] of entries) {\n if (!Array.isArray(value)) {\n const matcher = turnValueToRegExp(value);\n if (matcher.test(result)) {\n result = result.replace(matcher, `/[${key}]`);\n }\n }\n }\n // array values next\n for (const [key, value] of entries) {\n if (Array.isArray(value)) {\n const matcher = turnValueToRegExp(value.join('/'));\n if (matcher.test(result)) {\n result = result.replace(matcher, `/[...${key}]`);\n }\n }\n }\n return result;\n } catch (e) {\n return pathname;\n }\n}\n\nfunction turnValueToRegExp(value: string): RegExp {\n return new RegExp(`/${escapeRegExp(value)}(?=[/?#]|$)`);\n}\n\nfunction escapeRegExp(string: string): string {\n return string.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n","import { name as packageName, version } from '../package.json';\nimport { initQueue } from './queue';\nimport type { SpeedInsightsProps } from './types';\nimport { isBrowser, isDevelopment, computeRoute } from './utils';\n\nconst SCRIPT_URL = 'https://va.vercel-scripts.com/v1/speed-insights';\nconst PROD_SCRIPT_URL = `${SCRIPT_URL}/script.js`;\nconst DEV_SCRIPT_URL = `${SCRIPT_URL}/script.debug.js`;\nconst PROXY_SCRIPT_URL = '/_vercel/speed-insights/script.js';\n\n/**\n * Injects the Vercel Speed Insights script into the page head and starts tracking page views. Read more in our [documentation](https://vercel.com/docs/speed-insights).\n * @param [props] - Speed Insights options.\n * @param [props.debug] - Whether to enable debug logging in development. Defaults to `true`.\n * @param [props.beforeSend] - A middleware function to modify events before they are sent. Should return the event object or `null` to cancel the event.\n * @param [props.sampleRate] - When setting to 0.5, 50% of the events will be sent to Vercel Speed Insights. Defaults to `1`.\n * @param [props.route] - The dynamic route of the page.\n * @param [props.dsn] - The DSN of the project to send events to. Only required when self-hosting.\n */\nfunction injectSpeedInsights(\n props: SpeedInsightsProps & {\n framework?: string;\n } = {},\n): {\n setRoute: (route: string | null) => void;\n} | null {\n // When route is null, it means that pages router is not ready yet. Will resolve soon\n if (!isBrowser() || props.route === null) return null;\n\n initQueue();\n\n const isSelfHosted = Boolean(props.dsn);\n\n const productionScript = isSelfHosted ? PROD_SCRIPT_URL : PROXY_SCRIPT_URL;\n\n const src =\n props.scriptSrc || (isDevelopment() ? DEV_SCRIPT_URL : productionScript);\n\n if (document.head.querySelector(`script[src*=\"${src}\"]`)) return null;\n\n if (props.beforeSend) {\n window.si?.('beforeSend', props.beforeSend);\n }\n\n const script = document.createElement('script');\n script.src = src;\n script.defer = true;\n script.dataset.sdkn =\n packageName + (props.framework ? `/${props.framework}` : '');\n script.dataset.sdkv = version;\n\n if (props.sampleRate) {\n script.dataset.sampleRate = props.sampleRate.toString();\n }\n if (props.route) {\n script.dataset.route = props.route;\n }\n if (props.endpoint) {\n script.dataset.endpoint = props.endpoint;\n }\n if (props.dsn) {\n script.dataset.dsn = props.dsn;\n }\n if (isDevelopment() && props.debug === false) {\n script.dataset.debug = 'false';\n }\n\n script.onerror = (): void => {\n // eslint-disable-next-line no-console -- Logging is okay here\n console.log(\n `[Vercel Speed Insights] Failed to load script from ${src}. Please check if any content blockers are enabled and try again.`,\n );\n };\n\n document.head.appendChild(script);\n\n return {\n setRoute: (route: string | null): void => {\n script.dataset.route = route ?? undefined;\n },\n };\n}\n\nexport { injectSpeedInsights, computeRoute };\nexport type { SpeedInsightsProps };\n\n// eslint-disable-next-line import/no-default-export -- Allow default export\nexport default {\n injectSpeedInsights,\n computeRoute,\n};\n","'use client';\n/* eslint-disable @typescript-eslint/no-unnecessary-condition -- can be empty in pages router */\nimport { useParams, usePathname, useSearchParams } from 'next/navigation.js';\nimport { computeRoute } from '../utils';\n\nexport const useRoute = (): string | null => {\n const params = useParams();\n const searchParams = useSearchParams() || new URLSearchParams();\n const path = usePathname();\n // Until we have route parameters, we don't compute the route\n if (!params) {\n return null;\n }\n // in Next.js@13, useParams() could return an empty object for pages router, and we default to searchParams.\n const finalParams = Object.keys(params).length\n ? params\n : Object.fromEntries(searchParams.entries());\n return computeRoute(path, finalParams);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,uBAAAA;AAAA;AAAA;AAAA,IAAAC,gBAAgC;;;ACChC,mBAAkC;;;ACAhC,WAAQ;AACR,cAAW;;;ACFN,IAAM,YAAY,MAAY;AAEnC,MAAI,OAAO;AAAI;AAEf,SAAO,KAAK,SAAS,KAAK,QAAc;AACtC,KAAC,OAAO,MAAM,OAAO,OAAO,CAAC,GAAG,KAAK,MAAM;AAAA,EAC7C;AACF;;;ACPO,SAAS,YAAqB;AACnC,SAAO,OAAO,WAAW;AAC3B;AAEA,SAAS,oBAAkD;AACzD,MAAI;AACF,UAAM,MAAM,QAAQ,IAAI;AACxB,QAAI,QAAQ,iBAAiB,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M;AACd,QAAI,CAAC,eAAe,SAAS;AAC3B,YAAM,SAAS,oBAAoB;AAAA,QACjC,WAAW,MAAM,aAAa;AAAA,QAC9B,GAAG;AAAA,MACL,CAAC;AACD,UAAI,QAAQ;AACV,uBAAe,UAAU,OAAO;AAAA,MAClC;AAAA,IACF,WAAW,MAAM,OAAO;AACtB,qBAAe,QAAQ,MAAM,KAAK;AAAA,IACpC;AAAA,EACF,GAAG,CAAC,MAAM,KAAK,CAAC;AAEhB,SAAO;AACT;;;AK9BA,wBAAwD;AAGjD,IAAM,WAAW,MAAqB;AAC3C,QAAM,aAAS,6BAAU;AACzB,QAAM,mBAAe,mCAAgB,KAAK,IAAI,gBAAgB;AAC9D,QAAM,WAAO,+BAAY;AAEzB,MAAI,CAAC,QAAQ;AACX,WAAO;AAAA,EACT;AAEA,QAAM,cAAc,OAAO,KAAK,MAAM,EAAE,SACpC,SACA,OAAO,YAAY,aAAa,QAAQ,CAAC;AAC7C,SAAO,aAAa,MAAM,WAAW;AACvC;;;ANXA,SAAS,uBAAuB,OAAkC;AAChE,QAAM,QAAQ,SAAS;AAEvB,SAAO,8BAAAC,QAAA,cAAC,iBAAoB,OAAe,GAAG,OAAO,WAAU,QAAO;AACxE;AAEO,SAASC,eAAc,OAAoB;AAEhD,SACE,8BAAAD,QAAA,cAAC,0BAAS,UAAU,QAClB,8BAAAA,QAAA,cAAC,0BAAwB,GAAG,OAAO,CACrC;AAEJ;","names":["SpeedInsights","import_react","React","SpeedInsights"]} \ No newline at end of file diff --git a/node_modules/@vercel/speed-insights/dist/next/index.mjs b/node_modules/@vercel/speed-insights/dist/next/index.mjs new file mode 100644 index 0000000..61b193c --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/next/index.mjs @@ -0,0 +1,174 @@ +"use client"; + +// src/nextjs/index.tsx +import React, { Suspense } from "react"; + +// src/react/index.tsx +import { useEffect, useRef } from "react"; + +// package.json +var name = "@vercel/speed-insights"; +var version = "1.1.0"; + +// src/queue.ts +var initQueue = () => { + if (window.si) + return; + window.si = function a(...params) { + (window.siq = window.siq || []).push(params); + }; +}; + +// src/utils.ts +function isBrowser() { + return typeof window !== "undefined"; +} +function detectEnvironment() { + try { + const env = process.env.NODE_ENV; + if (env === "development" || env === "test") { + return "development"; + } + } catch (e) { + } + return "production"; +} +function isDevelopment() { + return detectEnvironment() === "development"; +} +function computeRoute(pathname, pathParams) { + if (!pathname || !pathParams) { + return pathname; + } + let result = pathname; + try { + const entries = Object.entries(pathParams); + for (const [key, value] of entries) { + if (!Array.isArray(value)) { + const matcher = turnValueToRegExp(value); + if (matcher.test(result)) { + result = result.replace(matcher, `/[${key}]`); + } + } + } + for (const [key, value] of entries) { + if (Array.isArray(value)) { + const matcher = turnValueToRegExp(value.join("/")); + if (matcher.test(result)) { + result = result.replace(matcher, `/[...${key}]`); + } + } + } + return result; + } catch (e) { + return pathname; + } +} +function turnValueToRegExp(value) { + return new RegExp(`/${escapeRegExp(value)}(?=[/?#]|$)`); +} +function escapeRegExp(string) { + return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); +} + +// src/generic.ts +var SCRIPT_URL = "https://va.vercel-scripts.com/v1/speed-insights"; +var PROD_SCRIPT_URL = `${SCRIPT_URL}/script.js`; +var DEV_SCRIPT_URL = `${SCRIPT_URL}/script.debug.js`; +var PROXY_SCRIPT_URL = "/_vercel/speed-insights/script.js"; +function injectSpeedInsights(props = {}) { + var _a; + if (!isBrowser() || props.route === null) + return null; + initQueue(); + const isSelfHosted = Boolean(props.dsn); + const productionScript = isSelfHosted ? PROD_SCRIPT_URL : PROXY_SCRIPT_URL; + const src = props.scriptSrc || (isDevelopment() ? DEV_SCRIPT_URL : productionScript); + if (document.head.querySelector(`script[src*="${src}"]`)) + return null; + if (props.beforeSend) { + (_a = window.si) == null ? void 0 : _a.call(window, "beforeSend", props.beforeSend); + } + const script = document.createElement("script"); + script.src = src; + script.defer = true; + script.dataset.sdkn = name + (props.framework ? `/${props.framework}` : ""); + script.dataset.sdkv = version; + if (props.sampleRate) { + script.dataset.sampleRate = props.sampleRate.toString(); + } + if (props.route) { + script.dataset.route = props.route; + } + if (props.endpoint) { + script.dataset.endpoint = props.endpoint; + } + if (props.dsn) { + script.dataset.dsn = props.dsn; + } + if (isDevelopment() && props.debug === false) { + script.dataset.debug = "false"; + } + script.onerror = () => { + console.log( + `[Vercel Speed Insights] Failed to load script from ${src}. Please check if any content blockers are enabled and try again.` + ); + }; + document.head.appendChild(script); + return { + setRoute: (route) => { + script.dataset.route = route ?? void 0; + } + }; +} + +// src/react/index.tsx +function SpeedInsights(props) { + useEffect(() => { + var _a; + if (props.beforeSend) { + (_a = window.si) == null ? void 0 : _a.call(window, "beforeSend", props.beforeSend); + } + }, [props.beforeSend]); + const setScriptRoute = useRef(null); + useEffect(() => { + if (!setScriptRoute.current) { + const script = injectSpeedInsights({ + framework: props.framework || "react", + ...props + }); + if (script) { + setScriptRoute.current = script.setRoute; + } + } else if (props.route) { + setScriptRoute.current(props.route); + } + }, [props.route]); + return null; +} + +// src/nextjs/utils.ts +import { useParams, usePathname, useSearchParams } from "next/navigation.js"; +var useRoute = () => { + const params = useParams(); + const searchParams = useSearchParams() || new URLSearchParams(); + const path = usePathname(); + if (!params) { + return null; + } + const finalParams = Object.keys(params).length ? params : Object.fromEntries(searchParams.entries()); + return computeRoute(path, finalParams); +}; + +// src/nextjs/index.tsx +function SpeedInsightsComponent(props) { + const route = useRoute(); + return /* @__PURE__ */ React.createElement(SpeedInsights, { route, ...props, framework: "next" }); +} +function SpeedInsights2(props) { + return /* @__PURE__ */ React.createElement(Suspense, { fallback: null }, /* @__PURE__ */ React.createElement(SpeedInsightsComponent, { ...props })); +} +export { + SpeedInsights2 as SpeedInsights +}; +//# sourceMappingURL=index.mjs.map \ No newline at end of file diff --git a/node_modules/@vercel/speed-insights/dist/next/index.mjs.map b/node_modules/@vercel/speed-insights/dist/next/index.mjs.map new file mode 100644 index 0000000..a4e5824 --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/next/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/nextjs/index.tsx","../../src/react/index.tsx","../../package.json","../../src/queue.ts","../../src/utils.ts","../../src/generic.ts","../../src/nextjs/utils.ts"],"sourcesContent":["import React, { Suspense } from 'react';\nimport { SpeedInsights as SpeedInsightsScript } from '../react';\nimport type { SpeedInsightsProps } from '../types';\nimport { useRoute } from './utils';\n\ntype Props = Omit;\n\nfunction SpeedInsightsComponent(props: Props): React.ReactElement {\n const route = useRoute();\n\n return ;\n}\n\nexport function SpeedInsights(props: Props): null {\n // Because of incompatible types between ReactNode in React 19 and React 18 we return null (which is also what we render)\n return (\n \n \n \n ) as never;\n}\n","'use client';\nimport { useEffect, useRef } from 'react';\nimport type { SpeedInsightsProps } from '../types';\nimport { computeRoute, injectSpeedInsights } from '../generic';\n\nexport function SpeedInsights(\n props: SpeedInsightsProps & {\n framework?: string;\n },\n): JSX.Element | null {\n useEffect(() => {\n if (props.beforeSend) {\n window.si?.('beforeSend', props.beforeSend);\n }\n }, [props.beforeSend]);\n\n const setScriptRoute = useRef<((path: string) => void) | null>(null);\n useEffect(() => {\n if (!setScriptRoute.current) {\n const script = injectSpeedInsights({\n framework: props.framework || 'react',\n ...props,\n });\n if (script) {\n setScriptRoute.current = script.setRoute;\n }\n } else if (props.route) {\n setScriptRoute.current(props.route);\n }\n }, [props.route]);\n\n return null;\n}\n\nexport { computeRoute };\n","{\n \"name\": \"@vercel/speed-insights\",\n \"version\": \"1.1.0\",\n \"description\": \"Speed Insights is a tool for measuring web performance and providing suggestions for improvement.\",\n \"keywords\": [\n \"speed-insights\",\n \"vercel\"\n ],\n \"repository\": {\n \"url\": \"github:vercel/speed-insights\",\n \"directory\": \"packages/web\"\n },\n \"license\": \"Apache-2.0\",\n \"exports\": {\n \"./package.json\": \"./package.json\",\n \".\": {\n \"browser\": \"./dist/index.mjs\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\"\n },\n \"./astro\": {\n \"import\": \"./dist/astro/component.ts\"\n },\n \"./next\": {\n \"browser\": \"./dist/next/index.mjs\",\n \"import\": \"./dist/next/index.mjs\",\n \"require\": \"./dist/next/index.js\"\n },\n \"./nuxt\": {\n \"browser\": \"./dist/nuxt/index.mjs\",\n \"import\": \"./dist/nuxt/index.mjs\",\n \"require\": \"./dist/nuxt/index.js\"\n },\n \"./react\": {\n \"browser\": \"./dist/react/index.mjs\",\n \"import\": \"./dist/react/index.mjs\",\n \"require\": \"./dist/react/index.js\"\n },\n \"./remix\": {\n \"browser\": \"./dist/remix/index.mjs\",\n \"import\": \"./dist/remix/index.mjs\",\n \"require\": \"./dist/remix/index.js\"\n },\n \"./sveltekit\": {\n \"svelte\": \"./dist/sveltekit/index.mjs\",\n \"types\": \"./dist/sveltekit/index.d.ts\"\n },\n \"./vue\": {\n \"browser\": \"./dist/vue/index.mjs\",\n \"import\": \"./dist/vue/index.mjs\",\n \"require\": \"./dist/vue/index.js\"\n }\n },\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \"*\": [\n \"dist/index.d.ts\"\n ],\n \"react\": [\n \"dist/react/index.d.ts\"\n ],\n \"next\": [\n \"dist/next/index.d.ts\"\n ],\n \"nuxt\": [\n \"dist/nuxt/index.d.ts\"\n ],\n \"remix\": [\n \"dist/remix/index.d.ts\"\n ],\n \"sveltekit\": [\n \"dist/sveltekit/index.d.ts\"\n ],\n \"vue\": [\n \"dist/vue/index.d.ts\"\n ]\n }\n },\n \"scripts\": {\n \"build\": \"tsup && pnpm copy-astro\",\n \"copy-astro\": \"cp -R src/astro dist/\",\n \"dev\": \"pnpm copy-astro && tsup --watch\",\n \"postinstall\": \"node scripts/postinstall.mjs\",\n \"lint\": \"eslint .\",\n \"lint-fix\": \"eslint . --fix\",\n \"test\": \"jest\",\n \"type-check\": \"tsc --noEmit\"\n },\n \"devDependencies\": {\n \"@jest/globals\": \"^29.7.0\",\n \"@remix-run/react\": \"^2.5.0\",\n \"@sveltejs/kit\": \"^2.7\",\n \"@swc/core\": \"^1.3.103\",\n \"@swc/jest\": \"^0.2.29\",\n \"@testing-library/jest-dom\": \"^6.6.3\",\n \"@testing-library/react\": \"^16.0.1\",\n \"@types/node\": \"^20.11.4\",\n \"@types/react\": \"^18.2.48\",\n \"copyfiles\": \"^2.4.1\",\n \"jest\": \"^29.7.0\",\n \"jest-environment-jsdom\": \"^29.7.0\",\n \"next\": \"^14.0.4\",\n \"react\": \"^18.2.0\",\n \"react-dom\": \"^18.2.0\",\n \"svelte\": \"^5\",\n \"tsup\": \"7.2.0\",\n \"vue\": \"^3.4.14\",\n \"vue-router\": \"^4.2.5\"\n },\n \"peerDependencies\": {\n \"@sveltejs/kit\": \"^1 || ^2\",\n \"next\": \">= 13\",\n \"react\": \"^18 || ^19 || ^19.0.0-rc\",\n \"svelte\": \">= 4\",\n \"vue\": \"^3\",\n \"vue-router\": \"^4\"\n },\n \"peerDependenciesMeta\": {\n \"@sveltejs/kit\": {\n \"optional\": true\n },\n \"next\": {\n \"optional\": true\n },\n \"react\": {\n \"optional\": true\n },\n \"svelte\": {\n \"optional\": true\n },\n \"vue\": {\n \"optional\": true\n },\n \"vue-router\": {\n \"optional\": true\n }\n }\n}\n","export const initQueue = (): void => {\n // initialize va until script is loaded\n if (window.si) return;\n\n window.si = function a(...params): void {\n (window.siq = window.siq || []).push(params);\n };\n};\n","export function isBrowser(): boolean {\n return typeof window !== 'undefined';\n}\n\nfunction detectEnvironment(): 'development' | 'production' {\n try {\n const env = process.env.NODE_ENV;\n if (env === 'development' || env === 'test') {\n return 'development';\n }\n } catch (e) {\n // do nothing, this is okay\n }\n return 'production';\n}\n\nexport function isProduction(): boolean {\n return detectEnvironment() === 'production';\n}\n\nexport function isDevelopment(): boolean {\n return detectEnvironment() === 'development';\n}\n\nexport function computeRoute(\n pathname: string | null,\n pathParams: Record | null,\n): string | null {\n if (!pathname || !pathParams) {\n return pathname;\n }\n\n let result = pathname;\n try {\n const entries = Object.entries(pathParams);\n // simple keys must be handled first\n for (const [key, value] of entries) {\n if (!Array.isArray(value)) {\n const matcher = turnValueToRegExp(value);\n if (matcher.test(result)) {\n result = result.replace(matcher, `/[${key}]`);\n }\n }\n }\n // array values next\n for (const [key, value] of entries) {\n if (Array.isArray(value)) {\n const matcher = turnValueToRegExp(value.join('/'));\n if (matcher.test(result)) {\n result = result.replace(matcher, `/[...${key}]`);\n }\n }\n }\n return result;\n } catch (e) {\n return pathname;\n }\n}\n\nfunction turnValueToRegExp(value: string): RegExp {\n return new RegExp(`/${escapeRegExp(value)}(?=[/?#]|$)`);\n}\n\nfunction escapeRegExp(string: string): string {\n return string.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n","import { name as packageName, version } from '../package.json';\nimport { initQueue } from './queue';\nimport type { SpeedInsightsProps } from './types';\nimport { isBrowser, isDevelopment, computeRoute } from './utils';\n\nconst SCRIPT_URL = 'https://va.vercel-scripts.com/v1/speed-insights';\nconst PROD_SCRIPT_URL = `${SCRIPT_URL}/script.js`;\nconst DEV_SCRIPT_URL = `${SCRIPT_URL}/script.debug.js`;\nconst PROXY_SCRIPT_URL = '/_vercel/speed-insights/script.js';\n\n/**\n * Injects the Vercel Speed Insights script into the page head and starts tracking page views. Read more in our [documentation](https://vercel.com/docs/speed-insights).\n * @param [props] - Speed Insights options.\n * @param [props.debug] - Whether to enable debug logging in development. Defaults to `true`.\n * @param [props.beforeSend] - A middleware function to modify events before they are sent. Should return the event object or `null` to cancel the event.\n * @param [props.sampleRate] - When setting to 0.5, 50% of the events will be sent to Vercel Speed Insights. Defaults to `1`.\n * @param [props.route] - The dynamic route of the page.\n * @param [props.dsn] - The DSN of the project to send events to. Only required when self-hosting.\n */\nfunction injectSpeedInsights(\n props: SpeedInsightsProps & {\n framework?: string;\n } = {},\n): {\n setRoute: (route: string | null) => void;\n} | null {\n // When route is null, it means that pages router is not ready yet. Will resolve soon\n if (!isBrowser() || props.route === null) return null;\n\n initQueue();\n\n const isSelfHosted = Boolean(props.dsn);\n\n const productionScript = isSelfHosted ? PROD_SCRIPT_URL : PROXY_SCRIPT_URL;\n\n const src =\n props.scriptSrc || (isDevelopment() ? DEV_SCRIPT_URL : productionScript);\n\n if (document.head.querySelector(`script[src*=\"${src}\"]`)) return null;\n\n if (props.beforeSend) {\n window.si?.('beforeSend', props.beforeSend);\n }\n\n const script = document.createElement('script');\n script.src = src;\n script.defer = true;\n script.dataset.sdkn =\n packageName + (props.framework ? `/${props.framework}` : '');\n script.dataset.sdkv = version;\n\n if (props.sampleRate) {\n script.dataset.sampleRate = props.sampleRate.toString();\n }\n if (props.route) {\n script.dataset.route = props.route;\n }\n if (props.endpoint) {\n script.dataset.endpoint = props.endpoint;\n }\n if (props.dsn) {\n script.dataset.dsn = props.dsn;\n }\n if (isDevelopment() && props.debug === false) {\n script.dataset.debug = 'false';\n }\n\n script.onerror = (): void => {\n // eslint-disable-next-line no-console -- Logging is okay here\n console.log(\n `[Vercel Speed Insights] Failed to load script from ${src}. Please check if any content blockers are enabled and try again.`,\n );\n };\n\n document.head.appendChild(script);\n\n return {\n setRoute: (route: string | null): void => {\n script.dataset.route = route ?? undefined;\n },\n };\n}\n\nexport { injectSpeedInsights, computeRoute };\nexport type { SpeedInsightsProps };\n\n// eslint-disable-next-line import/no-default-export -- Allow default export\nexport default {\n injectSpeedInsights,\n computeRoute,\n};\n","'use client';\n/* eslint-disable @typescript-eslint/no-unnecessary-condition -- can be empty in pages router */\nimport { useParams, usePathname, useSearchParams } from 'next/navigation.js';\nimport { computeRoute } from '../utils';\n\nexport const useRoute = (): string | null => {\n const params = useParams();\n const searchParams = useSearchParams() || new URLSearchParams();\n const path = usePathname();\n // Until we have route parameters, we don't compute the route\n if (!params) {\n return null;\n }\n // in Next.js@13, useParams() could return an empty object for pages router, and we default to searchParams.\n const finalParams = Object.keys(params).length\n ? params\n : Object.fromEntries(searchParams.entries());\n return computeRoute(path, finalParams);\n};\n"],"mappings":";;;AAAA,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CACrC;AAEJ;","names":["SpeedInsights"]} \ No newline at end of file diff --git a/node_modules/@vercel/speed-insights/dist/nuxt/index.d.mts b/node_modules/@vercel/speed-insights/dist/nuxt/index.d.mts new file mode 100644 index 0000000..f2f121b --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/nuxt/index.d.mts @@ -0,0 +1,3 @@ +declare const SpeedInsights: any; + +export { SpeedInsights }; diff --git a/node_modules/@vercel/speed-insights/dist/nuxt/index.d.ts b/node_modules/@vercel/speed-insights/dist/nuxt/index.d.ts new file mode 100644 index 0000000..f2f121b --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/nuxt/index.d.ts @@ -0,0 +1,3 @@ +declare const SpeedInsights: any; + +export { SpeedInsights }; diff --git a/node_modules/@vercel/speed-insights/dist/nuxt/index.js b/node_modules/@vercel/speed-insights/dist/nuxt/index.js new file mode 100644 index 0000000..5cf8cf6 --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/nuxt/index.js @@ -0,0 +1,182 @@ +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __export = (target, all) => { + for (var name2 in all) + __defProp(target, name2, { get: all[name2], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/nuxt/index.ts +var nuxt_exports = {}; +__export(nuxt_exports, { + SpeedInsights: () => SpeedInsights +}); +module.exports = __toCommonJS(nuxt_exports); + +// src/vue/create-component.ts +var import_vue = require("vue"); +var import_vue_router = require("vue-router"); + +// package.json +var name = "@vercel/speed-insights"; +var version = "1.1.0"; + +// src/queue.ts +var initQueue = () => { + if (window.si) + return; + window.si = function a(...params) { + (window.siq = window.siq || []).push(params); + }; +}; + +// src/utils.ts +function isBrowser() { + return typeof window !== "undefined"; +} +function detectEnvironment() { + try { + const env = process.env.NODE_ENV; + if (env === "development" || env === "test") { + return "development"; + } + } catch (e) { + } + return "production"; +} +function isDevelopment() { + return detectEnvironment() === "development"; +} +function computeRoute(pathname, pathParams) { + if (!pathname || !pathParams) { + return pathname; + } + let result = pathname; + try { + const entries = Object.entries(pathParams); + for (const [key, value] of entries) { + if (!Array.isArray(value)) { + const matcher = turnValueToRegExp(value); + if (matcher.test(result)) { + result = result.replace(matcher, `/[${key}]`); + } + } + } + for (const [key, value] of entries) { + if (Array.isArray(value)) { + const matcher = turnValueToRegExp(value.join("/")); + if (matcher.test(result)) { + result = result.replace(matcher, `/[...${key}]`); + } + } + } + return result; + } catch (e) { + return pathname; + } +} +function turnValueToRegExp(value) { + return new RegExp(`/${escapeRegExp(value)}(?=[/?#]|$)`); +} +function escapeRegExp(string) { + return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); +} + +// src/generic.ts +var SCRIPT_URL = "https://va.vercel-scripts.com/v1/speed-insights"; +var PROD_SCRIPT_URL = `${SCRIPT_URL}/script.js`; +var DEV_SCRIPT_URL = `${SCRIPT_URL}/script.debug.js`; +var PROXY_SCRIPT_URL = "/_vercel/speed-insights/script.js"; +function injectSpeedInsights(props = {}) { + var _a; + if (!isBrowser() || props.route === null) + return null; + initQueue(); + const isSelfHosted = Boolean(props.dsn); + const productionScript = isSelfHosted ? PROD_SCRIPT_URL : PROXY_SCRIPT_URL; + const src = props.scriptSrc || (isDevelopment() ? DEV_SCRIPT_URL : productionScript); + if (document.head.querySelector(`script[src*="${src}"]`)) + return null; + if (props.beforeSend) { + (_a = window.si) == null ? void 0 : _a.call(window, "beforeSend", props.beforeSend); + } + const script = document.createElement("script"); + script.src = src; + script.defer = true; + script.dataset.sdkn = name + (props.framework ? `/${props.framework}` : ""); + script.dataset.sdkv = version; + if (props.sampleRate) { + script.dataset.sampleRate = props.sampleRate.toString(); + } + if (props.route) { + script.dataset.route = props.route; + } + if (props.endpoint) { + script.dataset.endpoint = props.endpoint; + } + if (props.dsn) { + script.dataset.dsn = props.dsn; + } + if (isDevelopment() && props.debug === false) { + script.dataset.debug = "false"; + } + script.onerror = () => { + console.log( + `[Vercel Speed Insights] Failed to load script from ${src}. Please check if any content blockers are enabled and try again.` + ); + }; + document.head.appendChild(script); + return { + setRoute: (route) => { + script.dataset.route = route ?? void 0; + } + }; +} + +// src/vue/create-component.ts +function createComponent(framework = "vue") { + return (0, import_vue.defineComponent)({ + props: [ + "dsn", + "sampleRate", + "beforeSend", + "debug", + "scriptSrc", + "endpoint" + ], + setup(props) { + const route = (0, import_vue_router.useRoute)(); + const configure = injectSpeedInsights({ ...props, framework }); + if (route && configure) { + const changeRoute = () => { + configure.setRoute(computeRoute(route.path, route.params)); + }; + changeRoute(); + (0, import_vue.watch)(route, changeRoute); + } + }, + // Vue component must have a render function, or a template. + render() { + return null; + } + }); +} + +// src/nuxt/index.ts +var SpeedInsights = createComponent("nuxt"); +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + SpeedInsights +}); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/node_modules/@vercel/speed-insights/dist/nuxt/index.js.map b/node_modules/@vercel/speed-insights/dist/nuxt/index.js.map new file mode 100644 index 0000000..dc234af --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/nuxt/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/nuxt/index.ts","../../src/vue/create-component.ts","../../package.json","../../src/queue.ts","../../src/utils.ts","../../src/generic.ts"],"sourcesContent":["import { createComponent } from '../vue/create-component';\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- vue's defineComponent return type is any\nexport const SpeedInsights = createComponent('nuxt');\n","import { defineComponent, watch } from 'vue';\n// for barebone vue project, vite will issue a warning since 'vue-router' import can't be resolved,\nimport { useRoute } from 'vue-router';\nimport { injectSpeedInsights, type SpeedInsightsProps } from '../generic';\nimport { computeRoute } from '../utils';\n\nexport function createComponent(\n framework = 'vue',\n): ReturnType {\n return defineComponent({\n props: [\n 'dsn',\n 'sampleRate',\n 'beforeSend',\n 'debug',\n 'scriptSrc',\n 'endpoint',\n ],\n setup(props: Omit) {\n const route = useRoute();\n const configure = injectSpeedInsights({ ...props, framework });\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- route is undefined for barebone vue project\n if (route && configure) {\n const changeRoute = (): void => {\n configure.setRoute(computeRoute(route.path, route.params));\n };\n\n changeRoute();\n watch(route, changeRoute);\n }\n },\n // Vue component must have a render function, or a template.\n render() {\n return null;\n },\n });\n}\n","{\n \"name\": \"@vercel/speed-insights\",\n \"version\": \"1.1.0\",\n \"description\": \"Speed Insights is a tool for measuring web performance and providing suggestions for improvement.\",\n \"keywords\": [\n \"speed-insights\",\n \"vercel\"\n ],\n \"repository\": {\n \"url\": \"github:vercel/speed-insights\",\n \"directory\": \"packages/web\"\n },\n \"license\": \"Apache-2.0\",\n \"exports\": {\n \"./package.json\": \"./package.json\",\n \".\": {\n \"browser\": \"./dist/index.mjs\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\"\n },\n \"./astro\": {\n \"import\": \"./dist/astro/component.ts\"\n },\n \"./next\": {\n \"browser\": \"./dist/next/index.mjs\",\n \"import\": \"./dist/next/index.mjs\",\n \"require\": \"./dist/next/index.js\"\n },\n \"./nuxt\": {\n \"browser\": \"./dist/nuxt/index.mjs\",\n \"import\": \"./dist/nuxt/index.mjs\",\n \"require\": \"./dist/nuxt/index.js\"\n },\n \"./react\": {\n \"browser\": \"./dist/react/index.mjs\",\n \"import\": \"./dist/react/index.mjs\",\n \"require\": \"./dist/react/index.js\"\n },\n \"./remix\": {\n \"browser\": \"./dist/remix/index.mjs\",\n \"import\": \"./dist/remix/index.mjs\",\n \"require\": \"./dist/remix/index.js\"\n },\n \"./sveltekit\": {\n \"svelte\": \"./dist/sveltekit/index.mjs\",\n \"types\": \"./dist/sveltekit/index.d.ts\"\n },\n \"./vue\": {\n \"browser\": \"./dist/vue/index.mjs\",\n \"import\": \"./dist/vue/index.mjs\",\n \"require\": \"./dist/vue/index.js\"\n }\n },\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \"*\": [\n \"dist/index.d.ts\"\n ],\n \"react\": [\n \"dist/react/index.d.ts\"\n ],\n \"next\": [\n \"dist/next/index.d.ts\"\n ],\n \"nuxt\": [\n \"dist/nuxt/index.d.ts\"\n ],\n \"remix\": [\n \"dist/remix/index.d.ts\"\n ],\n \"sveltekit\": [\n \"dist/sveltekit/index.d.ts\"\n ],\n \"vue\": [\n \"dist/vue/index.d.ts\"\n ]\n }\n },\n \"scripts\": {\n \"build\": \"tsup && pnpm copy-astro\",\n \"copy-astro\": \"cp -R src/astro dist/\",\n \"dev\": \"pnpm copy-astro && tsup --watch\",\n \"postinstall\": \"node scripts/postinstall.mjs\",\n \"lint\": \"eslint .\",\n \"lint-fix\": \"eslint . --fix\",\n \"test\": \"jest\",\n \"type-check\": \"tsc --noEmit\"\n },\n \"devDependencies\": {\n \"@jest/globals\": \"^29.7.0\",\n \"@remix-run/react\": \"^2.5.0\",\n \"@sveltejs/kit\": \"^2.7\",\n \"@swc/core\": \"^1.3.103\",\n \"@swc/jest\": \"^0.2.29\",\n \"@testing-library/jest-dom\": \"^6.6.3\",\n \"@testing-library/react\": \"^16.0.1\",\n \"@types/node\": \"^20.11.4\",\n \"@types/react\": \"^18.2.48\",\n \"copyfiles\": \"^2.4.1\",\n \"jest\": \"^29.7.0\",\n \"jest-environment-jsdom\": \"^29.7.0\",\n \"next\": \"^14.0.4\",\n \"react\": \"^18.2.0\",\n \"react-dom\": \"^18.2.0\",\n \"svelte\": \"^5\",\n \"tsup\": \"7.2.0\",\n \"vue\": \"^3.4.14\",\n \"vue-router\": \"^4.2.5\"\n },\n \"peerDependencies\": {\n \"@sveltejs/kit\": \"^1 || ^2\",\n \"next\": \">= 13\",\n \"react\": \"^18 || ^19 || ^19.0.0-rc\",\n \"svelte\": \">= 4\",\n \"vue\": \"^3\",\n \"vue-router\": \"^4\"\n },\n \"peerDependenciesMeta\": {\n \"@sveltejs/kit\": {\n \"optional\": true\n },\n \"next\": {\n \"optional\": true\n },\n \"react\": {\n \"optional\": true\n },\n \"svelte\": {\n \"optional\": true\n },\n \"vue\": {\n \"optional\": true\n },\n \"vue-router\": {\n \"optional\": true\n }\n }\n}\n","export const initQueue = (): void => {\n // initialize va until script is loaded\n if (window.si) return;\n\n window.si = function a(...params): void {\n (window.siq = window.siq || []).push(params);\n };\n};\n","export function isBrowser(): boolean {\n return typeof window !== 'undefined';\n}\n\nfunction detectEnvironment(): 'development' | 'production' {\n try {\n const env = process.env.NODE_ENV;\n if (env === 'development' || env === 'test') {\n return 'development';\n }\n } catch (e) {\n // do nothing, this is okay\n }\n return 'production';\n}\n\nexport function isProduction(): boolean {\n return detectEnvironment() === 'production';\n}\n\nexport function isDevelopment(): boolean {\n return detectEnvironment() === 'development';\n}\n\nexport function computeRoute(\n pathname: string | null,\n pathParams: Record | null,\n): string | null {\n if (!pathname || !pathParams) {\n return pathname;\n }\n\n let result = pathname;\n try {\n const entries = Object.entries(pathParams);\n // simple keys must be handled first\n for (const [key, value] of entries) {\n if (!Array.isArray(value)) {\n const matcher = turnValueToRegExp(value);\n if (matcher.test(result)) {\n result = result.replace(matcher, `/[${key}]`);\n }\n }\n }\n // array values next\n for (const [key, value] of entries) {\n if (Array.isArray(value)) {\n const matcher = turnValueToRegExp(value.join('/'));\n if (matcher.test(result)) {\n result = result.replace(matcher, `/[...${key}]`);\n }\n }\n }\n return result;\n } catch (e) {\n return pathname;\n }\n}\n\nfunction turnValueToRegExp(value: string): RegExp {\n return new RegExp(`/${escapeRegExp(value)}(?=[/?#]|$)`);\n}\n\nfunction escapeRegExp(string: string): string {\n return string.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n","import { name as packageName, version } from '../package.json';\nimport { initQueue } from './queue';\nimport type { SpeedInsightsProps } from './types';\nimport { isBrowser, isDevelopment, computeRoute } from './utils';\n\nconst SCRIPT_URL = 'https://va.vercel-scripts.com/v1/speed-insights';\nconst PROD_SCRIPT_URL = `${SCRIPT_URL}/script.js`;\nconst DEV_SCRIPT_URL = `${SCRIPT_URL}/script.debug.js`;\nconst PROXY_SCRIPT_URL = '/_vercel/speed-insights/script.js';\n\n/**\n * Injects the Vercel Speed Insights script into the page head and starts tracking page views. Read more in our [documentation](https://vercel.com/docs/speed-insights).\n * @param [props] - Speed Insights options.\n * @param [props.debug] - Whether to enable debug logging in development. Defaults to `true`.\n * @param [props.beforeSend] - A middleware function to modify events before they are sent. Should return the event object or `null` to cancel the event.\n * @param [props.sampleRate] - When setting to 0.5, 50% of the events will be sent to Vercel Speed Insights. Defaults to `1`.\n * @param [props.route] - The dynamic route of the page.\n * @param [props.dsn] - The DSN of the project to send events to. Only required when self-hosting.\n */\nfunction injectSpeedInsights(\n props: SpeedInsightsProps & {\n framework?: string;\n } = {},\n): {\n setRoute: (route: string | null) => void;\n} | null {\n // When route is null, it means that pages router is not ready yet. Will resolve soon\n if (!isBrowser() || props.route === null) return null;\n\n initQueue();\n\n const isSelfHosted = Boolean(props.dsn);\n\n const productionScript = isSelfHosted ? PROD_SCRIPT_URL : PROXY_SCRIPT_URL;\n\n const src =\n props.scriptSrc || (isDevelopment() ? DEV_SCRIPT_URL : productionScript);\n\n if (document.head.querySelector(`script[src*=\"${src}\"]`)) return null;\n\n if (props.beforeSend) {\n window.si?.('beforeSend', props.beforeSend);\n }\n\n const script = document.createElement('script');\n script.src = src;\n script.defer = true;\n script.dataset.sdkn =\n packageName + (props.framework ? `/${props.framework}` : '');\n script.dataset.sdkv = version;\n\n if (props.sampleRate) {\n script.dataset.sampleRate = props.sampleRate.toString();\n }\n if (props.route) {\n script.dataset.route = props.route;\n }\n if (props.endpoint) {\n script.dataset.endpoint = props.endpoint;\n }\n if (props.dsn) {\n script.dataset.dsn = props.dsn;\n }\n if (isDevelopment() && props.debug === false) {\n script.dataset.debug = 'false';\n }\n\n script.onerror = (): void => {\n // eslint-disable-next-line no-console -- Logging is okay here\n console.log(\n `[Vercel Speed Insights] Failed to load script from ${src}. Please check if any content blockers are enabled and try again.`,\n );\n };\n\n document.head.appendChild(script);\n\n return {\n setRoute: (route: string | null): void => {\n script.dataset.route = route ?? undefined;\n },\n };\n}\n\nexport { injectSpeedInsights, computeRoute };\nexport type { SpeedInsightsProps };\n\n// eslint-disable-next-line import/no-default-export -- Allow default export\nexport default {\n injectSpeedInsights,\n computeRoute,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iBAAuC;AAEvC,wBAAyB;;;ACDvB,WAAQ;AACR,cAAW;;;ACFN,IAAM,YAAY,MAAY;AAEnC,MAAI,OAAO;AAAI;AAEf,SAAO,KAAK,SAAS,KAAK,QAAc;AACtC,KAAC,OAAO,MAAM,OAAO,OAAO,CAAC,GAAG,KAAK,MAAM;AAAA,EAC7C;AACF;;;ACPO,SAAS,YAAqB;AACnC,SAAO,OAAO,WAAW;AAC3B;AAEA,SAAS,oBAAkD;AACzD,MAAI;AACF,UAAM,MAAM,QAAQ,IAAI;AACxB,QAAI,QAAQ,iBAAiB,QAAQ,QAAQ;AAC3C,aAAO;AAAA,IACT;AAAA,EACF,SAAS,GAAG;AAAA,EAEZ;AACA,SAAO;AACT;AAMO,SAAS,gBAAyB;AACvC,SAAO,kBAAkB,MAAM;AACjC;AAEO,SAAS,aACd,UACA,YACe;AACf,MAAI,CAAC,YAAY,CAAC,YAAY;AAC5B,WAAO;AAAA,EACT;AAEA,MAAI,SAAS;AACb,MAAI;AACF,UAAM,UAAU,OAAO,QAAQ,UAAU;AAEzC,eAAW,CAAC,KAAK,KAAK,KAAK,SAAS;AAClC,UAA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node_modules/@vercel/speed-insights/dist/nuxt/index.mjs b/node_modules/@vercel/speed-insights/dist/nuxt/index.mjs new file mode 100644 index 0000000..d332ac1 --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/nuxt/index.mjs @@ -0,0 +1,155 @@ +// src/vue/create-component.ts +import { defineComponent, watch } from "vue"; +import { useRoute } from "vue-router"; + +// package.json +var name = "@vercel/speed-insights"; +var version = "1.1.0"; + +// src/queue.ts +var initQueue = () => { + if (window.si) + return; + window.si = function a(...params) { + (window.siq = window.siq || []).push(params); + }; +}; + +// src/utils.ts +function isBrowser() { + return typeof window !== "undefined"; +} +function detectEnvironment() { + try { + const env = process.env.NODE_ENV; + if (env === "development" || env === "test") { + return "development"; + } + } catch (e) { + } + return "production"; +} +function isDevelopment() { + return detectEnvironment() === "development"; +} +function computeRoute(pathname, pathParams) { + if (!pathname || !pathParams) { + return pathname; + } + let result = pathname; + try { + const entries = Object.entries(pathParams); + for (const [key, value] of entries) { + if (!Array.isArray(value)) { + const matcher = turnValueToRegExp(value); + if (matcher.test(result)) { + result = result.replace(matcher, `/[${key}]`); + } + } + } + for (const [key, value] of entries) { + if (Array.isArray(value)) { + const matcher = turnValueToRegExp(value.join("/")); + if (matcher.test(result)) { + result = result.replace(matcher, `/[...${key}]`); + } + } + } + return result; + } catch (e) { + return pathname; + } +} +function turnValueToRegExp(value) { + return new RegExp(`/${escapeRegExp(value)}(?=[/?#]|$)`); +} +function escapeRegExp(string) { + return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); +} + +// src/generic.ts +var SCRIPT_URL = "https://va.vercel-scripts.com/v1/speed-insights"; +var PROD_SCRIPT_URL = `${SCRIPT_URL}/script.js`; +var DEV_SCRIPT_URL = `${SCRIPT_URL}/script.debug.js`; +var PROXY_SCRIPT_URL = "/_vercel/speed-insights/script.js"; +function injectSpeedInsights(props = {}) { + var _a; + if (!isBrowser() || props.route === null) + return null; + initQueue(); + const isSelfHosted = Boolean(props.dsn); + const productionScript = isSelfHosted ? PROD_SCRIPT_URL : PROXY_SCRIPT_URL; + const src = props.scriptSrc || (isDevelopment() ? DEV_SCRIPT_URL : productionScript); + if (document.head.querySelector(`script[src*="${src}"]`)) + return null; + if (props.beforeSend) { + (_a = window.si) == null ? void 0 : _a.call(window, "beforeSend", props.beforeSend); + } + const script = document.createElement("script"); + script.src = src; + script.defer = true; + script.dataset.sdkn = name + (props.framework ? `/${props.framework}` : ""); + script.dataset.sdkv = version; + if (props.sampleRate) { + script.dataset.sampleRate = props.sampleRate.toString(); + } + if (props.route) { + script.dataset.route = props.route; + } + if (props.endpoint) { + script.dataset.endpoint = props.endpoint; + } + if (props.dsn) { + script.dataset.dsn = props.dsn; + } + if (isDevelopment() && props.debug === false) { + script.dataset.debug = "false"; + } + script.onerror = () => { + console.log( + `[Vercel Speed Insights] Failed to load script from ${src}. Please check if any content blockers are enabled and try again.` + ); + }; + document.head.appendChild(script); + return { + setRoute: (route) => { + script.dataset.route = route ?? void 0; + } + }; +} + +// src/vue/create-component.ts +function createComponent(framework = "vue") { + return defineComponent({ + props: [ + "dsn", + "sampleRate", + "beforeSend", + "debug", + "scriptSrc", + "endpoint" + ], + setup(props) { + const route = useRoute(); + const configure = injectSpeedInsights({ ...props, framework }); + if (route && configure) { + const changeRoute = () => { + configure.setRoute(computeRoute(route.path, route.params)); + }; + changeRoute(); + watch(route, changeRoute); + } + }, + // Vue component must have a render function, or a template. + render() { + return null; + } + }); +} + +// src/nuxt/index.ts +var SpeedInsights = createComponent("nuxt"); +export { + SpeedInsights +}; +//# sourceMappingURL=index.mjs.map \ No newline at end of file diff --git a/node_modules/@vercel/speed-insights/dist/nuxt/index.mjs.map b/node_modules/@vercel/speed-insights/dist/nuxt/index.mjs.map new file mode 100644 index 0000000..b11b248 --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/nuxt/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/vue/create-component.ts","../../package.json","../../src/queue.ts","../../src/utils.ts","../../src/generic.ts","../../src/nuxt/index.ts"],"sourcesContent":["import { defineComponent, watch } from 'vue';\n// for barebone vue project, vite will issue a warning since 'vue-router' import can't be resolved,\nimport { useRoute } from 'vue-router';\nimport { injectSpeedInsights, type SpeedInsightsProps } from '../generic';\nimport { computeRoute } from '../utils';\n\nexport function createComponent(\n framework = 'vue',\n): ReturnType {\n return defineComponent({\n props: [\n 'dsn',\n 'sampleRate',\n 'beforeSend',\n 'debug',\n 'scriptSrc',\n 'endpoint',\n ],\n setup(props: Omit) {\n const route = useRoute();\n const configure = injectSpeedInsights({ ...props, framework });\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- route is undefined for barebone vue project\n if (route && configure) {\n const changeRoute = (): void => {\n configure.setRoute(computeRoute(route.path, route.params));\n };\n\n changeRoute();\n watch(route, changeRoute);\n }\n },\n // Vue component must have a render function, or a template.\n render() {\n return null;\n },\n });\n}\n","{\n \"name\": \"@vercel/speed-insights\",\n \"version\": \"1.1.0\",\n \"description\": \"Speed Insights is a tool for measuring web performance and providing suggestions for improvement.\",\n \"keywords\": [\n \"speed-insights\",\n \"vercel\"\n ],\n \"repository\": {\n \"url\": \"github:vercel/speed-insights\",\n \"directory\": \"packages/web\"\n },\n \"license\": \"Apache-2.0\",\n \"exports\": {\n \"./package.json\": \"./package.json\",\n \".\": {\n \"browser\": \"./dist/index.mjs\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\"\n },\n \"./astro\": {\n \"import\": \"./dist/astro/component.ts\"\n },\n \"./next\": {\n \"browser\": \"./dist/next/index.mjs\",\n \"import\": \"./dist/next/index.mjs\",\n \"require\": \"./dist/next/index.js\"\n },\n \"./nuxt\": {\n \"browser\": \"./dist/nuxt/index.mjs\",\n \"import\": \"./dist/nuxt/index.mjs\",\n \"require\": \"./dist/nuxt/index.js\"\n },\n \"./react\": {\n \"browser\": \"./dist/react/index.mjs\",\n \"import\": \"./dist/react/index.mjs\",\n \"require\": \"./dist/react/index.js\"\n },\n \"./remix\": {\n \"browser\": \"./dist/remix/index.mjs\",\n \"import\": \"./dist/remix/index.mjs\",\n \"require\": \"./dist/remix/index.js\"\n },\n \"./sveltekit\": {\n \"svelte\": \"./dist/sveltekit/index.mjs\",\n \"types\": \"./dist/sveltekit/index.d.ts\"\n },\n \"./vue\": {\n \"browser\": \"./dist/vue/index.mjs\",\n \"import\": \"./dist/vue/index.mjs\",\n \"require\": \"./dist/vue/index.js\"\n }\n },\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \"*\": [\n \"dist/index.d.ts\"\n ],\n \"react\": [\n \"dist/react/index.d.ts\"\n ],\n \"next\": [\n \"dist/next/index.d.ts\"\n ],\n \"nuxt\": [\n \"dist/nuxt/index.d.ts\"\n ],\n \"remix\": [\n \"dist/remix/index.d.ts\"\n ],\n \"sveltekit\": [\n \"dist/sveltekit/index.d.ts\"\n ],\n \"vue\": [\n \"dist/vue/index.d.ts\"\n ]\n }\n },\n \"scripts\": {\n \"build\": \"tsup && pnpm copy-astro\",\n \"copy-astro\": \"cp -R src/astro dist/\",\n \"dev\": \"pnpm copy-astro && tsup --watch\",\n \"postinstall\": \"node scripts/postinstall.mjs\",\n \"lint\": \"eslint .\",\n \"lint-fix\": \"eslint . --fix\",\n \"test\": \"jest\",\n \"type-check\": \"tsc --noEmit\"\n },\n \"devDependencies\": {\n \"@jest/globals\": \"^29.7.0\",\n \"@remix-run/react\": \"^2.5.0\",\n \"@sveltejs/kit\": \"^2.7\",\n \"@swc/core\": \"^1.3.103\",\n \"@swc/jest\": \"^0.2.29\",\n \"@testing-library/jest-dom\": \"^6.6.3\",\n \"@testing-library/react\": \"^16.0.1\",\n \"@types/node\": \"^20.11.4\",\n \"@types/react\": \"^18.2.48\",\n \"copyfiles\": \"^2.4.1\",\n \"jest\": \"^29.7.0\",\n \"jest-environment-jsdom\": \"^29.7.0\",\n \"next\": \"^14.0.4\",\n \"react\": \"^18.2.0\",\n \"react-dom\": \"^18.2.0\",\n \"svelte\": \"^5\",\n \"tsup\": \"7.2.0\",\n \"vue\": \"^3.4.14\",\n \"vue-router\": \"^4.2.5\"\n },\n \"peerDependencies\": {\n \"@sveltejs/kit\": \"^1 || ^2\",\n \"next\": \">= 13\",\n \"react\": \"^18 || ^19 || ^19.0.0-rc\",\n \"svelte\": \">= 4\",\n \"vue\": \"^3\",\n \"vue-router\": \"^4\"\n },\n \"peerDependenciesMeta\": {\n \"@sveltejs/kit\": {\n \"optional\": true\n },\n \"next\": {\n \"optional\": true\n },\n \"react\": {\n \"optional\": true\n },\n \"svelte\": {\n \"optional\": true\n },\n \"vue\": {\n \"optional\": true\n },\n \"vue-router\": {\n \"optional\": true\n }\n }\n}\n","export const initQueue = (): void => {\n // initialize va until script is loaded\n if (window.si) return;\n\n window.si = function a(...params): void {\n (window.siq = window.siq || []).push(params);\n };\n};\n","export function isBrowser(): boolean {\n return typeof window !== 'undefined';\n}\n\nfunction detectEnvironment(): 'development' | 'production' {\n try {\n const env = process.env.NODE_ENV;\n if (env === 'development' || env === 'test') {\n return 'development';\n }\n } catch (e) {\n // do nothing, this is okay\n }\n return 'production';\n}\n\nexport function isProduction(): boolean {\n return detectEnvironment() === 'production';\n}\n\nexport function isDevelopment(): boolean {\n return detectEnvironment() === 'development';\n}\n\nexport function computeRoute(\n pathname: string | null,\n pathParams: Record | null,\n): string | null {\n if (!pathname || !pathParams) {\n return pathname;\n }\n\n let result = pathname;\n try {\n const entries = Object.entries(pathParams);\n // simple keys must be handled first\n for (const [key, value] of entries) {\n if (!Array.isArray(value)) {\n const matcher = turnValueToRegExp(value);\n if (matcher.test(result)) {\n result = result.replace(matcher, `/[${key}]`);\n }\n }\n }\n // array values next\n for (const [key, value] of entries) {\n if (Array.isArray(value)) {\n const matcher = turnValueToRegExp(value.join('/'));\n if (matcher.test(result)) {\n result = result.replace(matcher, `/[...${key}]`);\n }\n }\n }\n return result;\n } catch (e) {\n return pathname;\n }\n}\n\nfunction turnValueToRegExp(value: string): RegExp {\n return new RegExp(`/${escapeRegExp(value)}(?=[/?#]|$)`);\n}\n\nfunction escapeRegExp(string: string): string {\n return string.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n","import { name as packageName, version } from '../package.json';\nimport { initQueue } from './queue';\nimport type { SpeedInsightsProps } from './types';\nimport { isBrowser, isDevelopment, computeRoute } from './utils';\n\nconst SCRIPT_URL = 'https://va.vercel-scripts.com/v1/speed-insights';\nconst PROD_SCRIPT_URL = `${SCRIPT_URL}/script.js`;\nconst DEV_SCRIPT_URL = `${SCRIPT_URL}/script.debug.js`;\nconst PROXY_SCRIPT_URL = '/_vercel/speed-insights/script.js';\n\n/**\n * Injects the Vercel Speed Insights script into the page head and starts tracking page views. Read more in our [documentation](https://vercel.com/docs/speed-insights).\n * @param [props] - Speed Insights options.\n * @param [props.debug] - Whether to enable debug logging in development. Defaults to `true`.\n * @param [props.beforeSend] - A middleware function to modify events before they are sent. Should return the event object or `null` to cancel the event.\n * @param [props.sampleRate] - When setting to 0.5, 50% of the events will be sent to Vercel Speed Insights. Defaults to `1`.\n * @param [props.route] - The dynamic route of the page.\n * @param [props.dsn] - The DSN of the project to send events to. Only required when self-hosting.\n */\nfunction injectSpeedInsights(\n props: SpeedInsightsProps & {\n framework?: string;\n } = {},\n): {\n setRoute: (route: string | null) => void;\n} | null {\n // When route is null, it means that pages router is not ready yet. Will resolve soon\n if (!isBrowser() || props.route === null) return null;\n\n initQueue();\n\n const isSelfHosted = Boolean(props.dsn);\n\n const productionScript = isSelfHosted ? PROD_SCRIPT_URL : PROXY_SCRIPT_URL;\n\n const src =\n props.scriptSrc || (isDevelopment() ? DEV_SCRIPT_URL : productionScript);\n\n if (document.head.querySelector(`script[src*=\"${src}\"]`)) return null;\n\n if (props.beforeSend) {\n window.si?.('beforeSend', props.beforeSend);\n }\n\n const script = document.createElement('script');\n script.src = src;\n script.defer = true;\n script.dataset.sdkn =\n packageName + (props.framework ? `/${props.framework}` : '');\n script.dataset.sdkv = version;\n\n if (props.sampleRate) {\n script.dataset.sampleRate = props.sampleRate.toString();\n }\n if (props.route) {\n script.dataset.route = props.route;\n }\n if (props.endpoint) {\n script.dataset.endpoint = props.endpoint;\n }\n if (props.dsn) {\n script.dataset.dsn = props.dsn;\n }\n if (isDevelopment() && props.debug === false) {\n script.dataset.debug = 'false';\n }\n\n script.onerror = (): void => {\n // eslint-disable-next-line no-console -- Logging is okay here\n console.log(\n `[Vercel Speed Insights] Failed to load script from ${src}. Please check if any content blockers are enabled and try again.`,\n );\n };\n\n document.head.appendChild(script);\n\n return {\n setRoute: (route: string | null): void => {\n script.dataset.route = route ?? undefined;\n },\n };\n}\n\nexport { injectSpeedInsights, computeRoute };\nexport type { SpeedInsightsProps };\n\n// eslint-disable-next-line import/no-default-export -- Allow default export\nexport default {\n injectSpeedInsights,\n computeRoute,\n};\n","import { createComponent } from '../vue/create-component';\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- vue's defineComponent return type is any\nexport const SpeedInsights = createComponent('nuxt');\n"],"mappings":";AAAA,SAAS,iBAAiB,aAAa;AAEvC,SAAS,gBAAgB;;;ACDvB,WAAQ;AACR,cAAW;;;ACFN,IAAM,YAAY,MAAY;AAEnC,MAAI,OAAO;AAAI;AAEf,SAAO,KAAK,SAAS,KAAK,QAAc;AACtC,KAAC,OAAO,MAAM,OAAO,OAAO,CAAC,GAAG,KAAK,MAAM;AAAA,EAC7C;AACF;;;ACPO,SAAS,YAAqB;AACnC,SAAO,OAAO,WAAW;AAC3B;AAEA,SAAS,oBAAkD;AACzD,MAAI;AACF,UAAM,MAAM,QAAQ,IAAI;AACxB,QAAI,QAAQ,iBAAiB,QAAQ,QAAQ;AAC3C,aAAO;AAAA,IACT;AAAA,EACF,SAAS,GAAG;AAAA,EAEZ;AACA,SAAO;AACT;AAMO,SAAS,gBAAyB;AACvC,SAAO,kBAAkB,MAAM;AACjC;AAEO,SAAS,aACd,UACA,YACe;AACf,MAAI,CAAC,YA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AAAA,MAC1B;AAAA,IACF;AAAA;AAAA,IAEA,SAAS;AACP,aAAO;AAAA,IACT;AAAA,EACF,CAAC;AACH;;;AKjCO,IAAM,gBAAgB,gBAAgB,MAAM;","names":[]} \ No newline at end of file diff --git a/node_modules/@vercel/speed-insights/dist/react/index.d.mts b/node_modules/@vercel/speed-insights/dist/react/index.d.mts new file mode 100644 index 0000000..c73f52a --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/react/index.d.mts @@ -0,0 +1,41 @@ +interface SpeedInsightsProps { + dsn?: string; + sampleRate?: number; + route?: string | null; + beforeSend?: BeforeSendMiddleware; + debug?: boolean; + scriptSrc?: string; + endpoint?: string; +} +type EventTypes = 'vital'; +interface Event { + type: EventTypes; + url: string; +} +type BeforeSendMiddleware = (data: Event) => Event | null | undefined | false; +interface Functions { + beforeSend?: BeforeSendMiddleware; +} +interface SpeedInsights$1 { + queue: [T, Functions[T]][]; + addAction: (action: T, data: Functions[T]) => void; +} +declare global { + interface Window { + /** Base interface to track events */ + si?: SpeedInsights$1['addAction']; + /** Queue for speed insights datapoints, before the library is loaded */ + siq?: SpeedInsights$1['queue']; + sil?: boolean; + /** used by Astro component only */ + speedInsightsBeforeSend?: BeforeSendMiddleware; + } +} + +declare function computeRoute(pathname: string | null, pathParams: Record | null): string | null; + +declare function SpeedInsights(props: SpeedInsightsProps & { + framework?: string; +}): JSX.Element | null; + +export { SpeedInsights, computeRoute }; diff --git a/node_modules/@vercel/speed-insights/dist/react/index.d.ts b/node_modules/@vercel/speed-insights/dist/react/index.d.ts new file mode 100644 index 0000000..c73f52a --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/react/index.d.ts @@ -0,0 +1,41 @@ +interface SpeedInsightsProps { + dsn?: string; + sampleRate?: number; + route?: string | null; + beforeSend?: BeforeSendMiddleware; + debug?: boolean; + scriptSrc?: string; + endpoint?: string; +} +type EventTypes = 'vital'; +interface Event { + type: EventTypes; + url: string; +} +type BeforeSendMiddleware = (data: Event) => Event | null | undefined | false; +interface Functions { + beforeSend?: BeforeSendMiddleware; +} +interface SpeedInsights$1 { + queue: [T, Functions[T]][]; + addAction: (action: T, data: Functions[T]) => void; +} +declare global { + interface Window { + /** Base interface to track events */ + si?: SpeedInsights$1['addAction']; + /** Queue for speed insights datapoints, before the library is loaded */ + siq?: SpeedInsights$1['queue']; + sil?: boolean; + /** used by Astro component only */ + speedInsightsBeforeSend?: BeforeSendMiddleware; + } +} + +declare function computeRoute(pathname: string | null, pathParams: Record | null): string | null; + +declare function SpeedInsights(props: SpeedInsightsProps & { + framework?: string; +}): JSX.Element | null; + +export { SpeedInsights, computeRoute }; diff --git a/node_modules/@vercel/speed-insights/dist/react/index.js b/node_modules/@vercel/speed-insights/dist/react/index.js new file mode 100644 index 0000000..ab93df2 --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/react/index.js @@ -0,0 +1,175 @@ +"use strict"; +"use client"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __export = (target, all) => { + for (var name2 in all) + __defProp(target, name2, { get: all[name2], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/react/index.tsx +var react_exports = {}; +__export(react_exports, { + SpeedInsights: () => SpeedInsights, + computeRoute: () => computeRoute +}); +module.exports = __toCommonJS(react_exports); +var import_react = require("react"); + +// package.json +var name = "@vercel/speed-insights"; +var version = "1.1.0"; + +// src/queue.ts +var initQueue = () => { + if (window.si) + return; + window.si = function a(...params) { + (window.siq = window.siq || []).push(params); + }; +}; + +// src/utils.ts +function isBrowser() { + return typeof window !== "undefined"; +} +function detectEnvironment() { + try { + const env = process.env.NODE_ENV; + if (env === "development" || env === "test") { + return "development"; + } + } catch (e) { + } + return "production"; +} +function isDevelopment() { + return detectEnvironment() === "development"; +} +function computeRoute(pathname, pathParams) { + if (!pathname || !pathParams) { + return pathname; + } + let result = pathname; + try { + const entries = Object.entries(pathParams); + for (const [key, value] of entries) { + if (!Array.isArray(value)) { + const matcher = turnValueToRegExp(value); + if (matcher.test(result)) { + result = result.replace(matcher, `/[${key}]`); + } + } + } + for (const [key, value] of entries) { + if (Array.isArray(value)) { + const matcher = turnValueToRegExp(value.join("/")); + if (matcher.test(result)) { + result = result.replace(matcher, `/[...${key}]`); + } + } + } + return result; + } catch (e) { + return pathname; + } +} +function turnValueToRegExp(value) { + return new RegExp(`/${escapeRegExp(value)}(?=[/?#]|$)`); +} +function escapeRegExp(string) { + return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); +} + +// src/generic.ts +var SCRIPT_URL = "https://va.vercel-scripts.com/v1/speed-insights"; +var PROD_SCRIPT_URL = `${SCRIPT_URL}/script.js`; +var DEV_SCRIPT_URL = `${SCRIPT_URL}/script.debug.js`; +var PROXY_SCRIPT_URL = "/_vercel/speed-insights/script.js"; +function injectSpeedInsights(props = {}) { + var _a; + if (!isBrowser() || props.route === null) + return null; + initQueue(); + const isSelfHosted = Boolean(props.dsn); + const productionScript = isSelfHosted ? PROD_SCRIPT_URL : PROXY_SCRIPT_URL; + const src = props.scriptSrc || (isDevelopment() ? DEV_SCRIPT_URL : productionScript); + if (document.head.querySelector(`script[src*="${src}"]`)) + return null; + if (props.beforeSend) { + (_a = window.si) == null ? void 0 : _a.call(window, "beforeSend", props.beforeSend); + } + const script = document.createElement("script"); + script.src = src; + script.defer = true; + script.dataset.sdkn = name + (props.framework ? `/${props.framework}` : ""); + script.dataset.sdkv = version; + if (props.sampleRate) { + script.dataset.sampleRate = props.sampleRate.toString(); + } + if (props.route) { + script.dataset.route = props.route; + } + if (props.endpoint) { + script.dataset.endpoint = props.endpoint; + } + if (props.dsn) { + script.dataset.dsn = props.dsn; + } + if (isDevelopment() && props.debug === false) { + script.dataset.debug = "false"; + } + script.onerror = () => { + console.log( + `[Vercel Speed Insights] Failed to load script from ${src}. Please check if any content blockers are enabled and try again.` + ); + }; + document.head.appendChild(script); + return { + setRoute: (route) => { + script.dataset.route = route ?? void 0; + } + }; +} + +// src/react/index.tsx +function SpeedInsights(props) { + (0, import_react.useEffect)(() => { + var _a; + if (props.beforeSend) { + (_a = window.si) == null ? void 0 : _a.call(window, "beforeSend", props.beforeSend); + } + }, [props.beforeSend]); + const setScriptRoute = (0, import_react.useRef)(null); + (0, import_react.useEffect)(() => { + if (!setScriptRoute.current) { + const script = injectSpeedInsights({ + framework: props.framework || "react", + ...props + }); + if (script) { + setScriptRoute.current = script.setRoute; + } + } else if (props.route) { + setScriptRoute.current(props.route); + } + }, [props.route]); + return null; +} +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + SpeedInsights, + computeRoute +}); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/node_modules/@vercel/speed-insights/dist/react/index.js.map b/node_modules/@vercel/speed-insights/dist/react/index.js.map new file mode 100644 index 0000000..126c9b1 --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/react/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/react/index.tsx","../../package.json","../../src/queue.ts","../../src/utils.ts","../../src/generic.ts"],"sourcesContent":["'use client';\nimport { useEffect, useRef } from 'react';\nimport type { SpeedInsightsProps } from '../types';\nimport { computeRoute, injectSpeedInsights } from '../generic';\n\nexport function SpeedInsights(\n props: SpeedInsightsProps & {\n framework?: string;\n },\n): JSX.Element | null {\n useEffect(() => {\n if (props.beforeSend) {\n window.si?.('beforeSend', props.beforeSend);\n }\n }, [props.beforeSend]);\n\n const setScriptRoute = useRef<((path: string) => void) | null>(null);\n useEffect(() => {\n if (!setScriptRoute.current) {\n const script = injectSpeedInsights({\n framework: props.framework || 'react',\n ...props,\n });\n if (script) {\n setScriptRoute.current = script.setRoute;\n }\n } else if (props.route) {\n setScriptRoute.current(props.route);\n }\n }, [props.route]);\n\n return null;\n}\n\nexport { computeRoute };\n","{\n \"name\": \"@vercel/speed-insights\",\n \"version\": \"1.1.0\",\n \"description\": \"Speed Insights is a tool for measuring web performance and providing suggestions for improvement.\",\n \"keywords\": [\n \"speed-insights\",\n \"vercel\"\n ],\n \"repository\": {\n \"url\": \"github:vercel/speed-insights\",\n \"directory\": \"packages/web\"\n },\n \"license\": \"Apache-2.0\",\n \"exports\": {\n \"./package.json\": \"./package.json\",\n \".\": {\n \"browser\": \"./dist/index.mjs\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\"\n },\n \"./astro\": {\n \"import\": \"./dist/astro/component.ts\"\n },\n \"./next\": {\n \"browser\": \"./dist/next/index.mjs\",\n \"import\": \"./dist/next/index.mjs\",\n \"require\": \"./dist/next/index.js\"\n },\n \"./nuxt\": {\n \"browser\": \"./dist/nuxt/index.mjs\",\n \"import\": \"./dist/nuxt/index.mjs\",\n \"require\": \"./dist/nuxt/index.js\"\n },\n \"./react\": {\n \"browser\": \"./dist/react/index.mjs\",\n \"import\": \"./dist/react/index.mjs\",\n \"require\": \"./dist/react/index.js\"\n },\n \"./remix\": {\n \"browser\": \"./dist/remix/index.mjs\",\n \"import\": \"./dist/remix/index.mjs\",\n \"require\": \"./dist/remix/index.js\"\n },\n \"./sveltekit\": {\n \"svelte\": \"./dist/sveltekit/index.mjs\",\n \"types\": \"./dist/sveltekit/index.d.ts\"\n },\n \"./vue\": {\n \"browser\": \"./dist/vue/index.mjs\",\n \"import\": \"./dist/vue/index.mjs\",\n \"require\": \"./dist/vue/index.js\"\n }\n },\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \"*\": [\n \"dist/index.d.ts\"\n ],\n \"react\": [\n \"dist/react/index.d.ts\"\n ],\n \"next\": [\n \"dist/next/index.d.ts\"\n ],\n \"nuxt\": [\n \"dist/nuxt/index.d.ts\"\n ],\n \"remix\": [\n \"dist/remix/index.d.ts\"\n ],\n \"sveltekit\": [\n \"dist/sveltekit/index.d.ts\"\n ],\n \"vue\": [\n \"dist/vue/index.d.ts\"\n ]\n }\n },\n \"scripts\": {\n \"build\": \"tsup && pnpm copy-astro\",\n \"copy-astro\": \"cp -R src/astro dist/\",\n \"dev\": \"pnpm copy-astro && tsup --watch\",\n \"postinstall\": \"node scripts/postinstall.mjs\",\n \"lint\": \"eslint .\",\n \"lint-fix\": \"eslint . --fix\",\n \"test\": \"jest\",\n \"type-check\": \"tsc --noEmit\"\n },\n \"devDependencies\": {\n \"@jest/globals\": \"^29.7.0\",\n \"@remix-run/react\": \"^2.5.0\",\n \"@sveltejs/kit\": \"^2.7\",\n \"@swc/core\": \"^1.3.103\",\n \"@swc/jest\": \"^0.2.29\",\n \"@testing-library/jest-dom\": \"^6.6.3\",\n \"@testing-library/react\": \"^16.0.1\",\n \"@types/node\": \"^20.11.4\",\n \"@types/react\": \"^18.2.48\",\n \"copyfiles\": \"^2.4.1\",\n \"jest\": \"^29.7.0\",\n \"jest-environment-jsdom\": \"^29.7.0\",\n \"next\": \"^14.0.4\",\n \"react\": \"^18.2.0\",\n \"react-dom\": \"^18.2.0\",\n \"svelte\": \"^5\",\n \"tsup\": \"7.2.0\",\n \"vue\": \"^3.4.14\",\n \"vue-router\": \"^4.2.5\"\n },\n \"peerDependencies\": {\n \"@sveltejs/kit\": \"^1 || ^2\",\n \"next\": \">= 13\",\n \"react\": \"^18 || ^19 || ^19.0.0-rc\",\n \"svelte\": \">= 4\",\n \"vue\": \"^3\",\n \"vue-router\": \"^4\"\n },\n \"peerDependenciesMeta\": {\n \"@sveltejs/kit\": {\n \"optional\": true\n },\n \"next\": {\n \"optional\": true\n },\n \"react\": {\n \"optional\": true\n },\n \"svelte\": {\n \"optional\": true\n },\n \"vue\": {\n \"optional\": true\n },\n \"vue-router\": {\n \"optional\": true\n }\n }\n}\n","export const initQueue = (): void => {\n // initialize va until script is loaded\n if (window.si) return;\n\n window.si = function a(...params): void {\n (window.siq = window.siq || []).push(params);\n };\n};\n","export function isBrowser(): boolean {\n return typeof window !== 'undefined';\n}\n\nfunction detectEnvironment(): 'development' | 'production' {\n try {\n const env = process.env.NODE_ENV;\n if (env === 'development' || env === 'test') {\n return 'development';\n }\n } catch (e) {\n // do nothing, this is okay\n }\n return 'production';\n}\n\nexport function isProduction(): boolean {\n return detectEnvironment() === 'production';\n}\n\nexport function isDevelopment(): boolean {\n return detectEnvironment() === 'development';\n}\n\nexport function computeRoute(\n pathname: string | null,\n pathParams: Record | null,\n): string | null {\n if (!pathname || !pathParams) {\n return pathname;\n }\n\n let result = pathname;\n try {\n const entries = Object.entries(pathParams);\n // simple keys must be handled first\n for (const [key, value] of entries) {\n if (!Array.isArray(value)) {\n const matcher = turnValueToRegExp(value);\n if (matcher.test(result)) {\n result = result.replace(matcher, `/[${key}]`);\n }\n }\n }\n // array values next\n for (const [key, value] of entries) {\n if (Array.isArray(value)) {\n const matcher = turnValueToRegExp(value.join('/'));\n if (matcher.test(result)) {\n result = result.replace(matcher, `/[...${key}]`);\n }\n }\n }\n return result;\n } catch (e) {\n return pathname;\n }\n}\n\nfunction turnValueToRegExp(value: string): RegExp {\n return new RegExp(`/${escapeRegExp(value)}(?=[/?#]|$)`);\n}\n\nfunction escapeRegExp(string: string): string {\n return string.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n","import { name as packageName, version } from '../package.json';\nimport { initQueue } from './queue';\nimport type { SpeedInsightsProps } from './types';\nimport { isBrowser, isDevelopment, computeRoute } from './utils';\n\nconst SCRIPT_URL = 'https://va.vercel-scripts.com/v1/speed-insights';\nconst PROD_SCRIPT_URL = `${SCRIPT_URL}/script.js`;\nconst DEV_SCRIPT_URL = `${SCRIPT_URL}/script.debug.js`;\nconst PROXY_SCRIPT_URL = '/_vercel/speed-insights/script.js';\n\n/**\n * Injects the Vercel Speed Insights script into the page head and starts tracking page views. Read more in our [documentation](https://vercel.com/docs/speed-insights).\n * @param [props] - Speed Insights options.\n * @param [props.debug] - Whether to enable debug logging in development. Defaults to `true`.\n * @param [props.beforeSend] - A middleware function to modify events before they are sent. Should return the event object or `null` to cancel the event.\n * @param [props.sampleRate] - When setting to 0.5, 50% of the events will be sent to Vercel Speed Insights. Defaults to `1`.\n * @param [props.route] - The dynamic route of the page.\n * @param [props.dsn] - The DSN of the project to send events to. Only required when self-hosting.\n */\nfunction injectSpeedInsights(\n props: SpeedInsightsProps & {\n framework?: string;\n } = {},\n): {\n setRoute: (route: string | null) => void;\n} | null {\n // When route is null, it means that pages router is not ready yet. Will resolve soon\n if (!isBrowser() || props.route === null) return null;\n\n initQueue();\n\n const isSelfHosted = Boolean(props.dsn);\n\n const productionScript = isSelfHosted ? PROD_SCRIPT_URL : PROXY_SCRIPT_URL;\n\n const src =\n props.scriptSrc || (isDevelopment() ? DEV_SCRIPT_URL : productionScript);\n\n if (document.head.querySelector(`script[src*=\"${src}\"]`)) return null;\n\n if (props.beforeSend) {\n window.si?.('beforeSend', props.beforeSend);\n }\n\n const script = document.createElement('script');\n script.src = src;\n script.defer = true;\n script.dataset.sdkn =\n packageName + (props.framework ? `/${props.framework}` : '');\n script.dataset.sdkv = version;\n\n if (props.sampleRate) {\n script.dataset.sampleRate = props.sampleRate.toString();\n }\n if (props.route) {\n script.dataset.route = props.route;\n }\n if (props.endpoint) {\n script.dataset.endpoint = props.endpoint;\n }\n if (props.dsn) {\n script.dataset.dsn = props.dsn;\n }\n if (isDevelopment() && props.debug === false) {\n script.dataset.debug = 'false';\n }\n\n script.onerror = (): void => {\n // eslint-disable-next-line no-console -- Logging is okay here\n console.log(\n `[Vercel Speed Insights] Failed to load script from ${src}. Please check if any content blockers are enabled and try again.`,\n );\n };\n\n document.head.appendChild(script);\n\n return {\n setRoute: (route: string | null): void => {\n script.dataset.route = route ?? undefined;\n },\n };\n}\n\nexport { injectSpeedInsights, computeRoute };\nexport type { SpeedInsightsProps };\n\n// eslint-disable-next-line import/no-default-export -- Allow default export\nexport default {\n injectSpeedInsights,\n computeRoute,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkC;;;ACAhC,WAAQ;AACR,cAAW;;;ACFN,IAAM,YAAY,MAAY;AAEnC,MAAI,OAAO;AAAI;AAEf,SAAO,KAAK,SAAS,KAAK,QAAc;AACtC,KAAC,OAAO,MAAM,OAAO,OAAO,CAAC,GAAG,KAAK,MAAM;AAAA,EAC7C;AACF;;;ACPO,SAAS,YAAqB;AACnC,SAAO,OAAO,WAAW;AAC3B;AAEA,SAAS,oBAAkD;AACzD,MAAI;AACF,UAAM,MAAM,QAAQ,IAAI;AACxB,QAAI,QAAQ,iBAAiB,QAAQ,QAAQ;AAC3C,aAAO;AAAA,IACT;AAAA,EACF,SAAS,GAAG;AAAA,EAEZ;AACA,SAAO;AACT;AAMO,SAAS,gBAAyB;AACvC,SAAO,kBAAkB,MAAM;AACjC;AAEO,SAAS,aACd,UACA,YACe;AACf,MAAI,CAAC,YAAY,CAAC,YAAY;AAC5B,WAAO;AAAA,EACT;AAEA,MAAI,SAAS;AACb,MAAI;AACF,UAAM,UAAU,OAAO,QAAQ,UAAU;AAEzC,eAAW,CAAC,KAAK,KAAK,KAAK,SAAS;AAClC,UAAI,CAAC,MAAM,QAAQ,KAAK,GAAG;AACzB,cAAM,UAAU,kBAAkB,KAAK;AACvC,YAAI,QAAQ,KAAK,MAAM,GAAG;AACxB,mBAAS,OAAO,QAAQ,SAAS,KAAK,GAAG,GAAG;AAAA,QAC9C;AAAA,MACF;AAAA,IACF;AAEA,eAAW,CAAC,KAAK,KAAK,KAAK,SAAS;AAClC,UAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,cAAM,UAAU,kBAAkB,MAAM,KAAK,GAAG,CAAC;AACjD,YAAI,QAAQ,KAA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MAAM;AAAA,EAC7B;AACA,MAAI,cAAc,KAAK,MAAM,UAAU,OAAO;AAC5C,WAAO,QAAQ,QAAQ;AAAA,EACzB;AAEA,SAAO,UAAU,MAAY;AAE3B,YAAQ;AAAA,MACN,sDAAsD,GAAG;AAAA,IAC3D;AAAA,EACF;AAEA,WAAS,KAAK,YAAY,MAAM;AAEhC,SAAO;AAAA,IACL,UAAU,CAAC,UAA+B;AACxC,aAAO,QAAQ,QAAQ,SAAS;AAAA,IAClC;AAAA,EACF;AACF;;;AJ5EO,SAAS,cACd,OAGoB;AACpB,8BAAU,MAAM;AAVlB;AAWI,QAAI,MAAM,YAAY;AACpB,mBAAO,OAAP,gCAAY,cAAc,MAAM;AAAA,IAClC;AAAA,EACF,GAAG,CAAC,MAAM,UAAU,CAAC;AAErB,QAAM,qBAAiB,qBAAwC,IAAI;AACnE,8BAAU,MAAM;AACd,QAAI,CAAC,eAAe,SAAS;AAC3B,YAAM,SAAS,oBAAoB;AAAA,QACjC,WAAW,MAAM,aAAa;AAAA,QAC9B,GAAG;AAAA,MACL,CAAC;AACD,UAAI,QAAQ;AACV,uBAAe,UAAU,OAAO;AAAA,MAClC;AAAA,IACF,WAAW,MAAM,OAAO;AACtB,qBAAe,QAAQ,MAAM,KAAK;AAAA,IACpC;AAAA,EACF,GAAG,CAAC,MAAM,KAAK,CAAC;AAEhB,SAAO;AACT;","names":[]} \ No newline at end of file diff --git a/node_modules/@vercel/speed-insights/dist/react/index.mjs b/node_modules/@vercel/speed-insights/dist/react/index.mjs new file mode 100644 index 0000000..bc96f29 --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/react/index.mjs @@ -0,0 +1,150 @@ +"use client"; + +// src/react/index.tsx +import { useEffect, useRef } from "react"; + +// package.json +var name = "@vercel/speed-insights"; +var version = "1.1.0"; + +// src/queue.ts +var initQueue = () => { + if (window.si) + return; + window.si = function a(...params) { + (window.siq = window.siq || []).push(params); + }; +}; + +// src/utils.ts +function isBrowser() { + return typeof window !== "undefined"; +} +function detectEnvironment() { + try { + const env = process.env.NODE_ENV; + if (env === "development" || env === "test") { + return "development"; + } + } catch (e) { + } + return "production"; +} +function isDevelopment() { + return detectEnvironment() === "development"; +} +function computeRoute(pathname, pathParams) { + if (!pathname || !pathParams) { + return pathname; + } + let result = pathname; + try { + const entries = Object.entries(pathParams); + for (const [key, value] of entries) { + if (!Array.isArray(value)) { + const matcher = turnValueToRegExp(value); + if (matcher.test(result)) { + result = result.replace(matcher, `/[${key}]`); + } + } + } + for (const [key, value] of entries) { + if (Array.isArray(value)) { + const matcher = turnValueToRegExp(value.join("/")); + if (matcher.test(result)) { + result = result.replace(matcher, `/[...${key}]`); + } + } + } + return result; + } catch (e) { + return pathname; + } +} +function turnValueToRegExp(value) { + return new RegExp(`/${escapeRegExp(value)}(?=[/?#]|$)`); +} +function escapeRegExp(string) { + return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); +} + +// src/generic.ts +var SCRIPT_URL = "https://va.vercel-scripts.com/v1/speed-insights"; +var PROD_SCRIPT_URL = `${SCRIPT_URL}/script.js`; +var DEV_SCRIPT_URL = `${SCRIPT_URL}/script.debug.js`; +var PROXY_SCRIPT_URL = "/_vercel/speed-insights/script.js"; +function injectSpeedInsights(props = {}) { + var _a; + if (!isBrowser() || props.route === null) + return null; + initQueue(); + const isSelfHosted = Boolean(props.dsn); + const productionScript = isSelfHosted ? PROD_SCRIPT_URL : PROXY_SCRIPT_URL; + const src = props.scriptSrc || (isDevelopment() ? DEV_SCRIPT_URL : productionScript); + if (document.head.querySelector(`script[src*="${src}"]`)) + return null; + if (props.beforeSend) { + (_a = window.si) == null ? void 0 : _a.call(window, "beforeSend", props.beforeSend); + } + const script = document.createElement("script"); + script.src = src; + script.defer = true; + script.dataset.sdkn = name + (props.framework ? `/${props.framework}` : ""); + script.dataset.sdkv = version; + if (props.sampleRate) { + script.dataset.sampleRate = props.sampleRate.toString(); + } + if (props.route) { + script.dataset.route = props.route; + } + if (props.endpoint) { + script.dataset.endpoint = props.endpoint; + } + if (props.dsn) { + script.dataset.dsn = props.dsn; + } + if (isDevelopment() && props.debug === false) { + script.dataset.debug = "false"; + } + script.onerror = () => { + console.log( + `[Vercel Speed Insights] Failed to load script from ${src}. Please check if any content blockers are enabled and try again.` + ); + }; + document.head.appendChild(script); + return { + setRoute: (route) => { + script.dataset.route = route ?? void 0; + } + }; +} + +// src/react/index.tsx +function SpeedInsights(props) { + useEffect(() => { + var _a; + if (props.beforeSend) { + (_a = window.si) == null ? void 0 : _a.call(window, "beforeSend", props.beforeSend); + } + }, [props.beforeSend]); + const setScriptRoute = useRef(null); + useEffect(() => { + if (!setScriptRoute.current) { + const script = injectSpeedInsights({ + framework: props.framework || "react", + ...props + }); + if (script) { + setScriptRoute.current = script.setRoute; + } + } else if (props.route) { + setScriptRoute.current(props.route); + } + }, [props.route]); + return null; +} +export { + SpeedInsights, + computeRoute +}; +//# sourceMappingURL=index.mjs.map \ No newline at end of file diff --git a/node_modules/@vercel/speed-insights/dist/react/index.mjs.map b/node_modules/@vercel/speed-insights/dist/react/index.mjs.map new file mode 100644 index 0000000..8fc9830 --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/react/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/react/index.tsx","../../package.json","../../src/queue.ts","../../src/utils.ts","../../src/generic.ts"],"sourcesContent":["'use client';\nimport { useEffect, useRef } from 'react';\nimport type { SpeedInsightsProps } from '../types';\nimport { computeRoute, injectSpeedInsights } from '../generic';\n\nexport function SpeedInsights(\n props: SpeedInsightsProps & {\n framework?: string;\n },\n): JSX.Element | null {\n useEffect(() => {\n if (props.beforeSend) {\n window.si?.('beforeSend', props.beforeSend);\n }\n }, [props.beforeSend]);\n\n const setScriptRoute = useRef<((path: string) => void) | null>(null);\n useEffect(() => {\n if (!setScriptRoute.current) {\n const script = injectSpeedInsights({\n framework: props.framework || 'react',\n ...props,\n });\n if (script) {\n setScriptRoute.current = script.setRoute;\n }\n } else if (props.route) {\n setScriptRoute.current(props.route);\n }\n }, [props.route]);\n\n return null;\n}\n\nexport { computeRoute };\n","{\n \"name\": \"@vercel/speed-insights\",\n \"version\": \"1.1.0\",\n \"description\": \"Speed Insights is a tool for measuring web performance and providing suggestions for improvement.\",\n \"keywords\": [\n \"speed-insights\",\n \"vercel\"\n ],\n \"repository\": {\n \"url\": \"github:vercel/speed-insights\",\n \"directory\": \"packages/web\"\n },\n \"license\": \"Apache-2.0\",\n \"exports\": {\n \"./package.json\": \"./package.json\",\n \".\": {\n \"browser\": \"./dist/index.mjs\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\"\n },\n \"./astro\": {\n \"import\": \"./dist/astro/component.ts\"\n },\n \"./next\": {\n \"browser\": \"./dist/next/index.mjs\",\n \"import\": \"./dist/next/index.mjs\",\n \"require\": \"./dist/next/index.js\"\n },\n \"./nuxt\": {\n \"browser\": \"./dist/nuxt/index.mjs\",\n \"import\": \"./dist/nuxt/index.mjs\",\n \"require\": \"./dist/nuxt/index.js\"\n },\n \"./react\": {\n \"browser\": \"./dist/react/index.mjs\",\n \"import\": \"./dist/react/index.mjs\",\n \"require\": \"./dist/react/index.js\"\n },\n \"./remix\": {\n \"browser\": \"./dist/remix/index.mjs\",\n \"import\": \"./dist/remix/index.mjs\",\n \"require\": \"./dist/remix/index.js\"\n },\n \"./sveltekit\": {\n \"svelte\": \"./dist/sveltekit/index.mjs\",\n \"types\": \"./dist/sveltekit/index.d.ts\"\n },\n \"./vue\": {\n \"browser\": \"./dist/vue/index.mjs\",\n \"import\": \"./dist/vue/index.mjs\",\n \"require\": \"./dist/vue/index.js\"\n }\n },\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \"*\": [\n \"dist/index.d.ts\"\n ],\n \"react\": [\n \"dist/react/index.d.ts\"\n ],\n \"next\": [\n \"dist/next/index.d.ts\"\n ],\n \"nuxt\": [\n \"dist/nuxt/index.d.ts\"\n ],\n \"remix\": [\n \"dist/remix/index.d.ts\"\n ],\n \"sveltekit\": [\n \"dist/sveltekit/index.d.ts\"\n ],\n \"vue\": [\n \"dist/vue/index.d.ts\"\n ]\n }\n },\n \"scripts\": {\n \"build\": \"tsup && pnpm copy-astro\",\n \"copy-astro\": \"cp -R src/astro dist/\",\n \"dev\": \"pnpm copy-astro && tsup --watch\",\n \"postinstall\": \"node scripts/postinstall.mjs\",\n \"lint\": \"eslint .\",\n \"lint-fix\": \"eslint . --fix\",\n \"test\": \"jest\",\n \"type-check\": \"tsc --noEmit\"\n },\n \"devDependencies\": {\n \"@jest/globals\": \"^29.7.0\",\n \"@remix-run/react\": \"^2.5.0\",\n \"@sveltejs/kit\": \"^2.7\",\n \"@swc/core\": \"^1.3.103\",\n \"@swc/jest\": \"^0.2.29\",\n \"@testing-library/jest-dom\": \"^6.6.3\",\n \"@testing-library/react\": \"^16.0.1\",\n \"@types/node\": \"^20.11.4\",\n \"@types/react\": \"^18.2.48\",\n \"copyfiles\": \"^2.4.1\",\n \"jest\": \"^29.7.0\",\n \"jest-environment-jsdom\": \"^29.7.0\",\n \"next\": \"^14.0.4\",\n \"react\": \"^18.2.0\",\n \"react-dom\": \"^18.2.0\",\n \"svelte\": \"^5\",\n \"tsup\": \"7.2.0\",\n \"vue\": \"^3.4.14\",\n \"vue-router\": \"^4.2.5\"\n },\n \"peerDependencies\": {\n \"@sveltejs/kit\": \"^1 || ^2\",\n \"next\": \">= 13\",\n \"react\": \"^18 || ^19 || ^19.0.0-rc\",\n \"svelte\": \">= 4\",\n \"vue\": \"^3\",\n \"vue-router\": \"^4\"\n },\n \"peerDependenciesMeta\": {\n \"@sveltejs/kit\": {\n \"optional\": true\n },\n \"next\": {\n \"optional\": true\n },\n \"react\": {\n \"optional\": true\n },\n \"svelte\": {\n \"optional\": true\n },\n \"vue\": {\n \"optional\": true\n },\n \"vue-router\": {\n \"optional\": true\n }\n }\n}\n","export const initQueue = (): void => {\n // initialize va until script is loaded\n if (window.si) return;\n\n window.si = function a(...params): void {\n (window.siq = window.siq || []).push(params);\n };\n};\n","export function isBrowser(): boolean {\n return typeof window !== 'undefined';\n}\n\nfunction detectEnvironment(): 'development' | 'production' {\n try {\n const env = process.env.NODE_ENV;\n if (env === 'development' || env === 'test') {\n return 'development';\n }\n } catch (e) {\n // do nothing, this is okay\n }\n return 'production';\n}\n\nexport function isProduction(): boolean {\n return detectEnvironment() === 'production';\n}\n\nexport function isDevelopment(): boolean {\n return detectEnvironment() === 'development';\n}\n\nexport function computeRoute(\n pathname: string | null,\n pathParams: Record | null,\n): string | null {\n if (!pathname || !pathParams) {\n return pathname;\n }\n\n let result = pathname;\n try {\n const entries = Object.entries(pathParams);\n // simple keys must be handled first\n for (const [key, value] of entries) {\n if (!Array.isArray(value)) {\n const matcher = turnValueToRegExp(value);\n if (matcher.test(result)) {\n result = result.replace(matcher, `/[${key}]`);\n }\n }\n }\n // array values next\n for (const [key, value] of entries) {\n if (Array.isArray(value)) {\n const matcher = turnValueToRegExp(value.join('/'));\n if (matcher.test(result)) {\n result = result.replace(matcher, `/[...${key}]`);\n }\n }\n }\n return result;\n } catch (e) {\n return pathname;\n }\n}\n\nfunction turnValueToRegExp(value: string): RegExp {\n return new RegExp(`/${escapeRegExp(value)}(?=[/?#]|$)`);\n}\n\nfunction escapeRegExp(string: string): string {\n return string.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n","import { name as packageName, version } from '../package.json';\nimport { initQueue } from './queue';\nimport type { SpeedInsightsProps } from './types';\nimport { isBrowser, isDevelopment, computeRoute } from './utils';\n\nconst SCRIPT_URL = 'https://va.vercel-scripts.com/v1/speed-insights';\nconst PROD_SCRIPT_URL = `${SCRIPT_URL}/script.js`;\nconst DEV_SCRIPT_URL = `${SCRIPT_URL}/script.debug.js`;\nconst PROXY_SCRIPT_URL = '/_vercel/speed-insights/script.js';\n\n/**\n * Injects the Vercel Speed Insights script into the page head and starts tracking page views. Read more in our [documentation](https://vercel.com/docs/speed-insights).\n * @param [props] - Speed Insights options.\n * @param [props.debug] - Whether to enable debug logging in development. Defaults to `true`.\n * @param [props.beforeSend] - A middleware function to modify events before they are sent. Should return the event object or `null` to cancel the event.\n * @param [props.sampleRate] - When setting to 0.5, 50% of the events will be sent to Vercel Speed Insights. Defaults to `1`.\n * @param [props.route] - The dynamic route of the page.\n * @param [props.dsn] - The DSN of the project to send events to. Only required when self-hosting.\n */\nfunction injectSpeedInsights(\n props: SpeedInsightsProps & {\n framework?: string;\n } = {},\n): {\n setRoute: (route: string | null) => void;\n} | null {\n // When route is null, it means that pages router is not ready yet. Will resolve soon\n if (!isBrowser() || props.route === null) return null;\n\n initQueue();\n\n const isSelfHosted = Boolean(props.dsn);\n\n const productionScript = isSelfHosted ? PROD_SCRIPT_URL : PROXY_SCRIPT_URL;\n\n const src =\n props.scriptSrc || (isDevelopment() ? DEV_SCRIPT_URL : productionScript);\n\n if (document.head.querySelector(`script[src*=\"${src}\"]`)) return null;\n\n if (props.beforeSend) {\n window.si?.('beforeSend', props.beforeSend);\n }\n\n const script = document.createElement('script');\n script.src = src;\n script.defer = true;\n script.dataset.sdkn =\n packageName + (props.framework ? `/${props.framework}` : '');\n script.dataset.sdkv = version;\n\n if (props.sampleRate) {\n script.dataset.sampleRate = props.sampleRate.toString();\n }\n if (props.route) {\n script.dataset.route = props.route;\n }\n if (props.endpoint) {\n script.dataset.endpoint = props.endpoint;\n }\n if (props.dsn) {\n script.dataset.dsn = props.dsn;\n }\n if (isDevelopment() && props.debug === false) {\n script.dataset.debug = 'false';\n }\n\n script.onerror = (): void => {\n // eslint-disable-next-line no-console -- Logging is okay here\n console.log(\n `[Vercel Speed Insights] Failed to load script from ${src}. Please check if any content blockers are enabled and try again.`,\n );\n };\n\n document.head.appendChild(script);\n\n return {\n setRoute: (route: string | null): void => {\n script.dataset.route = route ?? undefined;\n },\n };\n}\n\nexport { injectSpeedInsights, computeRoute };\nexport type { SpeedInsightsProps };\n\n// eslint-disable-next-line import/no-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;AAE3B,YAAQ;AAAA,MACN,sDAAsD,GAAG;AAAA,IAC3D;AAAA,EACF;AAEA,WAAS,KAAK,YAAY,MAAM;AAEhC,SAAO;AAAA,IACL,UAAU,CAAC,UAA+B;AACxC,aAAO,QAAQ,QAAQ,SAAS;AAAA,IAClC;AAAA,EACF;AACF;;;AJ5EO,SAAS,cACd,OAGoB;AACpB,YAAU,MAAM;AAVlB;AAWI,QAAI,MAAM,YAAY;AACpB,mBAAO,OAAP,gCAAY,cAAc,MAAM;AAAA,IAClC;AAAA,EACF,GAAG,CAAC,MAAM,UAAU,CAAC;AAErB,QAAM,iBAAiB,OAAwC,IAAI;AACnE,YAAU,MAAM;AACd,QAAI,CAAC,eAAe,SAAS;AAC3B,YAAM,SAAS,oBAAoB;AAAA,QACjC,WAAW,MAAM,aAAa;AAAA,QAC9B,GAAG;AAAA,MACL,CAAC;AACD,UAAI,QAAQ;AACV,uBAAe,UAAU,OAAO;AAAA,MAClC;AAAA,IACF,WAAW,MAAM,OAAO;AACtB,qBAAe,QAAQ,MAAM,KAAK;AAAA,IACpC;AAAA,EACF,GAAG,CAAC,MAAM,KAAK,CAAC;AAEhB,SAAO;AACT;","names":[]} \ No newline at end of file diff --git a/node_modules/@vercel/speed-insights/dist/remix/index.d.mts b/node_modules/@vercel/speed-insights/dist/remix/index.d.mts new file mode 100644 index 0000000..57837a1 --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/remix/index.d.mts @@ -0,0 +1,37 @@ +interface SpeedInsightsProps { + dsn?: string; + sampleRate?: number; + route?: string | null; + beforeSend?: BeforeSendMiddleware; + debug?: boolean; + scriptSrc?: string; + endpoint?: string; +} +type EventTypes = 'vital'; +interface Event { + type: EventTypes; + url: string; +} +type BeforeSendMiddleware = (data: Event) => Event | null | undefined | false; +interface Functions { + beforeSend?: BeforeSendMiddleware; +} +interface SpeedInsights$1 { + queue: [T, Functions[T]][]; + addAction: (action: T, data: Functions[T]) => void; +} +declare global { + interface Window { + /** Base interface to track events */ + si?: SpeedInsights$1['addAction']; + /** Queue for speed insights datapoints, before the library is loaded */ + siq?: SpeedInsights$1['queue']; + sil?: boolean; + /** used by Astro component only */ + speedInsightsBeforeSend?: BeforeSendMiddleware; + } +} + +declare function SpeedInsights(props: Omit): JSX.Element; + +export { SpeedInsights }; diff --git a/node_modules/@vercel/speed-insights/dist/remix/index.d.ts b/node_modules/@vercel/speed-insights/dist/remix/index.d.ts new file mode 100644 index 0000000..57837a1 --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/remix/index.d.ts @@ -0,0 +1,37 @@ +interface SpeedInsightsProps { + dsn?: string; + sampleRate?: number; + route?: string | null; + beforeSend?: BeforeSendMiddleware; + debug?: boolean; + scriptSrc?: string; + endpoint?: string; +} +type EventTypes = 'vital'; +interface Event { + type: EventTypes; + url: string; +} +type BeforeSendMiddleware = (data: Event) => Event | null | undefined | false; +interface Functions { + beforeSend?: BeforeSendMiddleware; +} +interface SpeedInsights$1 { + queue: [T, Functions[T]][]; + addAction: (action: T, data: Functions[T]) => void; +} +declare global { + interface Window { + /** Base interface to track events */ + si?: SpeedInsights$1['addAction']; + /** Queue for speed insights datapoints, before the library is loaded */ + siq?: SpeedInsights$1['queue']; + sil?: boolean; + /** used by Astro component only */ + speedInsightsBeforeSend?: BeforeSendMiddleware; + } +} + +declare function SpeedInsights(props: Omit): JSX.Element; + +export { SpeedInsights }; diff --git a/node_modules/@vercel/speed-insights/dist/remix/index.js b/node_modules/@vercel/speed-insights/dist/remix/index.js new file mode 100644 index 0000000..189c120 --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/remix/index.js @@ -0,0 +1,206 @@ +"use strict"; +var __create = Object.create; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __getProtoOf = Object.getPrototypeOf; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __export = (target, all) => { + for (var name2 in all) + __defProp(target, name2, { get: all[name2], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( + // If the importer is in node compatibility mode or this is not an ESM + // file that has been converted to a CommonJS file using a Babel- + // compatible transform (i.e. "__esModule" has not been set), then set + // "default" to the CommonJS "module.exports" for node compatibility. + isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, + mod +)); +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/remix/index.tsx +var remix_exports = {}; +__export(remix_exports, { + SpeedInsights: () => SpeedInsights2 +}); +module.exports = __toCommonJS(remix_exports); +var import_react3 = __toESM(require("react")); + +// src/react/index.tsx +var import_react = require("react"); + +// package.json +var name = "@vercel/speed-insights"; +var version = "1.1.0"; + +// src/queue.ts +var initQueue = () => { + if (window.si) + return; + window.si = function a(...params) { + (window.siq = window.siq || []).push(params); + }; +}; + +// src/utils.ts +function isBrowser() { + return typeof window !== "undefined"; +} +function detectEnvironment() { + try { + const env = process.env.NODE_ENV; + if (env === "development" || env === "test") { + return "development"; + } + } catch (e) { + } + return "production"; +} +function isDevelopment() { + return detectEnvironment() === "development"; +} +function computeRoute(pathname, pathParams) { + if (!pathname || !pathParams) { + return pathname; + } + let result = pathname; + try { + const entries = Object.entries(pathParams); + for (const [key, value] of entries) { + if (!Array.isArray(value)) { + const matcher = turnValueToRegExp(value); + if (matcher.test(result)) { + result = result.replace(matcher, `/[${key}]`); + } + } + } + for (const [key, value] of entries) { + if (Array.isArray(value)) { + const matcher = turnValueToRegExp(value.join("/")); + if (matcher.test(result)) { + result = result.replace(matcher, `/[...${key}]`); + } + } + } + return result; + } catch (e) { + return pathname; + } +} +function turnValueToRegExp(value) { + return new RegExp(`/${escapeRegExp(value)}(?=[/?#]|$)`); +} +function escapeRegExp(string) { + return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); +} + +// src/generic.ts +var SCRIPT_URL = "https://va.vercel-scripts.com/v1/speed-insights"; +var PROD_SCRIPT_URL = `${SCRIPT_URL}/script.js`; +var DEV_SCRIPT_URL = `${SCRIPT_URL}/script.debug.js`; +var PROXY_SCRIPT_URL = "/_vercel/speed-insights/script.js"; +function injectSpeedInsights(props = {}) { + var _a; + if (!isBrowser() || props.route === null) + return null; + initQueue(); + const isSelfHosted = Boolean(props.dsn); + const productionScript = isSelfHosted ? PROD_SCRIPT_URL : PROXY_SCRIPT_URL; + const src = props.scriptSrc || (isDevelopment() ? DEV_SCRIPT_URL : productionScript); + if (document.head.querySelector(`script[src*="${src}"]`)) + return null; + if (props.beforeSend) { + (_a = window.si) == null ? void 0 : _a.call(window, "beforeSend", props.beforeSend); + } + const script = document.createElement("script"); + script.src = src; + script.defer = true; + script.dataset.sdkn = name + (props.framework ? `/${props.framework}` : ""); + script.dataset.sdkv = version; + if (props.sampleRate) { + script.dataset.sampleRate = props.sampleRate.toString(); + } + if (props.route) { + script.dataset.route = props.route; + } + if (props.endpoint) { + script.dataset.endpoint = props.endpoint; + } + if (props.dsn) { + script.dataset.dsn = props.dsn; + } + if (isDevelopment() && props.debug === false) { + script.dataset.debug = "false"; + } + script.onerror = () => { + console.log( + `[Vercel Speed Insights] Failed to load script from ${src}. Please check if any content blockers are enabled and try again.` + ); + }; + document.head.appendChild(script); + return { + setRoute: (route) => { + script.dataset.route = route ?? void 0; + } + }; +} + +// src/react/index.tsx +function SpeedInsights(props) { + (0, import_react.useEffect)(() => { + var _a; + if (props.beforeSend) { + (_a = window.si) == null ? void 0 : _a.call(window, "beforeSend", props.beforeSend); + } + }, [props.beforeSend]); + const setScriptRoute = (0, import_react.useRef)(null); + (0, import_react.useEffect)(() => { + if (!setScriptRoute.current) { + const script = injectSpeedInsights({ + framework: props.framework || "react", + ...props + }); + if (script) { + setScriptRoute.current = script.setRoute; + } + } else if (props.route) { + setScriptRoute.current(props.route); + } + }, [props.route]); + return null; +} + +// src/remix/utils.ts +var import_react2 = require("@remix-run/react"); +var useRoute = () => { + const params = (0, import_react2.useParams)(); + const location = (0, import_react2.useLocation)(); + return computeRoute(location.pathname, params); +}; + +// src/remix/index.tsx +function SpeedInsights2(props) { + const route = useRoute(); + return /* @__PURE__ */ import_react3.default.createElement( + SpeedInsights, + { + ...route && { route }, + ...props, + framework: "remix" + } + ); +} +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + SpeedInsights +}); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/node_modules/@vercel/speed-insights/dist/remix/index.js.map b/node_modules/@vercel/speed-insights/dist/remix/index.js.map new file mode 100644 index 0000000..dd33f3d --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/remix/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/remix/index.tsx","../../src/react/index.tsx","../../package.json","../../src/queue.ts","../../src/utils.ts","../../src/generic.ts","../../src/remix/utils.ts"],"sourcesContent":["import React from 'react';\nimport { SpeedInsights as SpeedInsightsScript } from '../react';\nimport type { SpeedInsightsProps } from '../types';\nimport { useRoute } from './utils';\n\nexport function SpeedInsights(\n props: Omit,\n): JSX.Element {\n const route = useRoute();\n\n return (\n \n );\n}\n","'use client';\nimport { useEffect, useRef } from 'react';\nimport type { SpeedInsightsProps } from '../types';\nimport { computeRoute, injectSpeedInsights } from '../generic';\n\nexport function SpeedInsights(\n props: SpeedInsightsProps & {\n framework?: string;\n },\n): JSX.Element | null {\n useEffect(() => {\n if (props.beforeSend) {\n window.si?.('beforeSend', props.beforeSend);\n }\n }, [props.beforeSend]);\n\n const setScriptRoute = useRef<((path: string) => void) | null>(null);\n useEffect(() => {\n if (!setScriptRoute.current) {\n const script = injectSpeedInsights({\n framework: props.framework || 'react',\n ...props,\n });\n if (script) {\n setScriptRoute.current = script.setRoute;\n }\n } else if (props.route) {\n setScriptRoute.current(props.route);\n }\n }, [props.route]);\n\n return null;\n}\n\nexport { computeRoute };\n","{\n \"name\": \"@vercel/speed-insights\",\n \"version\": \"1.1.0\",\n \"description\": \"Speed Insights is a tool for measuring web performance and providing suggestions for improvement.\",\n \"keywords\": [\n \"speed-insights\",\n \"vercel\"\n ],\n \"repository\": {\n \"url\": \"github:vercel/speed-insights\",\n \"directory\": \"packages/web\"\n },\n \"license\": \"Apache-2.0\",\n \"exports\": {\n \"./package.json\": \"./package.json\",\n \".\": {\n \"browser\": \"./dist/index.mjs\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\"\n },\n \"./astro\": {\n \"import\": \"./dist/astro/component.ts\"\n },\n \"./next\": {\n \"browser\": \"./dist/next/index.mjs\",\n \"import\": \"./dist/next/index.mjs\",\n \"require\": \"./dist/next/index.js\"\n },\n \"./nuxt\": {\n \"browser\": \"./dist/nuxt/index.mjs\",\n \"import\": \"./dist/nuxt/index.mjs\",\n \"require\": \"./dist/nuxt/index.js\"\n },\n \"./react\": {\n \"browser\": \"./dist/react/index.mjs\",\n \"import\": \"./dist/react/index.mjs\",\n \"require\": \"./dist/react/index.js\"\n },\n \"./remix\": {\n \"browser\": \"./dist/remix/index.mjs\",\n \"import\": \"./dist/remix/index.mjs\",\n \"require\": \"./dist/remix/index.js\"\n },\n \"./sveltekit\": {\n \"svelte\": \"./dist/sveltekit/index.mjs\",\n \"types\": \"./dist/sveltekit/index.d.ts\"\n },\n \"./vue\": {\n \"browser\": \"./dist/vue/index.mjs\",\n \"import\": \"./dist/vue/index.mjs\",\n \"require\": \"./dist/vue/index.js\"\n }\n },\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \"*\": [\n \"dist/index.d.ts\"\n ],\n \"react\": [\n \"dist/react/index.d.ts\"\n ],\n \"next\": [\n \"dist/next/index.d.ts\"\n ],\n \"nuxt\": [\n \"dist/nuxt/index.d.ts\"\n ],\n \"remix\": [\n \"dist/remix/index.d.ts\"\n ],\n \"sveltekit\": [\n \"dist/sveltekit/index.d.ts\"\n ],\n \"vue\": [\n \"dist/vue/index.d.ts\"\n ]\n }\n },\n \"scripts\": {\n \"build\": \"tsup && pnpm copy-astro\",\n \"copy-astro\": \"cp -R src/astro dist/\",\n \"dev\": \"pnpm copy-astro && tsup --watch\",\n \"postinstall\": \"node scripts/postinstall.mjs\",\n \"lint\": \"eslint .\",\n \"lint-fix\": \"eslint . --fix\",\n \"test\": \"jest\",\n \"type-check\": \"tsc --noEmit\"\n },\n \"devDependencies\": {\n \"@jest/globals\": \"^29.7.0\",\n \"@remix-run/react\": \"^2.5.0\",\n \"@sveltejs/kit\": \"^2.7\",\n \"@swc/core\": \"^1.3.103\",\n \"@swc/jest\": \"^0.2.29\",\n \"@testing-library/jest-dom\": \"^6.6.3\",\n \"@testing-library/react\": \"^16.0.1\",\n \"@types/node\": \"^20.11.4\",\n \"@types/react\": \"^18.2.48\",\n \"copyfiles\": \"^2.4.1\",\n \"jest\": \"^29.7.0\",\n \"jest-environment-jsdom\": \"^29.7.0\",\n \"next\": \"^14.0.4\",\n \"react\": \"^18.2.0\",\n \"react-dom\": \"^18.2.0\",\n \"svelte\": \"^5\",\n \"tsup\": \"7.2.0\",\n \"vue\": \"^3.4.14\",\n \"vue-router\": \"^4.2.5\"\n },\n \"peerDependencies\": {\n \"@sveltejs/kit\": \"^1 || ^2\",\n \"next\": \">= 13\",\n \"react\": \"^18 || ^19 || ^19.0.0-rc\",\n \"svelte\": \">= 4\",\n \"vue\": \"^3\",\n \"vue-router\": \"^4\"\n },\n \"peerDependenciesMeta\": {\n \"@sveltejs/kit\": {\n \"optional\": true\n },\n \"next\": {\n \"optional\": true\n },\n \"react\": {\n \"optional\": true\n },\n \"svelte\": {\n \"optional\": true\n },\n \"vue\": {\n \"optional\": true\n },\n \"vue-router\": {\n \"optional\": true\n }\n }\n}\n","export const initQueue = (): void => {\n // initialize va until script is loaded\n if (window.si) return;\n\n window.si = function a(...params): void {\n (window.siq = window.siq || []).push(params);\n };\n};\n","export function isBrowser(): boolean {\n return typeof window !== 'undefined';\n}\n\nfunction detectEnvironment(): 'development' | 'production' {\n try {\n const env = process.env.NODE_ENV;\n if (env === 'development' || env === 'test') {\n return 'development';\n }\n } catch (e) {\n // do nothing, this is okay\n }\n return 'production';\n}\n\nexport function isProduction(): boolean {\n return detectEnvironment() === 'production';\n}\n\nexport function isDevelopment(): boolean {\n return detectEnvironment() === 'development';\n}\n\nexport function computeRoute(\n pathname: string | null,\n pathParams: Record | null,\n): string | null {\n if (!pathname || !pathParams) {\n return pathname;\n }\n\n let result = pathname;\n try {\n const entries = Object.entries(pathParams);\n // simple keys must be handled first\n for (const [key, value] of entries) {\n if (!Array.isArray(value)) {\n const matcher = turnValueToRegExp(value);\n if (matcher.test(result)) {\n result = result.replace(matcher, `/[${key}]`);\n }\n }\n }\n // array values next\n for (const [key, value] of entries) {\n if (Array.isArray(value)) {\n const matcher = turnValueToRegExp(value.join('/'));\n if (matcher.test(result)) {\n result = result.replace(matcher, `/[...${key}]`);\n }\n }\n }\n return result;\n } catch (e) {\n return pathname;\n }\n}\n\nfunction turnValueToRegExp(value: string): RegExp {\n return new RegExp(`/${escapeRegExp(value)}(?=[/?#]|$)`);\n}\n\nfunction escapeRegExp(string: string): string {\n return string.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n","import { name as packageName, version } from '../package.json';\nimport { initQueue } from './queue';\nimport type { SpeedInsightsProps } from './types';\nimport { isBrowser, isDevelopment, computeRoute } from './utils';\n\nconst SCRIPT_URL = 'https://va.vercel-scripts.com/v1/speed-insights';\nconst PROD_SCRIPT_URL = `${SCRIPT_URL}/script.js`;\nconst DEV_SCRIPT_URL = `${SCRIPT_URL}/script.debug.js`;\nconst PROXY_SCRIPT_URL = '/_vercel/speed-insights/script.js';\n\n/**\n * Injects the Vercel Speed Insights script into the page head and starts tracking page views. Read more in our [documentation](https://vercel.com/docs/speed-insights).\n * @param [props] - Speed Insights options.\n * @param [props.debug] - Whether to enable debug logging in development. Defaults to `true`.\n * @param [props.beforeSend] - A middleware function to modify events before they are sent. Should return the event object or `null` to cancel the event.\n * @param [props.sampleRate] - When setting to 0.5, 50% of the events will be sent to Vercel Speed Insights. Defaults to `1`.\n * @param [props.route] - The dynamic route of the page.\n * @param [props.dsn] - The DSN of the project to send events to. Only required when self-hosting.\n */\nfunction injectSpeedInsights(\n props: SpeedInsightsProps & {\n framework?: string;\n } = {},\n): {\n setRoute: (route: string | null) => void;\n} | null {\n // When route is null, it means that pages router is not ready yet. Will resolve soon\n if (!isBrowser() || props.route === null) return null;\n\n initQueue();\n\n const isSelfHosted = Boolean(props.dsn);\n\n const productionScript = isSelfHosted ? PROD_SCRIPT_URL : PROXY_SCRIPT_URL;\n\n const src =\n props.scriptSrc || (isDevelopment() ? DEV_SCRIPT_URL : productionScript);\n\n if (document.head.querySelector(`script[src*=\"${src}\"]`)) return null;\n\n if (props.beforeSend) {\n window.si?.('beforeSend', props.beforeSend);\n }\n\n const script = document.createElement('script');\n script.src = src;\n script.defer = true;\n script.dataset.sdkn =\n packageName + (props.framework ? `/${props.framework}` : '');\n script.dataset.sdkv = version;\n\n if (props.sampleRate) {\n script.dataset.sampleRate = props.sampleRate.toString();\n }\n if (props.route) {\n script.dataset.route = props.route;\n }\n if (props.endpoint) {\n script.dataset.endpoint = props.endpoint;\n }\n if (props.dsn) {\n script.dataset.dsn = props.dsn;\n }\n if (isDevelopment() && props.debug === false) {\n script.dataset.debug = 'false';\n }\n\n script.onerror = (): void => {\n // eslint-disable-next-line no-console -- Logging is okay here\n console.log(\n `[Vercel Speed Insights] Failed to load script from ${src}. Please check if any content blockers are enabled and try again.`,\n );\n };\n\n document.head.appendChild(script);\n\n return {\n setRoute: (route: string | null): void => {\n script.dataset.route = route ?? undefined;\n },\n };\n}\n\nexport { injectSpeedInsights, computeRoute };\nexport type { SpeedInsightsProps };\n\n// eslint-disable-next-line import/no-default-export -- Allow default export\nexport default {\n injectSpeedInsights,\n computeRoute,\n};\n","import { useLocation, useParams } from '@remix-run/react';\nimport { computeRoute } from '../utils';\n\nexport const useRoute = (): string | null => {\n const params = useParams();\n const location = useLocation();\n\n return computeRoute(location.pathname, params as never);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,uBAAAA;AAAA;AAAA;AAAA,IAAAC,gBAAkB;;;ACClB,mBAAkC;;;ACAhC,WAAQ;AACR,cAAW;;;ACFN,IAAM,YAAY,MAAY;AAEnC,MAAI,OAAO;AAAI;AAEf,SAAO,KAAK,SAAS,KAAK,QAAc;AACtC,KAAC,OAAO,MAAM,OAAO,OAAO,CAAC,GAAG,KAAK,MAAM;AAAA,EAC7C;AACF;;;ACPO,SAAS,YAAqB;AACnC,SAAO,OAAO,WAAW;AAC3B;AAEA,SAAS,oBAAkD;AACzD,MAAI;AACF,UAAM,MAAM,QAAQ,IAAI;AACxB,QAAI,QAAQ,iBAAiB,QAAQ,QAAQ;AAC3C,aAAO;AAAA,IACT;AAAA,EACF,SAAS,GAAG;AAAA,EAEZ;AACA,SAAO;AACT;AAMO,SAAS,gBAAyB;AACvC,SAAO,kBAAkB,MAAM;AACjC;AAEO,SAAS,aACd,UACA,YACe;AACf,MAAI,CAAC,YAAY,CAAC,YAAY;AAC5B,WAAO;AAAA,EACT;AAEA,MAAI,SAAS;AACb,MAAI;AACF,UAAM,UAAU,OAAO,QAAQ,UAAU;AAEzC,eAAW,CAAC,KAAK,KAAK,KAAK,SAAS;AAClC,UAAI,CAAC,MAAM,QAAQ,KAAK,GAAG;AACzB,cAAM,UAAU,kBAAkB,KAAK;AACvC,YAAI,QAAQ,KAAK,MAAM,GAAG;AACxB,mBAAS,OAAO,QAAQ,SAAS,KAAK,GAAG,GAAG;AAAA,QAC9C;AAAA,MACF;AAAA,IACF;AAEA,eAAW,CAAC,KAAK,KAA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AAI,SAAS,EAAE,MAAM;AAAA,MACrB,GAAG;AAAA,MACJ,WAAU;AAAA;AAAA,EACZ;AAEJ;","names":["SpeedInsights","import_react","import_react","SpeedInsights","React"]} \ No newline at end of file diff --git a/node_modules/@vercel/speed-insights/dist/remix/index.mjs b/node_modules/@vercel/speed-insights/dist/remix/index.mjs new file mode 100644 index 0000000..f0a95a8 --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/remix/index.mjs @@ -0,0 +1,171 @@ +// src/remix/index.tsx +import React from "react"; + +// src/react/index.tsx +import { useEffect, useRef } from "react"; + +// package.json +var name = "@vercel/speed-insights"; +var version = "1.1.0"; + +// src/queue.ts +var initQueue = () => { + if (window.si) + return; + window.si = function a(...params) { + (window.siq = window.siq || []).push(params); + }; +}; + +// src/utils.ts +function isBrowser() { + return typeof window !== "undefined"; +} +function detectEnvironment() { + try { + const env = process.env.NODE_ENV; + if (env === "development" || env === "test") { + return "development"; + } + } catch (e) { + } + return "production"; +} +function isDevelopment() { + return detectEnvironment() === "development"; +} +function computeRoute(pathname, pathParams) { + if (!pathname || !pathParams) { + return pathname; + } + let result = pathname; + try { + const entries = Object.entries(pathParams); + for (const [key, value] of entries) { + if (!Array.isArray(value)) { + const matcher = turnValueToRegExp(value); + if (matcher.test(result)) { + result = result.replace(matcher, `/[${key}]`); + } + } + } + for (const [key, value] of entries) { + if (Array.isArray(value)) { + const matcher = turnValueToRegExp(value.join("/")); + if (matcher.test(result)) { + result = result.replace(matcher, `/[...${key}]`); + } + } + } + return result; + } catch (e) { + return pathname; + } +} +function turnValueToRegExp(value) { + return new RegExp(`/${escapeRegExp(value)}(?=[/?#]|$)`); +} +function escapeRegExp(string) { + return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); +} + +// src/generic.ts +var SCRIPT_URL = "https://va.vercel-scripts.com/v1/speed-insights"; +var PROD_SCRIPT_URL = `${SCRIPT_URL}/script.js`; +var DEV_SCRIPT_URL = `${SCRIPT_URL}/script.debug.js`; +var PROXY_SCRIPT_URL = "/_vercel/speed-insights/script.js"; +function injectSpeedInsights(props = {}) { + var _a; + if (!isBrowser() || props.route === null) + return null; + initQueue(); + const isSelfHosted = Boolean(props.dsn); + const productionScript = isSelfHosted ? PROD_SCRIPT_URL : PROXY_SCRIPT_URL; + const src = props.scriptSrc || (isDevelopment() ? DEV_SCRIPT_URL : productionScript); + if (document.head.querySelector(`script[src*="${src}"]`)) + return null; + if (props.beforeSend) { + (_a = window.si) == null ? void 0 : _a.call(window, "beforeSend", props.beforeSend); + } + const script = document.createElement("script"); + script.src = src; + script.defer = true; + script.dataset.sdkn = name + (props.framework ? `/${props.framework}` : ""); + script.dataset.sdkv = version; + if (props.sampleRate) { + script.dataset.sampleRate = props.sampleRate.toString(); + } + if (props.route) { + script.dataset.route = props.route; + } + if (props.endpoint) { + script.dataset.endpoint = props.endpoint; + } + if (props.dsn) { + script.dataset.dsn = props.dsn; + } + if (isDevelopment() && props.debug === false) { + script.dataset.debug = "false"; + } + script.onerror = () => { + console.log( + `[Vercel Speed Insights] Failed to load script from ${src}. Please check if any content blockers are enabled and try again.` + ); + }; + document.head.appendChild(script); + return { + setRoute: (route) => { + script.dataset.route = route ?? void 0; + } + }; +} + +// src/react/index.tsx +function SpeedInsights(props) { + useEffect(() => { + var _a; + if (props.beforeSend) { + (_a = window.si) == null ? void 0 : _a.call(window, "beforeSend", props.beforeSend); + } + }, [props.beforeSend]); + const setScriptRoute = useRef(null); + useEffect(() => { + if (!setScriptRoute.current) { + const script = injectSpeedInsights({ + framework: props.framework || "react", + ...props + }); + if (script) { + setScriptRoute.current = script.setRoute; + } + } else if (props.route) { + setScriptRoute.current(props.route); + } + }, [props.route]); + return null; +} + +// src/remix/utils.ts +import { useLocation, useParams } from "@remix-run/react"; +var useRoute = () => { + const params = useParams(); + const location = useLocation(); + return computeRoute(location.pathname, params); +}; + +// src/remix/index.tsx +function SpeedInsights2(props) { + const route = useRoute(); + return /* @__PURE__ */ React.createElement( + SpeedInsights, + { + ...route && { route }, + ...props, + framework: "remix" + } + ); +} +export { + SpeedInsights2 as SpeedInsights +}; +//# sourceMappingURL=index.mjs.map \ No newline at end of file diff --git a/node_modules/@vercel/speed-insights/dist/remix/index.mjs.map b/node_modules/@vercel/speed-insights/dist/remix/index.mjs.map new file mode 100644 index 0000000..8c4dc22 --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/remix/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/remix/index.tsx","../../src/react/index.tsx","../../package.json","../../src/queue.ts","../../src/utils.ts","../../src/generic.ts","../../src/remix/utils.ts"],"sourcesContent":["import React from 'react';\nimport { SpeedInsights as SpeedInsightsScript } from '../react';\nimport type { SpeedInsightsProps } from '../types';\nimport { useRoute } from './utils';\n\nexport function SpeedInsights(\n props: Omit,\n): JSX.Element {\n const route = useRoute();\n\n return (\n \n );\n}\n","'use client';\nimport { useEffect, useRef } from 'react';\nimport type { SpeedInsightsProps } from '../types';\nimport { computeRoute, injectSpeedInsights } from '../generic';\n\nexport function SpeedInsights(\n props: SpeedInsightsProps & {\n framework?: string;\n },\n): JSX.Element | null {\n useEffect(() => {\n if (props.beforeSend) {\n window.si?.('beforeSend', props.beforeSend);\n }\n }, [props.beforeSend]);\n\n const setScriptRoute = useRef<((path: string) => void) | null>(null);\n useEffect(() => {\n if (!setScriptRoute.current) {\n const script = injectSpeedInsights({\n framework: props.framework || 'react',\n ...props,\n });\n if (script) {\n setScriptRoute.current = script.setRoute;\n }\n } else if (props.route) {\n setScriptRoute.current(props.route);\n }\n }, [props.route]);\n\n return null;\n}\n\nexport { computeRoute };\n","{\n \"name\": \"@vercel/speed-insights\",\n \"version\": \"1.1.0\",\n \"description\": \"Speed Insights is a tool for measuring web performance and providing suggestions for improvement.\",\n \"keywords\": [\n \"speed-insights\",\n \"vercel\"\n ],\n \"repository\": {\n \"url\": \"github:vercel/speed-insights\",\n \"directory\": \"packages/web\"\n },\n \"license\": \"Apache-2.0\",\n \"exports\": {\n \"./package.json\": \"./package.json\",\n \".\": {\n \"browser\": \"./dist/index.mjs\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\"\n },\n \"./astro\": {\n \"import\": \"./dist/astro/component.ts\"\n },\n \"./next\": {\n \"browser\": \"./dist/next/index.mjs\",\n \"import\": \"./dist/next/index.mjs\",\n \"require\": \"./dist/next/index.js\"\n },\n \"./nuxt\": {\n \"browser\": \"./dist/nuxt/index.mjs\",\n \"import\": \"./dist/nuxt/index.mjs\",\n \"require\": \"./dist/nuxt/index.js\"\n },\n \"./react\": {\n \"browser\": \"./dist/react/index.mjs\",\n \"import\": \"./dist/react/index.mjs\",\n \"require\": \"./dist/react/index.js\"\n },\n \"./remix\": {\n \"browser\": \"./dist/remix/index.mjs\",\n \"import\": \"./dist/remix/index.mjs\",\n \"require\": \"./dist/remix/index.js\"\n },\n \"./sveltekit\": {\n \"svelte\": \"./dist/sveltekit/index.mjs\",\n \"types\": \"./dist/sveltekit/index.d.ts\"\n },\n \"./vue\": {\n \"browser\": \"./dist/vue/index.mjs\",\n \"import\": \"./dist/vue/index.mjs\",\n \"require\": \"./dist/vue/index.js\"\n }\n },\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \"*\": [\n \"dist/index.d.ts\"\n ],\n \"react\": [\n \"dist/react/index.d.ts\"\n ],\n \"next\": [\n \"dist/next/index.d.ts\"\n ],\n \"nuxt\": [\n \"dist/nuxt/index.d.ts\"\n ],\n \"remix\": [\n \"dist/remix/index.d.ts\"\n ],\n \"sveltekit\": [\n \"dist/sveltekit/index.d.ts\"\n ],\n \"vue\": [\n \"dist/vue/index.d.ts\"\n ]\n }\n },\n \"scripts\": {\n \"build\": \"tsup && pnpm copy-astro\",\n \"copy-astro\": \"cp -R src/astro dist/\",\n \"dev\": \"pnpm copy-astro && tsup --watch\",\n \"postinstall\": \"node scripts/postinstall.mjs\",\n \"lint\": \"eslint .\",\n \"lint-fix\": \"eslint . --fix\",\n \"test\": \"jest\",\n \"type-check\": \"tsc --noEmit\"\n },\n \"devDependencies\": {\n \"@jest/globals\": \"^29.7.0\",\n \"@remix-run/react\": \"^2.5.0\",\n \"@sveltejs/kit\": \"^2.7\",\n \"@swc/core\": \"^1.3.103\",\n \"@swc/jest\": \"^0.2.29\",\n \"@testing-library/jest-dom\": \"^6.6.3\",\n \"@testing-library/react\": \"^16.0.1\",\n \"@types/node\": \"^20.11.4\",\n \"@types/react\": \"^18.2.48\",\n \"copyfiles\": \"^2.4.1\",\n \"jest\": \"^29.7.0\",\n \"jest-environment-jsdom\": \"^29.7.0\",\n \"next\": \"^14.0.4\",\n \"react\": \"^18.2.0\",\n \"react-dom\": \"^18.2.0\",\n \"svelte\": \"^5\",\n \"tsup\": \"7.2.0\",\n \"vue\": \"^3.4.14\",\n \"vue-router\": \"^4.2.5\"\n },\n \"peerDependencies\": {\n \"@sveltejs/kit\": \"^1 || ^2\",\n \"next\": \">= 13\",\n \"react\": \"^18 || ^19 || ^19.0.0-rc\",\n \"svelte\": \">= 4\",\n \"vue\": \"^3\",\n \"vue-router\": \"^4\"\n },\n \"peerDependenciesMeta\": {\n \"@sveltejs/kit\": {\n \"optional\": true\n },\n \"next\": {\n \"optional\": true\n },\n \"react\": {\n \"optional\": true\n },\n \"svelte\": {\n \"optional\": true\n },\n \"vue\": {\n \"optional\": true\n },\n \"vue-router\": {\n \"optional\": true\n }\n }\n}\n","export const initQueue = (): void => {\n // initialize va until script is loaded\n if (window.si) return;\n\n window.si = function a(...params): void {\n (window.siq = window.siq || []).push(params);\n };\n};\n","export function isBrowser(): boolean {\n return typeof window !== 'undefined';\n}\n\nfunction detectEnvironment(): 'development' | 'production' {\n try {\n const env = process.env.NODE_ENV;\n if (env === 'development' || env === 'test') {\n return 'development';\n }\n } catch (e) {\n // do nothing, this is okay\n }\n return 'production';\n}\n\nexport function isProduction(): boolean {\n return detectEnvironment() === 'production';\n}\n\nexport function isDevelopment(): boolean {\n return detectEnvironment() === 'development';\n}\n\nexport function computeRoute(\n pathname: string | null,\n pathParams: Record | null,\n): string | null {\n if (!pathname || !pathParams) {\n return pathname;\n }\n\n let result = pathname;\n try {\n const entries = Object.entries(pathParams);\n // simple keys must be handled first\n for (const [key, value] of entries) {\n if (!Array.isArray(value)) {\n const matcher = turnValueToRegExp(value);\n if (matcher.test(result)) {\n result = result.replace(matcher, `/[${key}]`);\n }\n }\n }\n // array values next\n for (const [key, value] of entries) {\n if (Array.isArray(value)) {\n const matcher = turnValueToRegExp(value.join('/'));\n if (matcher.test(result)) {\n result = result.replace(matcher, `/[...${key}]`);\n }\n }\n }\n return result;\n } catch (e) {\n return pathname;\n }\n}\n\nfunction turnValueToRegExp(value: string): RegExp {\n return new RegExp(`/${escapeRegExp(value)}(?=[/?#]|$)`);\n}\n\nfunction escapeRegExp(string: string): string {\n return string.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n","import { name as packageName, version } from '../package.json';\nimport { initQueue } from './queue';\nimport type { SpeedInsightsProps } from './types';\nimport { isBrowser, isDevelopment, computeRoute } from './utils';\n\nconst SCRIPT_URL = 'https://va.vercel-scripts.com/v1/speed-insights';\nconst PROD_SCRIPT_URL = `${SCRIPT_URL}/script.js`;\nconst DEV_SCRIPT_URL = `${SCRIPT_URL}/script.debug.js`;\nconst PROXY_SCRIPT_URL = '/_vercel/speed-insights/script.js';\n\n/**\n * Injects the Vercel Speed Insights script into the page head and starts tracking page views. Read more in our [documentation](https://vercel.com/docs/speed-insights).\n * @param [props] - Speed Insights options.\n * @param [props.debug] - Whether to enable debug logging in development. Defaults to `true`.\n * @param [props.beforeSend] - A middleware function to modify events before they are sent. Should return the event object or `null` to cancel the event.\n * @param [props.sampleRate] - When setting to 0.5, 50% of the events will be sent to Vercel Speed Insights. Defaults to `1`.\n * @param [props.route] - The dynamic route of the page.\n * @param [props.dsn] - The DSN of the project to send events to. Only required when self-hosting.\n */\nfunction injectSpeedInsights(\n props: SpeedInsightsProps & {\n framework?: string;\n } = {},\n): {\n setRoute: (route: string | null) => void;\n} | null {\n // When route is null, it means that pages router is not ready yet. Will resolve soon\n if (!isBrowser() || props.route === null) return null;\n\n initQueue();\n\n const isSelfHosted = Boolean(props.dsn);\n\n const productionScript = isSelfHosted ? PROD_SCRIPT_URL : PROXY_SCRIPT_URL;\n\n const src =\n props.scriptSrc || (isDevelopment() ? DEV_SCRIPT_URL : productionScript);\n\n if (document.head.querySelector(`script[src*=\"${src}\"]`)) return null;\n\n if (props.beforeSend) {\n window.si?.('beforeSend', props.beforeSend);\n }\n\n const script = document.createElement('script');\n script.src = src;\n script.defer = true;\n script.dataset.sdkn =\n packageName + (props.framework ? `/${props.framework}` : '');\n script.dataset.sdkv = version;\n\n if (props.sampleRate) {\n script.dataset.sampleRate = props.sampleRate.toString();\n }\n if (props.route) {\n script.dataset.route = props.route;\n }\n if (props.endpoint) {\n script.dataset.endpoint = props.endpoint;\n }\n if (props.dsn) {\n script.dataset.dsn = props.dsn;\n }\n if (isDevelopment() && props.debug === false) {\n script.dataset.debug = 'false';\n }\n\n script.onerror = (): void => {\n // eslint-disable-next-line no-console -- Logging is okay here\n console.log(\n `[Vercel Speed Insights] Failed to load script from ${src}. Please check if any content blockers are enabled and try again.`,\n );\n };\n\n document.head.appendChild(script);\n\n return {\n setRoute: (route: string | null): void => {\n script.dataset.route = route ?? undefined;\n },\n };\n}\n\nexport { injectSpeedInsights, computeRoute };\nexport type { SpeedInsightsProps };\n\n// eslint-disable-next-line import/no-default-export -- Allow default export\nexport default {\n injectSpeedInsights,\n computeRoute,\n};\n","import { useLocation, useParams } from '@remix-run/react';\nimport { computeRoute } from '../utils';\n\nexport const useRoute = (): string | null => {\n const params = useParams();\n const location = useLocation();\n\n return computeRoute(location.pathname, params as never);\n};\n"],"mappings":";AAAA,OAAO,WAAW;;;ACClB,SAAS,WAAW,cAAc;;;ACAhC,WAAQ;AACR,cAAW;;;ACFN,IAAM,YAAY,MAAY;AAEnC,MAAI,OAAO;A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AAQ,SAAS;AAAA,IAClC;AAAA,EACF;AACF;;;AJ5EO,SAAS,cACd,OAGoB;AACpB,YAAU,MAAM;AAVlB;AAWI,QAAI,MAAM,YAAY;AACpB,mBAAO,OAAP,gCAAY,cAAc,MAAM;AAAA,IAClC;AAAA,EACF,GAAG,CAAC,MAAM,UAAU,CAAC;AAErB,QAAM,iBAAiB,OAAwC,IAAI;AACnE,YAAU,MAAM;AACd,QAAI,CAAC,eAAe,SAAS;AAC3B,YAAM,SAAS,oBAAoB;AAAA,QACjC,WAAW,MAAM,aAAa;AAAA,QAC9B,GAAG;AAAA,MACL,CAAC;AACD,UAAI,QAAQ;AACV,uBAAe,UAAU,OAAO;AAAA,MAClC;AAAA,IACF,WAAW,MAAM,OAAO;AACtB,qBAAe,QAAQ,MAAM,KAAK;AAAA,IACpC;AAAA,EACF,GAAG,CAAC,MAAM,KAAK,CAAC;AAEhB,SAAO;AACT;;;AKhCA,SAAS,aAAa,iBAAiB;AAGhC,IAAM,WAAW,MAAqB;AAC3C,QAAM,SAAS,UAAU;AACzB,QAAM,WAAW,YAAY;AAE7B,SAAO,aAAa,SAAS,UAAU,MAAe;AACxD;;;ANHO,SAASA,eACd,OACa;AACb,QAAM,QAAQ,SAAS;AAEvB,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAI,SAAS,EAAE,MAAM;AAAA,MACrB,GAAG;AAAA,MACJ,WAAU;AAAA;AAAA,EACZ;AAEJ;","names":["SpeedInsights"]} \ No newline at end of file diff --git a/node_modules/@vercel/speed-insights/dist/sveltekit/index.d.mts b/node_modules/@vercel/speed-insights/dist/sveltekit/index.d.mts new file mode 100644 index 0000000..e0d6908 --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/sveltekit/index.d.mts @@ -0,0 +1,37 @@ +interface SpeedInsightsProps { + dsn?: string; + sampleRate?: number; + route?: string | null; + beforeSend?: BeforeSendMiddleware; + debug?: boolean; + scriptSrc?: string; + endpoint?: string; +} +type EventTypes = 'vital'; +interface Event { + type: EventTypes; + url: string; +} +type BeforeSendMiddleware = (data: Event) => Event | null | undefined | false; +interface Functions { + beforeSend?: BeforeSendMiddleware; +} +interface SpeedInsights { + queue: [T, Functions[T]][]; + addAction: (action: T, data: Functions[T]) => void; +} +declare global { + interface Window { + /** Base interface to track events */ + si?: SpeedInsights['addAction']; + /** Queue for speed insights datapoints, before the library is loaded */ + siq?: SpeedInsights['queue']; + sil?: boolean; + /** used by Astro component only */ + speedInsightsBeforeSend?: BeforeSendMiddleware; + } +} + +declare function injectSpeedInsights(props?: Omit): void; + +export { injectSpeedInsights }; diff --git a/node_modules/@vercel/speed-insights/dist/sveltekit/index.d.ts b/node_modules/@vercel/speed-insights/dist/sveltekit/index.d.ts new file mode 100644 index 0000000..e0d6908 --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/sveltekit/index.d.ts @@ -0,0 +1,37 @@ +interface SpeedInsightsProps { + dsn?: string; + sampleRate?: number; + route?: string | null; + beforeSend?: BeforeSendMiddleware; + debug?: boolean; + scriptSrc?: string; + endpoint?: string; +} +type EventTypes = 'vital'; +interface Event { + type: EventTypes; + url: string; +} +type BeforeSendMiddleware = (data: Event) => Event | null | undefined | false; +interface Functions { + beforeSend?: BeforeSendMiddleware; +} +interface SpeedInsights { + queue: [T, Functions[T]][]; + addAction: (action: T, data: Functions[T]) => void; +} +declare global { + interface Window { + /** Base interface to track events */ + si?: SpeedInsights['addAction']; + /** Queue for speed insights datapoints, before the library is loaded */ + siq?: SpeedInsights['queue']; + sil?: boolean; + /** used by Astro component only */ + speedInsightsBeforeSend?: BeforeSendMiddleware; + } +} + +declare function injectSpeedInsights(props?: Omit): void; + +export { injectSpeedInsights }; diff --git a/node_modules/@vercel/speed-insights/dist/sveltekit/index.js b/node_modules/@vercel/speed-insights/dist/sveltekit/index.js new file mode 100644 index 0000000..3b4c39d --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/sveltekit/index.js @@ -0,0 +1,136 @@ +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __export = (target, all) => { + for (var name2 in all) + __defProp(target, name2, { get: all[name2], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/sveltekit/index.ts +var sveltekit_exports = {}; +__export(sveltekit_exports, { + injectSpeedInsights: () => injectSpeedInsights2 +}); +module.exports = __toCommonJS(sveltekit_exports); +var import_store = require("svelte/store"); + +// package.json +var name = "@vercel/speed-insights"; +var version = "1.1.0"; + +// src/queue.ts +var initQueue = () => { + if (window.si) + return; + window.si = function a(...params) { + (window.siq = window.siq || []).push(params); + }; +}; + +// src/utils.ts +function isBrowser() { + return typeof window !== "undefined"; +} +function detectEnvironment() { + try { + const env = process.env.NODE_ENV; + if (env === "development" || env === "test") { + return "development"; + } + } catch (e) { + } + return "production"; +} +function isDevelopment() { + return detectEnvironment() === "development"; +} + +// src/generic.ts +var SCRIPT_URL = "https://va.vercel-scripts.com/v1/speed-insights"; +var PROD_SCRIPT_URL = `${SCRIPT_URL}/script.js`; +var DEV_SCRIPT_URL = `${SCRIPT_URL}/script.debug.js`; +var PROXY_SCRIPT_URL = "/_vercel/speed-insights/script.js"; +function injectSpeedInsights(props = {}) { + var _a; + if (!isBrowser() || props.route === null) + return null; + initQueue(); + const isSelfHosted = Boolean(props.dsn); + const productionScript = isSelfHosted ? PROD_SCRIPT_URL : PROXY_SCRIPT_URL; + const src = props.scriptSrc || (isDevelopment() ? DEV_SCRIPT_URL : productionScript); + if (document.head.querySelector(`script[src*="${src}"]`)) + return null; + if (props.beforeSend) { + (_a = window.si) == null ? void 0 : _a.call(window, "beforeSend", props.beforeSend); + } + const script = document.createElement("script"); + script.src = src; + script.defer = true; + script.dataset.sdkn = name + (props.framework ? `/${props.framework}` : ""); + script.dataset.sdkv = version; + if (props.sampleRate) { + script.dataset.sampleRate = props.sampleRate.toString(); + } + if (props.route) { + script.dataset.route = props.route; + } + if (props.endpoint) { + script.dataset.endpoint = props.endpoint; + } + if (props.dsn) { + script.dataset.dsn = props.dsn; + } + if (isDevelopment() && props.debug === false) { + script.dataset.debug = "false"; + } + script.onerror = () => { + console.log( + `[Vercel Speed Insights] Failed to load script from ${src}. Please check if any content blockers are enabled and try again.` + ); + }; + document.head.appendChild(script); + return { + setRoute: (route) => { + script.dataset.route = route ?? void 0; + } + }; +} + +// src/sveltekit/index.ts +var import_stores = require("$app/stores"); +var import_environment = require("$app/environment"); +function injectSpeedInsights2(props = {}) { + var _a; + if (import_environment.browser) { + const speedInsights = injectSpeedInsights({ + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- route could be undefined in layout.js file + route: (_a = (0, import_store.get)(import_stores.page).route) == null ? void 0 : _a.id, + ...props, + framework: "sveltekit" + }); + if (speedInsights) { + import_stores.page.subscribe((value) => { + var _a2; + if ((_a2 = value.route) == null ? void 0 : _a2.id) { + speedInsights.setRoute(value.route.id); + } + }); + } + } +} +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + injectSpeedInsights +}); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/node_modules/@vercel/speed-insights/dist/sveltekit/index.js.map b/node_modules/@vercel/speed-insights/dist/sveltekit/index.js.map new file mode 100644 index 0000000..6dae35a --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/sveltekit/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/sveltekit/index.ts","../../package.json","../../src/queue.ts","../../src/utils.ts","../../src/generic.ts"],"sourcesContent":["import { get } from 'svelte/store';\nimport {\n injectSpeedInsights as genericInject,\n type SpeedInsightsProps,\n} from '../generic';\nimport { page } from '$app/stores';\nimport { browser } from '$app/environment';\nimport type {} from '@sveltejs/kit'; // don't remove, ensures ambient types for $app/* are loaded\n\nexport function injectSpeedInsights(\n props: Omit = {},\n): void {\n if (browser) {\n const speedInsights = genericInject({\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- route could be undefined in layout.js file\n route: get(page).route?.id,\n ...props,\n framework: 'sveltekit',\n });\n\n if (speedInsights) {\n page.subscribe((value) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- route could be undefined in layout.js file\n if (value.route?.id) {\n speedInsights.setRoute(value.route.id);\n }\n });\n }\n }\n}\n","{\n \"name\": \"@vercel/speed-insights\",\n \"version\": \"1.1.0\",\n \"description\": \"Speed Insights is a tool for measuring web performance and providing suggestions for improvement.\",\n \"keywords\": [\n \"speed-insights\",\n \"vercel\"\n ],\n \"repository\": {\n \"url\": \"github:vercel/speed-insights\",\n \"directory\": \"packages/web\"\n },\n \"license\": \"Apache-2.0\",\n \"exports\": {\n \"./package.json\": \"./package.json\",\n \".\": {\n \"browser\": \"./dist/index.mjs\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\"\n },\n \"./astro\": {\n \"import\": \"./dist/astro/component.ts\"\n },\n \"./next\": {\n \"browser\": \"./dist/next/index.mjs\",\n \"import\": \"./dist/next/index.mjs\",\n \"require\": \"./dist/next/index.js\"\n },\n \"./nuxt\": {\n \"browser\": \"./dist/nuxt/index.mjs\",\n \"import\": \"./dist/nuxt/index.mjs\",\n \"require\": \"./dist/nuxt/index.js\"\n },\n \"./react\": {\n \"browser\": \"./dist/react/index.mjs\",\n \"import\": \"./dist/react/index.mjs\",\n \"require\": \"./dist/react/index.js\"\n },\n \"./remix\": {\n \"browser\": \"./dist/remix/index.mjs\",\n \"import\": \"./dist/remix/index.mjs\",\n \"require\": \"./dist/remix/index.js\"\n },\n \"./sveltekit\": {\n \"svelte\": \"./dist/sveltekit/index.mjs\",\n \"types\": \"./dist/sveltekit/index.d.ts\"\n },\n \"./vue\": {\n \"browser\": \"./dist/vue/index.mjs\",\n \"import\": \"./dist/vue/index.mjs\",\n \"require\": \"./dist/vue/index.js\"\n }\n },\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \"*\": [\n \"dist/index.d.ts\"\n ],\n \"react\": [\n \"dist/react/index.d.ts\"\n ],\n \"next\": [\n \"dist/next/index.d.ts\"\n ],\n \"nuxt\": [\n \"dist/nuxt/index.d.ts\"\n ],\n \"remix\": [\n \"dist/remix/index.d.ts\"\n ],\n \"sveltekit\": [\n \"dist/sveltekit/index.d.ts\"\n ],\n \"vue\": [\n \"dist/vue/index.d.ts\"\n ]\n }\n },\n \"scripts\": {\n \"build\": \"tsup && pnpm copy-astro\",\n \"copy-astro\": \"cp -R src/astro dist/\",\n \"dev\": \"pnpm copy-astro && tsup --watch\",\n \"postinstall\": \"node scripts/postinstall.mjs\",\n \"lint\": \"eslint .\",\n \"lint-fix\": \"eslint . --fix\",\n \"test\": \"jest\",\n \"type-check\": \"tsc --noEmit\"\n },\n \"devDependencies\": {\n \"@jest/globals\": \"^29.7.0\",\n \"@remix-run/react\": \"^2.5.0\",\n \"@sveltejs/kit\": \"^2.7\",\n \"@swc/core\": \"^1.3.103\",\n \"@swc/jest\": \"^0.2.29\",\n \"@testing-library/jest-dom\": \"^6.6.3\",\n \"@testing-library/react\": \"^16.0.1\",\n \"@types/node\": \"^20.11.4\",\n \"@types/react\": \"^18.2.48\",\n \"copyfiles\": \"^2.4.1\",\n \"jest\": \"^29.7.0\",\n \"jest-environment-jsdom\": \"^29.7.0\",\n \"next\": \"^14.0.4\",\n \"react\": \"^18.2.0\",\n \"react-dom\": \"^18.2.0\",\n \"svelte\": \"^5\",\n \"tsup\": \"7.2.0\",\n \"vue\": \"^3.4.14\",\n \"vue-router\": \"^4.2.5\"\n },\n \"peerDependencies\": {\n \"@sveltejs/kit\": \"^1 || ^2\",\n \"next\": \">= 13\",\n \"react\": \"^18 || ^19 || ^19.0.0-rc\",\n \"svelte\": \">= 4\",\n \"vue\": \"^3\",\n \"vue-router\": \"^4\"\n },\n \"peerDependenciesMeta\": {\n \"@sveltejs/kit\": {\n \"optional\": true\n },\n \"next\": {\n \"optional\": true\n },\n \"react\": {\n \"optional\": true\n },\n \"svelte\": {\n \"optional\": true\n },\n \"vue\": {\n \"optional\": true\n },\n \"vue-router\": {\n \"optional\": true\n }\n }\n}\n","export const initQueue = (): void => {\n // initialize va until script is loaded\n if (window.si) return;\n\n window.si = function a(...params): void {\n (window.siq = window.siq || []).push(params);\n };\n};\n","export function isBrowser(): boolean {\n return typeof window !== 'undefined';\n}\n\nfunction detectEnvironment(): 'development' | 'production' {\n try {\n const env = process.env.NODE_ENV;\n if (env === 'development' || env === 'test') {\n return 'development';\n }\n } catch (e) {\n // do nothing, this is okay\n }\n return 'production';\n}\n\nexport function isProduction(): boolean {\n return detectEnvironment() === 'production';\n}\n\nexport function isDevelopment(): boolean {\n return detectEnvironment() === 'development';\n}\n\nexport function computeRoute(\n pathname: string | null,\n pathParams: Record | null,\n): string | null {\n if (!pathname || !pathParams) {\n return pathname;\n }\n\n let result = pathname;\n try {\n const entries = Object.entries(pathParams);\n // simple keys must be handled first\n for (const [key, value] of entries) {\n if (!Array.isArray(value)) {\n const matcher = turnValueToRegExp(value);\n if (matcher.test(result)) {\n result = result.replace(matcher, `/[${key}]`);\n }\n }\n }\n // array values next\n for (const [key, value] of entries) {\n if (Array.isArray(value)) {\n const matcher = turnValueToRegExp(value.join('/'));\n if (matcher.test(result)) {\n result = result.replace(matcher, `/[...${key}]`);\n }\n }\n }\n return result;\n } catch (e) {\n return pathname;\n }\n}\n\nfunction turnValueToRegExp(value: string): RegExp {\n return new RegExp(`/${escapeRegExp(value)}(?=[/?#]|$)`);\n}\n\nfunction escapeRegExp(string: string): string {\n return string.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n","import { name as packageName, version } from '../package.json';\nimport { initQueue } from './queue';\nimport type { SpeedInsightsProps } from './types';\nimport { isBrowser, isDevelopment, computeRoute } from './utils';\n\nconst SCRIPT_URL = 'https://va.vercel-scripts.com/v1/speed-insights';\nconst PROD_SCRIPT_URL = `${SCRIPT_URL}/script.js`;\nconst DEV_SCRIPT_URL = `${SCRIPT_URL}/script.debug.js`;\nconst PROXY_SCRIPT_URL = '/_vercel/speed-insights/script.js';\n\n/**\n * Injects the Vercel Speed Insights script into the page head and starts tracking page views. Read more in our [documentation](https://vercel.com/docs/speed-insights).\n * @param [props] - Speed Insights options.\n * @param [props.debug] - Whether to enable debug logging in development. Defaults to `true`.\n * @param [props.beforeSend] - A middleware function to modify events before they are sent. Should return the event object or `null` to cancel the event.\n * @param [props.sampleRate] - When setting to 0.5, 50% of the events will be sent to Vercel Speed Insights. Defaults to `1`.\n * @param [props.route] - The dynamic route of the page.\n * @param [props.dsn] - The DSN of the project to send events to. Only required when self-hosting.\n */\nfunction injectSpeedInsights(\n props: SpeedInsightsProps & {\n framework?: string;\n } = {},\n): {\n setRoute: (route: string | null) => void;\n} | null {\n // When route is null, it means that pages router is not ready yet. Will resolve soon\n if (!isBrowser() || props.route === null) return null;\n\n initQueue();\n\n const isSelfHosted = Boolean(props.dsn);\n\n const productionScript = isSelfHosted ? PROD_SCRIPT_URL : PROXY_SCRIPT_URL;\n\n const src =\n props.scriptSrc || (isDevelopment() ? DEV_SCRIPT_URL : productionScript);\n\n if (document.head.querySelector(`script[src*=\"${src}\"]`)) return null;\n\n if (props.beforeSend) {\n window.si?.('beforeSend', props.beforeSend);\n }\n\n const script = document.createElement('script');\n script.src = src;\n script.defer = true;\n script.dataset.sdkn =\n packageName + (props.framework ? `/${props.framework}` : '');\n script.dataset.sdkv = version;\n\n if (props.sampleRate) {\n script.dataset.sampleRate = props.sampleRate.toString();\n }\n if (props.route) {\n script.dataset.route = props.route;\n }\n if (props.endpoint) {\n script.dataset.endpoint = props.endpoint;\n }\n if (props.dsn) {\n script.dataset.dsn = props.dsn;\n }\n if (isDevelopment() && props.debug === false) {\n script.dataset.debug = 'false';\n }\n\n script.onerror = (): void => {\n // eslint-disable-next-line no-console -- Logging is okay here\n console.log(\n `[Vercel Speed Insights] Failed to load script from ${src}. Please check if any content blockers are enabled and try again.`,\n );\n };\n\n document.head.appendChild(script);\n\n return {\n setRoute: (route: string | null): void => {\n script.dataset.route = route ?? undefined;\n },\n };\n}\n\nexport { injectSpeedInsights, computeRoute };\nexport type { SpeedInsightsProps };\n\n// eslint-disable-next-line import/no-default-export -- Allow default export\nexport default {\n injectSpeedInsights,\n computeRoute,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,6BAAAA;AAAA;AAAA;AAAA,mBAAoB;;;ACClB,WAAQ;AACR,cAAW;;;ACFN,IAAM,YAAY,MAAY;AAEnC,MAAI,OAAO;AAAI;AAEf,SAAO,KAAK,SAAS,KAAK,QAAc;AACtC,KAAC,OAAO,MAAM,OAAO,OAAO,CAAC,GAAG,KAAK,MAAM;AAAA,EAC7C;AACF;;;ACPO,SAAS,YAAqB;AACnC,SAAO,OAAO,WAAW;AAC3B;AAEA,SAAS,oBAAkD;AACzD,MAAI;AACF,UAAM,MAAM,QAAQ,IAAI;AACxB,QAAI,QAAQ,iBAAiB,QAAQ,QAAQ;AAC3C,aAAO;AAAA,IACT;AAAA,EACF,SAAS,GAAG;AAAA,EAEZ;AACA,SAAO;AACT;AAMO,SAAS,gBAAyB;AACvC,SAAO,kBAAkB,MAAM;AACjC;;;ACjBA,IAAM,aAAa;AACnB,IAAM,kBAAkB,GAAG,UAAU;AACrC,IAAM,iBAAiB,GAAG,UAAU;AACpC,IAAM,mBAAmB;AAWzB,SAAS,oBACP,QAEI,CAAC,GAGE;AAzBT;AA2BE,MAAI,CAAC,UAAU,KAAK,MAAM,UAAU;AAAM,WAAO;AAEjD,YAAU;AAEV,QAAM,eAAe,QAAQ,MAAM,GAAG;AAEtC,QAAM,m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,CAAC,UAAU;AArBhC,YAAAC;AAuBQ,aAAIA,MAAA,MAAM,UAAN,gBAAAA,IAAa,IAAI;AACnB,wBAAc,SAAS,MAAM,MAAM,EAAE;AAAA,QACvC;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":["injectSpeedInsights","injectSpeedInsights","_a"]} \ No newline at end of file diff --git a/node_modules/@vercel/speed-insights/dist/sveltekit/index.mjs b/node_modules/@vercel/speed-insights/dist/sveltekit/index.mjs new file mode 100644 index 0000000..df673b4 --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/sveltekit/index.mjs @@ -0,0 +1,111 @@ +// src/sveltekit/index.ts +import { get } from "svelte/store"; + +// package.json +var name = "@vercel/speed-insights"; +var version = "1.1.0"; + +// src/queue.ts +var initQueue = () => { + if (window.si) + return; + window.si = function a(...params) { + (window.siq = window.siq || []).push(params); + }; +}; + +// src/utils.ts +function isBrowser() { + return typeof window !== "undefined"; +} +function detectEnvironment() { + try { + const env = process.env.NODE_ENV; + if (env === "development" || env === "test") { + return "development"; + } + } catch (e) { + } + return "production"; +} +function isDevelopment() { + return detectEnvironment() === "development"; +} + +// src/generic.ts +var SCRIPT_URL = "https://va.vercel-scripts.com/v1/speed-insights"; +var PROD_SCRIPT_URL = `${SCRIPT_URL}/script.js`; +var DEV_SCRIPT_URL = `${SCRIPT_URL}/script.debug.js`; +var PROXY_SCRIPT_URL = "/_vercel/speed-insights/script.js"; +function injectSpeedInsights(props = {}) { + var _a; + if (!isBrowser() || props.route === null) + return null; + initQueue(); + const isSelfHosted = Boolean(props.dsn); + const productionScript = isSelfHosted ? PROD_SCRIPT_URL : PROXY_SCRIPT_URL; + const src = props.scriptSrc || (isDevelopment() ? DEV_SCRIPT_URL : productionScript); + if (document.head.querySelector(`script[src*="${src}"]`)) + return null; + if (props.beforeSend) { + (_a = window.si) == null ? void 0 : _a.call(window, "beforeSend", props.beforeSend); + } + const script = document.createElement("script"); + script.src = src; + script.defer = true; + script.dataset.sdkn = name + (props.framework ? `/${props.framework}` : ""); + script.dataset.sdkv = version; + if (props.sampleRate) { + script.dataset.sampleRate = props.sampleRate.toString(); + } + if (props.route) { + script.dataset.route = props.route; + } + if (props.endpoint) { + script.dataset.endpoint = props.endpoint; + } + if (props.dsn) { + script.dataset.dsn = props.dsn; + } + if (isDevelopment() && props.debug === false) { + script.dataset.debug = "false"; + } + script.onerror = () => { + console.log( + `[Vercel Speed Insights] Failed to load script from ${src}. Please check if any content blockers are enabled and try again.` + ); + }; + document.head.appendChild(script); + return { + setRoute: (route) => { + script.dataset.route = route ?? void 0; + } + }; +} + +// src/sveltekit/index.ts +import { page } from "$app/stores"; +import { browser } from "$app/environment"; +function injectSpeedInsights2(props = {}) { + var _a; + if (browser) { + const speedInsights = injectSpeedInsights({ + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- route could be undefined in layout.js file + route: (_a = get(page).route) == null ? void 0 : _a.id, + ...props, + framework: "sveltekit" + }); + if (speedInsights) { + page.subscribe((value) => { + var _a2; + if ((_a2 = value.route) == null ? void 0 : _a2.id) { + speedInsights.setRoute(value.route.id); + } + }); + } + } +} +export { + injectSpeedInsights2 as injectSpeedInsights +}; +//# sourceMappingURL=index.mjs.map \ No newline at end of file diff --git a/node_modules/@vercel/speed-insights/dist/sveltekit/index.mjs.map b/node_modules/@vercel/speed-insights/dist/sveltekit/index.mjs.map new file mode 100644 index 0000000..27f25b0 --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/sveltekit/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/sveltekit/index.ts","../../package.json","../../src/queue.ts","../../src/utils.ts","../../src/generic.ts"],"sourcesContent":["import { get } from 'svelte/store';\nimport {\n injectSpeedInsights as genericInject,\n type SpeedInsightsProps,\n} from '../generic';\nimport { page } from '$app/stores';\nimport { browser } from '$app/environment';\nimport type {} from '@sveltejs/kit'; // don't remove, ensures ambient types for $app/* are loaded\n\nexport function injectSpeedInsights(\n props: Omit = {},\n): void {\n if (browser) {\n const speedInsights = genericInject({\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- route could be undefined in layout.js file\n route: get(page).route?.id,\n ...props,\n framework: 'sveltekit',\n });\n\n if (speedInsights) {\n page.subscribe((value) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- route could be undefined in layout.js file\n if (value.route?.id) {\n speedInsights.setRoute(value.route.id);\n }\n });\n }\n }\n}\n","{\n \"name\": \"@vercel/speed-insights\",\n \"version\": \"1.1.0\",\n \"description\": \"Speed Insights is a tool for measuring web performance and providing suggestions for improvement.\",\n \"keywords\": [\n \"speed-insights\",\n \"vercel\"\n ],\n \"repository\": {\n \"url\": \"github:vercel/speed-insights\",\n \"directory\": \"packages/web\"\n },\n \"license\": \"Apache-2.0\",\n \"exports\": {\n \"./package.json\": \"./package.json\",\n \".\": {\n \"browser\": \"./dist/index.mjs\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\"\n },\n \"./astro\": {\n \"import\": \"./dist/astro/component.ts\"\n },\n \"./next\": {\n \"browser\": \"./dist/next/index.mjs\",\n \"import\": \"./dist/next/index.mjs\",\n \"require\": \"./dist/next/index.js\"\n },\n \"./nuxt\": {\n \"browser\": \"./dist/nuxt/index.mjs\",\n \"import\": \"./dist/nuxt/index.mjs\",\n \"require\": \"./dist/nuxt/index.js\"\n },\n \"./react\": {\n \"browser\": \"./dist/react/index.mjs\",\n \"import\": \"./dist/react/index.mjs\",\n \"require\": \"./dist/react/index.js\"\n },\n \"./remix\": {\n \"browser\": \"./dist/remix/index.mjs\",\n \"import\": \"./dist/remix/index.mjs\",\n \"require\": \"./dist/remix/index.js\"\n },\n \"./sveltekit\": {\n \"svelte\": \"./dist/sveltekit/index.mjs\",\n \"types\": \"./dist/sveltekit/index.d.ts\"\n },\n \"./vue\": {\n \"browser\": \"./dist/vue/index.mjs\",\n \"import\": \"./dist/vue/index.mjs\",\n \"require\": \"./dist/vue/index.js\"\n }\n },\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \"*\": [\n \"dist/index.d.ts\"\n ],\n \"react\": [\n \"dist/react/index.d.ts\"\n ],\n \"next\": [\n \"dist/next/index.d.ts\"\n ],\n \"nuxt\": [\n \"dist/nuxt/index.d.ts\"\n ],\n \"remix\": [\n \"dist/remix/index.d.ts\"\n ],\n \"sveltekit\": [\n \"dist/sveltekit/index.d.ts\"\n ],\n \"vue\": [\n \"dist/vue/index.d.ts\"\n ]\n }\n },\n \"scripts\": {\n \"build\": \"tsup && pnpm copy-astro\",\n \"copy-astro\": \"cp -R src/astro dist/\",\n \"dev\": \"pnpm copy-astro && tsup --watch\",\n \"postinstall\": \"node scripts/postinstall.mjs\",\n \"lint\": \"eslint .\",\n \"lint-fix\": \"eslint . --fix\",\n \"test\": \"jest\",\n \"type-check\": \"tsc --noEmit\"\n },\n \"devDependencies\": {\n \"@jest/globals\": \"^29.7.0\",\n \"@remix-run/react\": \"^2.5.0\",\n \"@sveltejs/kit\": \"^2.7\",\n \"@swc/core\": \"^1.3.103\",\n \"@swc/jest\": \"^0.2.29\",\n \"@testing-library/jest-dom\": \"^6.6.3\",\n \"@testing-library/react\": \"^16.0.1\",\n \"@types/node\": \"^20.11.4\",\n \"@types/react\": \"^18.2.48\",\n \"copyfiles\": \"^2.4.1\",\n \"jest\": \"^29.7.0\",\n \"jest-environment-jsdom\": \"^29.7.0\",\n \"next\": \"^14.0.4\",\n \"react\": \"^18.2.0\",\n \"react-dom\": \"^18.2.0\",\n \"svelte\": \"^5\",\n \"tsup\": \"7.2.0\",\n \"vue\": \"^3.4.14\",\n \"vue-router\": \"^4.2.5\"\n },\n \"peerDependencies\": {\n \"@sveltejs/kit\": \"^1 || ^2\",\n \"next\": \">= 13\",\n \"react\": \"^18 || ^19 || ^19.0.0-rc\",\n \"svelte\": \">= 4\",\n \"vue\": \"^3\",\n \"vue-router\": \"^4\"\n },\n \"peerDependenciesMeta\": {\n \"@sveltejs/kit\": {\n \"optional\": true\n },\n \"next\": {\n \"optional\": true\n },\n \"react\": {\n \"optional\": true\n },\n \"svelte\": {\n \"optional\": true\n },\n \"vue\": {\n \"optional\": true\n },\n \"vue-router\": {\n \"optional\": true\n }\n }\n}\n","export const initQueue = (): void => {\n // initialize va until script is loaded\n if (window.si) return;\n\n window.si = function a(...params): void {\n (window.siq = window.siq || []).push(params);\n };\n};\n","export function isBrowser(): boolean {\n return typeof window !== 'undefined';\n}\n\nfunction detectEnvironment(): 'development' | 'production' {\n try {\n const env = process.env.NODE_ENV;\n if (env === 'development' || env === 'test') {\n return 'development';\n }\n } catch (e) {\n // do nothing, this is okay\n }\n return 'production';\n}\n\nexport function isProduction(): boolean {\n return detectEnvironment() === 'production';\n}\n\nexport function isDevelopment(): boolean {\n return detectEnvironment() === 'development';\n}\n\nexport function computeRoute(\n pathname: string | null,\n pathParams: Record | null,\n): string | null {\n if (!pathname || !pathParams) {\n return pathname;\n }\n\n let result = pathname;\n try {\n const entries = Object.entries(pathParams);\n // simple keys must be handled first\n for (const [key, value] of entries) {\n if (!Array.isArray(value)) {\n const matcher = turnValueToRegExp(value);\n if (matcher.test(result)) {\n result = result.replace(matcher, `/[${key}]`);\n }\n }\n }\n // array values next\n for (const [key, value] of entries) {\n if (Array.isArray(value)) {\n const matcher = turnValueToRegExp(value.join('/'));\n if (matcher.test(result)) {\n result = result.replace(matcher, `/[...${key}]`);\n }\n }\n }\n return result;\n } catch (e) {\n return pathname;\n }\n}\n\nfunction turnValueToRegExp(value: string): RegExp {\n return new RegExp(`/${escapeRegExp(value)}(?=[/?#]|$)`);\n}\n\nfunction escapeRegExp(string: string): string {\n return string.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n","import { name as packageName, version } from '../package.json';\nimport { initQueue } from './queue';\nimport type { SpeedInsightsProps } from './types';\nimport { isBrowser, isDevelopment, computeRoute } from './utils';\n\nconst SCRIPT_URL = 'https://va.vercel-scripts.com/v1/speed-insights';\nconst PROD_SCRIPT_URL = `${SCRIPT_URL}/script.js`;\nconst DEV_SCRIPT_URL = `${SCRIPT_URL}/script.debug.js`;\nconst PROXY_SCRIPT_URL = '/_vercel/speed-insights/script.js';\n\n/**\n * Injects the Vercel Speed Insights script into the page head and starts tracking page views. Read more in our [documentation](https://vercel.com/docs/speed-insights).\n * @param [props] - Speed Insights options.\n * @param [props.debug] - Whether to enable debug logging in development. Defaults to `true`.\n * @param [props.beforeSend] - A middleware function to modify events before they are sent. Should return the event object or `null` to cancel the event.\n * @param [props.sampleRate] - When setting to 0.5, 50% of the events will be sent to Vercel Speed Insights. Defaults to `1`.\n * @param [props.route] - The dynamic route of the page.\n * @param [props.dsn] - The DSN of the project to send events to. Only required when self-hosting.\n */\nfunction injectSpeedInsights(\n props: SpeedInsightsProps & {\n framework?: string;\n } = {},\n): {\n setRoute: (route: string | null) => void;\n} | null {\n // When route is null, it means that pages router is not ready yet. Will resolve soon\n if (!isBrowser() || props.route === null) return null;\n\n initQueue();\n\n const isSelfHosted = Boolean(props.dsn);\n\n const productionScript = isSelfHosted ? PROD_SCRIPT_URL : PROXY_SCRIPT_URL;\n\n const src =\n props.scriptSrc || (isDevelopment() ? DEV_SCRIPT_URL : productionScript);\n\n if (document.head.querySelector(`script[src*=\"${src}\"]`)) return null;\n\n if (props.beforeSend) {\n window.si?.('beforeSend', props.beforeSend);\n }\n\n const script = document.createElement('script');\n script.src = src;\n script.defer = true;\n script.dataset.sdkn =\n packageName + (props.framework ? `/${props.framework}` : '');\n script.dataset.sdkv = version;\n\n if (props.sampleRate) {\n script.dataset.sampleRate = props.sampleRate.toString();\n }\n if (props.route) {\n script.dataset.route = props.route;\n }\n if (props.endpoint) {\n script.dataset.endpoint = props.endpoint;\n }\n if (props.dsn) {\n script.dataset.dsn = props.dsn;\n }\n if (isDevelopment() && props.debug === false) {\n script.dataset.debug = 'false';\n }\n\n script.onerror = (): void => {\n // eslint-disable-next-line no-console -- Logging is okay here\n console.log(\n `[Vercel Speed Insights] Failed to load script from ${src}. Please check if any content blockers are enabled and try again.`,\n );\n };\n\n document.head.appendChild(script);\n\n return {\n setRoute: (route: string | null): void => {\n script.dataset.route = route ?? undefined;\n },\n };\n}\n\nexport { injectSpeedInsights, computeRoute };\nexport type { SpeedInsightsProps };\n\n// eslint-disable-next-line import/no-default-export -- Allow default export\nexport default {\n injectSpeedInsights,\n computeRoute,\n};\n"],"mappings":";AAAA,SAAS,WAAW;;;ACClB,WAAQ;AACR,cAAW;;;ACFN,IAAM,YAAY,MAAY;AAEnC,MAAI,OAAO;AAAI;AAEf,SAAO,KAAK,SAAS,KAAK,QAAc;AACtC,KAAC,OAAO,MAAM,OAAO,OAAO,CAAC,GAAG,KAAK,MAAM;AAAA,EAC7C;AACF;;;ACPO,SAAS,YAAqB;AACnC,SAAO,OAAO,WAAW;AAC3B;AAEA,SAAS,oBAAkD;AACzD,MAAI;AACF,UAAM,MAAM,QAAQ,IAAI;AACxB,QAAI,QAAQ,iBAAiB,QAAQ,QAAQ;AAC3C,aAAO;AAAA,IACT;AAAA,EACF,SAAS,GAAG;AAAA,EAEZ;AACA,SAAO;AACT;AAMO,SAAS,gBAAyB;AACvC,SAAO,kBAAkB,MAAM;AACjC;;;ACjBA,IAAM,aAAa;AACnB,IAAM,kBAAkB,GAAG,UAAU;AACrC,IAAM,iBAAiB,GAAG,UAAU;AACpC,IAAM,mBAAmB;AAWzB,SAAS,oBACP,QAEI,CAAC,GAGE;AAzBT;AA2BE,MAAI,CAAC,UAAU,KAAK,MAAM,UAAU;AAAM,WAAO;AAEjD,YAAU;AAEV,QAAM,eAAe,QAAQ,MAAM,GAAG;AAEtC,QAAM,mBAAmB,eAAe,kBAAkB;AAE1D,QAAM,MACJ,MAAM,cAAc,cAAc,IAAI,iBAAiB;AAEzD,MAAI,SAAS,KAAK,cAAc,gBAAgB,GAAG,IAAI;AAAG,WAAO;AAEjE,MAAI,MAAM,YAAY;AACpB,iBAAO,OAAP,gCAAY,cAAc,MAAM;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 No newline at end of file diff --git a/node_modules/@vercel/speed-insights/dist/vue/index.d.mts b/node_modules/@vercel/speed-insights/dist/vue/index.d.mts new file mode 100644 index 0000000..f2f121b --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/vue/index.d.mts @@ -0,0 +1,3 @@ +declare const SpeedInsights: any; + +export { SpeedInsights }; diff --git a/node_modules/@vercel/speed-insights/dist/vue/index.d.ts b/node_modules/@vercel/speed-insights/dist/vue/index.d.ts new file mode 100644 index 0000000..f2f121b --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/vue/index.d.ts @@ -0,0 +1,3 @@ +declare const SpeedInsights: any; + +export { SpeedInsights }; diff --git a/node_modules/@vercel/speed-insights/dist/vue/index.js b/node_modules/@vercel/speed-insights/dist/vue/index.js new file mode 100644 index 0000000..36c3203 --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/vue/index.js @@ -0,0 +1,182 @@ +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __export = (target, all) => { + for (var name2 in all) + __defProp(target, name2, { get: all[name2], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/vue/index.ts +var vue_exports = {}; +__export(vue_exports, { + SpeedInsights: () => SpeedInsights +}); +module.exports = __toCommonJS(vue_exports); + +// src/vue/create-component.ts +var import_vue = require("vue"); +var import_vue_router = require("vue-router"); + +// package.json +var name = "@vercel/speed-insights"; +var version = "1.1.0"; + +// src/queue.ts +var initQueue = () => { + if (window.si) + return; + window.si = function a(...params) { + (window.siq = window.siq || []).push(params); + }; +}; + +// src/utils.ts +function isBrowser() { + return typeof window !== "undefined"; +} +function detectEnvironment() { + try { + const env = process.env.NODE_ENV; + if (env === "development" || env === "test") { + return "development"; + } + } catch (e) { + } + return "production"; +} +function isDevelopment() { + return detectEnvironment() === "development"; +} +function computeRoute(pathname, pathParams) { + if (!pathname || !pathParams) { + return pathname; + } + let result = pathname; + try { + const entries = Object.entries(pathParams); + for (const [key, value] of entries) { + if (!Array.isArray(value)) { + const matcher = turnValueToRegExp(value); + if (matcher.test(result)) { + result = result.replace(matcher, `/[${key}]`); + } + } + } + for (const [key, value] of entries) { + if (Array.isArray(value)) { + const matcher = turnValueToRegExp(value.join("/")); + if (matcher.test(result)) { + result = result.replace(matcher, `/[...${key}]`); + } + } + } + return result; + } catch (e) { + return pathname; + } +} +function turnValueToRegExp(value) { + return new RegExp(`/${escapeRegExp(value)}(?=[/?#]|$)`); +} +function escapeRegExp(string) { + return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); +} + +// src/generic.ts +var SCRIPT_URL = "https://va.vercel-scripts.com/v1/speed-insights"; +var PROD_SCRIPT_URL = `${SCRIPT_URL}/script.js`; +var DEV_SCRIPT_URL = `${SCRIPT_URL}/script.debug.js`; +var PROXY_SCRIPT_URL = "/_vercel/speed-insights/script.js"; +function injectSpeedInsights(props = {}) { + var _a; + if (!isBrowser() || props.route === null) + return null; + initQueue(); + const isSelfHosted = Boolean(props.dsn); + const productionScript = isSelfHosted ? PROD_SCRIPT_URL : PROXY_SCRIPT_URL; + const src = props.scriptSrc || (isDevelopment() ? DEV_SCRIPT_URL : productionScript); + if (document.head.querySelector(`script[src*="${src}"]`)) + return null; + if (props.beforeSend) { + (_a = window.si) == null ? void 0 : _a.call(window, "beforeSend", props.beforeSend); + } + const script = document.createElement("script"); + script.src = src; + script.defer = true; + script.dataset.sdkn = name + (props.framework ? `/${props.framework}` : ""); + script.dataset.sdkv = version; + if (props.sampleRate) { + script.dataset.sampleRate = props.sampleRate.toString(); + } + if (props.route) { + script.dataset.route = props.route; + } + if (props.endpoint) { + script.dataset.endpoint = props.endpoint; + } + if (props.dsn) { + script.dataset.dsn = props.dsn; + } + if (isDevelopment() && props.debug === false) { + script.dataset.debug = "false"; + } + script.onerror = () => { + console.log( + `[Vercel Speed Insights] Failed to load script from ${src}. Please check if any content blockers are enabled and try again.` + ); + }; + document.head.appendChild(script); + return { + setRoute: (route) => { + script.dataset.route = route ?? void 0; + } + }; +} + +// src/vue/create-component.ts +function createComponent(framework = "vue") { + return (0, import_vue.defineComponent)({ + props: [ + "dsn", + "sampleRate", + "beforeSend", + "debug", + "scriptSrc", + "endpoint" + ], + setup(props) { + const route = (0, import_vue_router.useRoute)(); + const configure = injectSpeedInsights({ ...props, framework }); + if (route && configure) { + const changeRoute = () => { + configure.setRoute(computeRoute(route.path, route.params)); + }; + changeRoute(); + (0, import_vue.watch)(route, changeRoute); + } + }, + // Vue component must have a render function, or a template. + render() { + return null; + } + }); +} + +// src/vue/index.ts +var SpeedInsights = createComponent(); +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + SpeedInsights +}); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/node_modules/@vercel/speed-insights/dist/vue/index.js.map b/node_modules/@vercel/speed-insights/dist/vue/index.js.map new file mode 100644 index 0000000..8f5b1fe --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/vue/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/vue/index.ts","../../src/vue/create-component.ts","../../package.json","../../src/queue.ts","../../src/utils.ts","../../src/generic.ts"],"sourcesContent":["import { createComponent } from './create-component';\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- vue's defineComponent return type is any\nexport const SpeedInsights = createComponent();\n","import { defineComponent, watch } from 'vue';\n// for barebone vue project, vite will issue a warning since 'vue-router' import can't be resolved,\nimport { useRoute } from 'vue-router';\nimport { injectSpeedInsights, type SpeedInsightsProps } from '../generic';\nimport { computeRoute } from '../utils';\n\nexport function createComponent(\n framework = 'vue',\n): ReturnType {\n return defineComponent({\n props: [\n 'dsn',\n 'sampleRate',\n 'beforeSend',\n 'debug',\n 'scriptSrc',\n 'endpoint',\n ],\n setup(props: Omit) {\n const route = useRoute();\n const configure = injectSpeedInsights({ ...props, framework });\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- route is undefined for barebone vue project\n if (route && configure) {\n const changeRoute = (): void => {\n configure.setRoute(computeRoute(route.path, route.params));\n };\n\n changeRoute();\n watch(route, changeRoute);\n }\n },\n // Vue component must have a render function, or a template.\n render() {\n return null;\n },\n });\n}\n","{\n \"name\": \"@vercel/speed-insights\",\n \"version\": \"1.1.0\",\n \"description\": \"Speed Insights is a tool for measuring web performance and providing suggestions for improvement.\",\n \"keywords\": [\n \"speed-insights\",\n \"vercel\"\n ],\n \"repository\": {\n \"url\": \"github:vercel/speed-insights\",\n \"directory\": \"packages/web\"\n },\n \"license\": \"Apache-2.0\",\n \"exports\": {\n \"./package.json\": \"./package.json\",\n \".\": {\n \"browser\": \"./dist/index.mjs\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\"\n },\n \"./astro\": {\n \"import\": \"./dist/astro/component.ts\"\n },\n \"./next\": {\n \"browser\": \"./dist/next/index.mjs\",\n \"import\": \"./dist/next/index.mjs\",\n \"require\": \"./dist/next/index.js\"\n },\n \"./nuxt\": {\n \"browser\": \"./dist/nuxt/index.mjs\",\n \"import\": \"./dist/nuxt/index.mjs\",\n \"require\": \"./dist/nuxt/index.js\"\n },\n \"./react\": {\n \"browser\": \"./dist/react/index.mjs\",\n \"import\": \"./dist/react/index.mjs\",\n \"require\": \"./dist/react/index.js\"\n },\n \"./remix\": {\n \"browser\": \"./dist/remix/index.mjs\",\n \"import\": \"./dist/remix/index.mjs\",\n \"require\": \"./dist/remix/index.js\"\n },\n \"./sveltekit\": {\n \"svelte\": \"./dist/sveltekit/index.mjs\",\n \"types\": \"./dist/sveltekit/index.d.ts\"\n },\n \"./vue\": {\n \"browser\": \"./dist/vue/index.mjs\",\n \"import\": \"./dist/vue/index.mjs\",\n \"require\": \"./dist/vue/index.js\"\n }\n },\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \"*\": [\n \"dist/index.d.ts\"\n ],\n \"react\": [\n \"dist/react/index.d.ts\"\n ],\n \"next\": [\n \"dist/next/index.d.ts\"\n ],\n \"nuxt\": [\n \"dist/nuxt/index.d.ts\"\n ],\n \"remix\": [\n \"dist/remix/index.d.ts\"\n ],\n \"sveltekit\": [\n \"dist/sveltekit/index.d.ts\"\n ],\n \"vue\": [\n \"dist/vue/index.d.ts\"\n ]\n }\n },\n \"scripts\": {\n \"build\": \"tsup && pnpm copy-astro\",\n \"copy-astro\": \"cp -R src/astro dist/\",\n \"dev\": \"pnpm copy-astro && tsup --watch\",\n \"postinstall\": \"node scripts/postinstall.mjs\",\n \"lint\": \"eslint .\",\n \"lint-fix\": \"eslint . --fix\",\n \"test\": \"jest\",\n \"type-check\": \"tsc --noEmit\"\n },\n \"devDependencies\": {\n \"@jest/globals\": \"^29.7.0\",\n \"@remix-run/react\": \"^2.5.0\",\n \"@sveltejs/kit\": \"^2.7\",\n \"@swc/core\": \"^1.3.103\",\n \"@swc/jest\": \"^0.2.29\",\n \"@testing-library/jest-dom\": \"^6.6.3\",\n \"@testing-library/react\": \"^16.0.1\",\n \"@types/node\": \"^20.11.4\",\n \"@types/react\": \"^18.2.48\",\n \"copyfiles\": \"^2.4.1\",\n \"jest\": \"^29.7.0\",\n \"jest-environment-jsdom\": \"^29.7.0\",\n \"next\": \"^14.0.4\",\n \"react\": \"^18.2.0\",\n \"react-dom\": \"^18.2.0\",\n \"svelte\": \"^5\",\n \"tsup\": \"7.2.0\",\n \"vue\": \"^3.4.14\",\n \"vue-router\": \"^4.2.5\"\n },\n \"peerDependencies\": {\n \"@sveltejs/kit\": \"^1 || ^2\",\n \"next\": \">= 13\",\n \"react\": \"^18 || ^19 || ^19.0.0-rc\",\n \"svelte\": \">= 4\",\n \"vue\": \"^3\",\n \"vue-router\": \"^4\"\n },\n \"peerDependenciesMeta\": {\n \"@sveltejs/kit\": {\n \"optional\": true\n },\n \"next\": {\n \"optional\": true\n },\n \"react\": {\n \"optional\": true\n },\n \"svelte\": {\n \"optional\": true\n },\n \"vue\": {\n \"optional\": true\n },\n \"vue-router\": {\n \"optional\": true\n }\n }\n}\n","export const initQueue = (): void => {\n // initialize va until script is loaded\n if (window.si) return;\n\n window.si = function a(...params): void {\n (window.siq = window.siq || []).push(params);\n };\n};\n","export function isBrowser(): boolean {\n return typeof window !== 'undefined';\n}\n\nfunction detectEnvironment(): 'development' | 'production' {\n try {\n const env = process.env.NODE_ENV;\n if (env === 'development' || env === 'test') {\n return 'development';\n }\n } catch (e) {\n // do nothing, this is okay\n }\n return 'production';\n}\n\nexport function isProduction(): boolean {\n return detectEnvironment() === 'production';\n}\n\nexport function isDevelopment(): boolean {\n return detectEnvironment() === 'development';\n}\n\nexport function computeRoute(\n pathname: string | null,\n pathParams: Record | null,\n): string | null {\n if (!pathname || !pathParams) {\n return pathname;\n }\n\n let result = pathname;\n try {\n const entries = Object.entries(pathParams);\n // simple keys must be handled first\n for (const [key, value] of entries) {\n if (!Array.isArray(value)) {\n const matcher = turnValueToRegExp(value);\n if (matcher.test(result)) {\n result = result.replace(matcher, `/[${key}]`);\n }\n }\n }\n // array values next\n for (const [key, value] of entries) {\n if (Array.isArray(value)) {\n const matcher = turnValueToRegExp(value.join('/'));\n if (matcher.test(result)) {\n result = result.replace(matcher, `/[...${key}]`);\n }\n }\n }\n return result;\n } catch (e) {\n return pathname;\n }\n}\n\nfunction turnValueToRegExp(value: string): RegExp {\n return new RegExp(`/${escapeRegExp(value)}(?=[/?#]|$)`);\n}\n\nfunction escapeRegExp(string: string): string {\n return string.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n","import { name as packageName, version } from '../package.json';\nimport { initQueue } from './queue';\nimport type { SpeedInsightsProps } from './types';\nimport { isBrowser, isDevelopment, computeRoute } from './utils';\n\nconst SCRIPT_URL = 'https://va.vercel-scripts.com/v1/speed-insights';\nconst PROD_SCRIPT_URL = `${SCRIPT_URL}/script.js`;\nconst DEV_SCRIPT_URL = `${SCRIPT_URL}/script.debug.js`;\nconst PROXY_SCRIPT_URL = '/_vercel/speed-insights/script.js';\n\n/**\n * Injects the Vercel Speed Insights script into the page head and starts tracking page views. Read more in our [documentation](https://vercel.com/docs/speed-insights).\n * @param [props] - Speed Insights options.\n * @param [props.debug] - Whether to enable debug logging in development. Defaults to `true`.\n * @param [props.beforeSend] - A middleware function to modify events before they are sent. Should return the event object or `null` to cancel the event.\n * @param [props.sampleRate] - When setting to 0.5, 50% of the events will be sent to Vercel Speed Insights. Defaults to `1`.\n * @param [props.route] - The dynamic route of the page.\n * @param [props.dsn] - The DSN of the project to send events to. Only required when self-hosting.\n */\nfunction injectSpeedInsights(\n props: SpeedInsightsProps & {\n framework?: string;\n } = {},\n): {\n setRoute: (route: string | null) => void;\n} | null {\n // When route is null, it means that pages router is not ready yet. Will resolve soon\n if (!isBrowser() || props.route === null) return null;\n\n initQueue();\n\n const isSelfHosted = Boolean(props.dsn);\n\n const productionScript = isSelfHosted ? PROD_SCRIPT_URL : PROXY_SCRIPT_URL;\n\n const src =\n props.scriptSrc || (isDevelopment() ? DEV_SCRIPT_URL : productionScript);\n\n if (document.head.querySelector(`script[src*=\"${src}\"]`)) return null;\n\n if (props.beforeSend) {\n window.si?.('beforeSend', props.beforeSend);\n }\n\n const script = document.createElement('script');\n script.src = src;\n script.defer = true;\n script.dataset.sdkn =\n packageName + (props.framework ? `/${props.framework}` : '');\n script.dataset.sdkv = version;\n\n if (props.sampleRate) {\n script.dataset.sampleRate = props.sampleRate.toString();\n }\n if (props.route) {\n script.dataset.route = props.route;\n }\n if (props.endpoint) {\n script.dataset.endpoint = props.endpoint;\n }\n if (props.dsn) {\n script.dataset.dsn = props.dsn;\n }\n if (isDevelopment() && props.debug === false) {\n script.dataset.debug = 'false';\n }\n\n script.onerror = (): void => {\n // eslint-disable-next-line no-console -- Logging is okay here\n console.log(\n `[Vercel Speed Insights] Failed to load script from ${src}. Please check if any content blockers are enabled and try again.`,\n );\n };\n\n document.head.appendChild(script);\n\n return {\n setRoute: (route: string | null): void => {\n script.dataset.route = route ?? undefined;\n },\n };\n}\n\nexport { injectSpeedInsights, computeRoute };\nexport type { SpeedInsightsProps };\n\n// eslint-disable-next-line import/no-default-export -- Allow default export\nexport default {\n injectSpeedInsights,\n computeRoute,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iBAAuC;AAEvC,wBAAyB;;;ACDvB,WAAQ;AACR,cAAW;;;ACFN,IAAM,YAAY,MAAY;AAEnC,MAAI,OAAO;AAAI;AAEf,SAAO,KAAK,SAAS,KAAK,QAAc;AACtC,KAAC,OAAO,MAAM,OAAO,OAAO,CAAC,GAAG,KAAK,MAAM;AAAA,EAC7C;AACF;;;ACPO,SAAS,YAAqB;AACnC,SAAO,OAAO,WAAW;AAC3B;AAEA,SAAS,oBAAkD;AACzD,MAAI;AACF,UAAM,MAAM,QAAQ,IAAI;AACxB,QAAI,QAAQ,iBAAiB,QAAQ,QAAQ;AAC3C,aAAO;AAAA,IACT;AAAA,EACF,SAAS,GAAG;AAAA,EAEZ;AACA,SAAO;AACT;AAMO,SAAS,gBAAyB;AACvC,SAAO,kBAAkB,MAAM;AACjC;AAEO,SAAS,aACd,UACA,YACe;AACf,MAAI,CAAC,YAAY,CAAC,YAAY;AAC5B,WAAO;AAAA,EACT;AAEA,MAAI,SAAS;AACb,MAAI;AACF,UAAM,UAAU,OAAO,QAAQ,UAAU;AAEzC,eAAW,CAAC,KAAK,KAAK,KAAK,SAAS;AAClC,UAAI,CAAC,MAAM,QAAQ,KAAK,GAAG;AACzB,cAAM,UAAU,kBAAkB,KAAK;AACvC,YAAI,QAAQ,KAAK,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I,MAAM,YAAY;AACpB,WAAO,QAAQ,aAAa,MAAM,WAAW,SAAS;AAAA,EACxD;AACA,MAAI,MAAM,OAAO;AACf,WAAO,QAAQ,QAAQ,MAAM;AAAA,EAC/B;AACA,MAAI,MAAM,UAAU;AAClB,WAAO,QAAQ,WAAW,MAAM;AAAA,EAClC;AACA,MAAI,MAAM,KAAK;AACb,WAAO,QAAQ,MAAM,MAAM;AAAA,EAC7B;AACA,MAAI,cAAc,KAAK,MAAM,UAAU,OAAO;AAC5C,WAAO,QAAQ,QAAQ;AAAA,EACzB;AAEA,SAAO,UAAU,MAAY;AAE3B,YAAQ;AAAA,MACN,sDAAsD,GAAG;AAAA,IAC3D;AAAA,EACF;AAEA,WAAS,KAAK,YAAY,MAAM;AAEhC,SAAO;AAAA,IACL,UAAU,CAAC,UAA+B;AACxC,aAAO,QAAQ,QAAQ,SAAS;AAAA,IAClC;AAAA,EACF;AACF;;;AJ3EO,SAAS,gBACd,YAAY,OACwB;AACpC,aAAO,4BAAgB;AAAA,IACrB,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,MAAM,OAA8C;AAClD,YAAM,YAAQ,4BAAS;AACvB,YAAM,YAAY,oBAAoB,EAAE,GAAG,OAAO,UAAU,CAAC;AAE7D,UAAI,SAAS,WAAW;AACtB,cAAM,cAAc,MAAY;AAC9B,oBAAU,SAAS,aAAa,MAAM,MAAM,MAAM,MAAM,CAAC;AAAA,QAC3D;AAEA,oBAAY;AACZ,8BAAM,OAAO,WAAW;AAAA,MAC1B;AAAA,IACF;AAAA;AAAA,IAEA,SAAS;AACP,aAAO;AAAA,IACT;AAAA,EACF,CAAC;AACH;;;ADjCO,IAAM,gBAAgB,gBAAgB;","names":[]} \ No newline at end of file diff --git a/node_modules/@vercel/speed-insights/dist/vue/index.mjs b/node_modules/@vercel/speed-insights/dist/vue/index.mjs new file mode 100644 index 0000000..506d11f --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/vue/index.mjs @@ -0,0 +1,155 @@ +// src/vue/create-component.ts +import { defineComponent, watch } from "vue"; +import { useRoute } from "vue-router"; + +// package.json +var name = "@vercel/speed-insights"; +var version = "1.1.0"; + +// src/queue.ts +var initQueue = () => { + if (window.si) + return; + window.si = function a(...params) { + (window.siq = window.siq || []).push(params); + }; +}; + +// src/utils.ts +function isBrowser() { + return typeof window !== "undefined"; +} +function detectEnvironment() { + try { + const env = process.env.NODE_ENV; + if (env === "development" || env === "test") { + return "development"; + } + } catch (e) { + } + return "production"; +} +function isDevelopment() { + return detectEnvironment() === "development"; +} +function computeRoute(pathname, pathParams) { + if (!pathname || !pathParams) { + return pathname; + } + let result = pathname; + try { + const entries = Object.entries(pathParams); + for (const [key, value] of entries) { + if (!Array.isArray(value)) { + const matcher = turnValueToRegExp(value); + if (matcher.test(result)) { + result = result.replace(matcher, `/[${key}]`); + } + } + } + for (const [key, value] of entries) { + if (Array.isArray(value)) { + const matcher = turnValueToRegExp(value.join("/")); + if (matcher.test(result)) { + result = result.replace(matcher, `/[...${key}]`); + } + } + } + return result; + } catch (e) { + return pathname; + } +} +function turnValueToRegExp(value) { + return new RegExp(`/${escapeRegExp(value)}(?=[/?#]|$)`); +} +function escapeRegExp(string) { + return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); +} + +// src/generic.ts +var SCRIPT_URL = "https://va.vercel-scripts.com/v1/speed-insights"; +var PROD_SCRIPT_URL = `${SCRIPT_URL}/script.js`; +var DEV_SCRIPT_URL = `${SCRIPT_URL}/script.debug.js`; +var PROXY_SCRIPT_URL = "/_vercel/speed-insights/script.js"; +function injectSpeedInsights(props = {}) { + var _a; + if (!isBrowser() || props.route === null) + return null; + initQueue(); + const isSelfHosted = Boolean(props.dsn); + const productionScript = isSelfHosted ? PROD_SCRIPT_URL : PROXY_SCRIPT_URL; + const src = props.scriptSrc || (isDevelopment() ? DEV_SCRIPT_URL : productionScript); + if (document.head.querySelector(`script[src*="${src}"]`)) + return null; + if (props.beforeSend) { + (_a = window.si) == null ? void 0 : _a.call(window, "beforeSend", props.beforeSend); + } + const script = document.createElement("script"); + script.src = src; + script.defer = true; + script.dataset.sdkn = name + (props.framework ? `/${props.framework}` : ""); + script.dataset.sdkv = version; + if (props.sampleRate) { + script.dataset.sampleRate = props.sampleRate.toString(); + } + if (props.route) { + script.dataset.route = props.route; + } + if (props.endpoint) { + script.dataset.endpoint = props.endpoint; + } + if (props.dsn) { + script.dataset.dsn = props.dsn; + } + if (isDevelopment() && props.debug === false) { + script.dataset.debug = "false"; + } + script.onerror = () => { + console.log( + `[Vercel Speed Insights] Failed to load script from ${src}. Please check if any content blockers are enabled and try again.` + ); + }; + document.head.appendChild(script); + return { + setRoute: (route) => { + script.dataset.route = route ?? void 0; + } + }; +} + +// src/vue/create-component.ts +function createComponent(framework = "vue") { + return defineComponent({ + props: [ + "dsn", + "sampleRate", + "beforeSend", + "debug", + "scriptSrc", + "endpoint" + ], + setup(props) { + const route = useRoute(); + const configure = injectSpeedInsights({ ...props, framework }); + if (route && configure) { + const changeRoute = () => { + configure.setRoute(computeRoute(route.path, route.params)); + }; + changeRoute(); + watch(route, changeRoute); + } + }, + // Vue component must have a render function, or a template. + render() { + return null; + } + }); +} + +// src/vue/index.ts +var SpeedInsights = createComponent(); +export { + SpeedInsights +}; +//# sourceMappingURL=index.mjs.map \ No newline at end of file diff --git a/node_modules/@vercel/speed-insights/dist/vue/index.mjs.map b/node_modules/@vercel/speed-insights/dist/vue/index.mjs.map new file mode 100644 index 0000000..2e2772e --- /dev/null +++ b/node_modules/@vercel/speed-insights/dist/vue/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/vue/create-component.ts","../../package.json","../../src/queue.ts","../../src/utils.ts","../../src/generic.ts","../../src/vue/index.ts"],"sourcesContent":["import { defineComponent, watch } from 'vue';\n// for barebone vue project, vite will issue a warning since 'vue-router' import can't be resolved,\nimport { useRoute } from 'vue-router';\nimport { injectSpeedInsights, type SpeedInsightsProps } from '../generic';\nimport { computeRoute } from '../utils';\n\nexport function createComponent(\n framework = 'vue',\n): ReturnType {\n return defineComponent({\n props: [\n 'dsn',\n 'sampleRate',\n 'beforeSend',\n 'debug',\n 'scriptSrc',\n 'endpoint',\n ],\n setup(props: Omit) {\n const route = useRoute();\n const configure = injectSpeedInsights({ ...props, framework });\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- route is undefined for barebone vue project\n if (route && configure) {\n const changeRoute = (): void => {\n configure.setRoute(computeRoute(route.path, route.params));\n };\n\n changeRoute();\n watch(route, changeRoute);\n }\n },\n // Vue component must have a render function, or a template.\n render() {\n return null;\n },\n });\n}\n","{\n \"name\": \"@vercel/speed-insights\",\n \"version\": \"1.1.0\",\n \"description\": \"Speed Insights is a tool for measuring web performance and providing suggestions for improvement.\",\n \"keywords\": [\n \"speed-insights\",\n \"vercel\"\n ],\n \"repository\": {\n \"url\": \"github:vercel/speed-insights\",\n \"directory\": \"packages/web\"\n },\n \"license\": \"Apache-2.0\",\n \"exports\": {\n \"./package.json\": \"./package.json\",\n \".\": {\n \"browser\": \"./dist/index.mjs\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\"\n },\n \"./astro\": {\n \"import\": \"./dist/astro/component.ts\"\n },\n \"./next\": {\n \"browser\": \"./dist/next/index.mjs\",\n \"import\": \"./dist/next/index.mjs\",\n \"require\": \"./dist/next/index.js\"\n },\n \"./nuxt\": {\n \"browser\": \"./dist/nuxt/index.mjs\",\n \"import\": \"./dist/nuxt/index.mjs\",\n \"require\": \"./dist/nuxt/index.js\"\n },\n \"./react\": {\n \"browser\": \"./dist/react/index.mjs\",\n \"import\": \"./dist/react/index.mjs\",\n \"require\": \"./dist/react/index.js\"\n },\n \"./remix\": {\n \"browser\": \"./dist/remix/index.mjs\",\n \"import\": \"./dist/remix/index.mjs\",\n \"require\": \"./dist/remix/index.js\"\n },\n \"./sveltekit\": {\n \"svelte\": \"./dist/sveltekit/index.mjs\",\n \"types\": \"./dist/sveltekit/index.d.ts\"\n },\n \"./vue\": {\n \"browser\": \"./dist/vue/index.mjs\",\n \"import\": \"./dist/vue/index.mjs\",\n \"require\": \"./dist/vue/index.js\"\n }\n },\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \"*\": [\n \"dist/index.d.ts\"\n ],\n \"react\": [\n \"dist/react/index.d.ts\"\n ],\n \"next\": [\n \"dist/next/index.d.ts\"\n ],\n \"nuxt\": [\n \"dist/nuxt/index.d.ts\"\n ],\n \"remix\": [\n \"dist/remix/index.d.ts\"\n ],\n \"sveltekit\": [\n \"dist/sveltekit/index.d.ts\"\n ],\n \"vue\": [\n \"dist/vue/index.d.ts\"\n ]\n }\n },\n \"scripts\": {\n \"build\": \"tsup && pnpm copy-astro\",\n \"copy-astro\": \"cp -R src/astro dist/\",\n \"dev\": \"pnpm copy-astro && tsup --watch\",\n \"postinstall\": \"node scripts/postinstall.mjs\",\n \"lint\": \"eslint .\",\n \"lint-fix\": \"eslint . --fix\",\n \"test\": \"jest\",\n \"type-check\": \"tsc --noEmit\"\n },\n \"devDependencies\": {\n \"@jest/globals\": \"^29.7.0\",\n \"@remix-run/react\": \"^2.5.0\",\n \"@sveltejs/kit\": \"^2.7\",\n \"@swc/core\": \"^1.3.103\",\n \"@swc/jest\": \"^0.2.29\",\n \"@testing-library/jest-dom\": \"^6.6.3\",\n \"@testing-library/react\": \"^16.0.1\",\n \"@types/node\": \"^20.11.4\",\n \"@types/react\": \"^18.2.48\",\n \"copyfiles\": \"^2.4.1\",\n \"jest\": \"^29.7.0\",\n \"jest-environment-jsdom\": \"^29.7.0\",\n \"next\": \"^14.0.4\",\n \"react\": \"^18.2.0\",\n \"react-dom\": \"^18.2.0\",\n \"svelte\": \"^5\",\n \"tsup\": \"7.2.0\",\n \"vue\": \"^3.4.14\",\n \"vue-router\": \"^4.2.5\"\n },\n \"peerDependencies\": {\n \"@sveltejs/kit\": \"^1 || ^2\",\n \"next\": \">= 13\",\n \"react\": \"^18 || ^19 || ^19.0.0-rc\",\n \"svelte\": \">= 4\",\n \"vue\": \"^3\",\n \"vue-router\": \"^4\"\n },\n \"peerDependenciesMeta\": {\n \"@sveltejs/kit\": {\n \"optional\": true\n },\n \"next\": {\n \"optional\": true\n },\n \"react\": {\n \"optional\": true\n },\n \"svelte\": {\n \"optional\": true\n },\n \"vue\": {\n \"optional\": true\n },\n \"vue-router\": {\n \"optional\": true\n }\n }\n}\n","export const initQueue = (): void => {\n // initialize va until script is loaded\n if (window.si) return;\n\n window.si = function a(...params): void {\n (window.siq = window.siq || []).push(params);\n };\n};\n","export function isBrowser(): boolean {\n return typeof window !== 'undefined';\n}\n\nfunction detectEnvironment(): 'development' | 'production' {\n try {\n const env = process.env.NODE_ENV;\n if (env === 'development' || env === 'test') {\n return 'development';\n }\n } catch (e) {\n // do nothing, this is okay\n }\n return 'production';\n}\n\nexport function isProduction(): boolean {\n return detectEnvironment() === 'production';\n}\n\nexport function isDevelopment(): boolean {\n return detectEnvironment() === 'development';\n}\n\nexport function computeRoute(\n pathname: string | null,\n pathParams: Record | null,\n): string | null {\n if (!pathname || !pathParams) {\n return pathname;\n }\n\n let result = pathname;\n try {\n const entries = Object.entries(pathParams);\n // simple keys must be handled first\n for (const [key, value] of entries) {\n if (!Array.isArray(value)) {\n const matcher = turnValueToRegExp(value);\n if (matcher.test(result)) {\n result = result.replace(matcher, `/[${key}]`);\n }\n }\n }\n // array values next\n for (const [key, value] of entries) {\n if (Array.isArray(value)) {\n const matcher = turnValueToRegExp(value.join('/'));\n if (matcher.test(result)) {\n result = result.replace(matcher, `/[...${key}]`);\n }\n }\n }\n return result;\n } catch (e) {\n return pathname;\n }\n}\n\nfunction turnValueToRegExp(value: string): RegExp {\n return new RegExp(`/${escapeRegExp(value)}(?=[/?#]|$)`);\n}\n\nfunction escapeRegExp(string: string): string {\n return string.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n","import { name as packageName, version } from '../package.json';\nimport { initQueue } from './queue';\nimport type { SpeedInsightsProps } from './types';\nimport { isBrowser, isDevelopment, computeRoute } from './utils';\n\nconst SCRIPT_URL = 'https://va.vercel-scripts.com/v1/speed-insights';\nconst PROD_SCRIPT_URL = `${SCRIPT_URL}/script.js`;\nconst DEV_SCRIPT_URL = `${SCRIPT_URL}/script.debug.js`;\nconst PROXY_SCRIPT_URL = '/_vercel/speed-insights/script.js';\n\n/**\n * Injects the Vercel Speed Insights script into the page head and starts tracking page views. Read more in our [documentation](https://vercel.com/docs/speed-insights).\n * @param [props] - Speed Insights options.\n * @param [props.debug] - Whether to enable debug logging in development. Defaults to `true`.\n * @param [props.beforeSend] - A middleware function to modify events before they are sent. Should return the event object or `null` to cancel the event.\n * @param [props.sampleRate] - When setting to 0.5, 50% of the events will be sent to Vercel Speed Insights. Defaults to `1`.\n * @param [props.route] - The dynamic route of the page.\n * @param [props.dsn] - The DSN of the project to send events to. Only required when self-hosting.\n */\nfunction injectSpeedInsights(\n props: SpeedInsightsProps & {\n framework?: string;\n } = {},\n): {\n setRoute: (route: string | null) => void;\n} | null {\n // When route is null, it means that pages router is not ready yet. Will resolve soon\n if (!isBrowser() || props.route === null) return null;\n\n initQueue();\n\n const isSelfHosted = Boolean(props.dsn);\n\n const productionScript = isSelfHosted ? PROD_SCRIPT_URL : PROXY_SCRIPT_URL;\n\n const src =\n props.scriptSrc || (isDevelopment() ? DEV_SCRIPT_URL : productionScript);\n\n if (document.head.querySelector(`script[src*=\"${src}\"]`)) return null;\n\n if (props.beforeSend) {\n window.si?.('beforeSend', props.beforeSend);\n }\n\n const script = document.createElement('script');\n script.src = src;\n script.defer = true;\n script.dataset.sdkn =\n packageName + (props.framework ? `/${props.framework}` : '');\n script.dataset.sdkv = version;\n\n if (props.sampleRate) {\n script.dataset.sampleRate = props.sampleRate.toString();\n }\n if (props.route) {\n script.dataset.route = props.route;\n }\n if (props.endpoint) {\n script.dataset.endpoint = props.endpoint;\n }\n if (props.dsn) {\n script.dataset.dsn = props.dsn;\n }\n if (isDevelopment() && props.debug === false) {\n script.dataset.debug = 'false';\n }\n\n script.onerror = (): void => {\n // eslint-disable-next-line no-console -- Logging is okay here\n console.log(\n `[Vercel Speed Insights] Failed to load script from ${src}. Please check if any content blockers are enabled and try again.`,\n );\n };\n\n document.head.appendChild(script);\n\n return {\n setRoute: (route: string | null): void => {\n script.dataset.route = route ?? undefined;\n },\n };\n}\n\nexport { injectSpeedInsights, computeRoute };\nexport type { SpeedInsightsProps };\n\n// eslint-disable-next-line import/no-default-export -- Allow default export\nexport default {\n injectSpeedInsights,\n computeRoute,\n};\n","import { createComponent } from './create-component';\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- vue's defineComponent return type is any\nexport const SpeedInsights = createComponent();\n"],"mappings":";AAAA,SAAS,iBAAiB,aAAa;AAEvC,SAAS,gBAAgB;;;ACDvB,WAAQ;AACR,cAAW;;;ACFN,IAAM,YAAY,MAAY;AAEnC,MAAI,OAAO;AAAI;AAEf,SAAO,KAAK,SAAS,KAAK,QAAc;AACtC,KAAC,OAAO,MAAM,OAAO,OAAO,CAAC,GAAG,KAAK,MAAM;AAAA,EAC7C;AACF;;;ACPO,SAAS,YAAqB;AACnC,SAAO,OAAO,WAAW;AAC3B;AAEA,SAAS,oBAAkD;AACzD,MAAI;AACF,UAAM,MAAM,QAAQ,IAAI;AACxB,QAAI,QAAQ,iBAAiB,QAAQ,QAAQ;AAC3C,aAAO;AAAA,IACT;AAAA,EACF,SAAS,GAAG;AAAA,EAEZ;AACA,SAAO;AACT;AAMO,SAAS,gBAAyB;AACvC,SAAO,kBAAkB,MAAM;AACjC;AAEO,SAAS,aACd,UACA,YACe;AACf,MAAI,CAAC,YAAY,CAAC,YAAY;AAC5B,WAAO;AAAA,EACT;AAEA,MAAI,SAAS;AACb,MAAI;AACF,UAAM,UAAU,OAAO,QAAQ,UAAU;AAEzC,eAAW,CAAC,KAAK,KAAK,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line at end of file diff --git a/node_modules/@vercel/speed-insights/jest.config.js b/node_modules/@vercel/speed-insights/jest.config.js new file mode 100644 index 0000000..f45b9dd --- /dev/null +++ b/node_modules/@vercel/speed-insights/jest.config.js @@ -0,0 +1,9 @@ +module.exports = { + testEnvironment: 'jsdom', + transform: { + '^.+\\.(t|j)sx?$': '@swc/jest', + }, + coverageReporters: ['text', 'html'], + setupFilesAfterEnv: ['/jest.setup.ts'], + reporters: ['default', 'github-actions'], +}; diff --git a/node_modules/@vercel/speed-insights/jest.setup.ts b/node_modules/@vercel/speed-insights/jest.setup.ts new file mode 100644 index 0000000..bc72741 --- /dev/null +++ b/node_modules/@vercel/speed-insights/jest.setup.ts @@ -0,0 +1,13 @@ +import { beforeEach } from '@jest/globals'; +import '@testing-library/jest-dom'; +// Adds helpers like `.toHaveAttribute` +import '@testing-library/jest-dom/jest-globals'; + +beforeEach(() => { + if ('document' in global) { + const html = document.querySelector('html'); + if (html) { + html.innerHTML = ''; + } + } +}); diff --git a/node_modules/@vercel/speed-insights/package.json b/node_modules/@vercel/speed-insights/package.json new file mode 100644 index 0000000..309f51b --- /dev/null +++ b/node_modules/@vercel/speed-insights/package.json @@ -0,0 +1,140 @@ +{ + "name": "@vercel/speed-insights", + "version": "1.1.0", + "description": "Speed Insights is a tool for measuring web performance and providing suggestions for improvement.", + "keywords": [ + "speed-insights", + "vercel" + ], + "repository": { + "url": "github:vercel/speed-insights", + "directory": "packages/web" + }, + "license": "Apache-2.0", + "exports": { + "./package.json": "./package.json", + ".": { + "browser": "./dist/index.mjs", + "import": "./dist/index.mjs", + "require": "./dist/index.js" + }, + "./astro": { + "import": "./dist/astro/component.ts" + }, + "./next": { + "browser": "./dist/next/index.mjs", + "import": "./dist/next/index.mjs", + "require": "./dist/next/index.js" + }, + "./nuxt": { + "browser": "./dist/nuxt/index.mjs", + "import": "./dist/nuxt/index.mjs", + "require": "./dist/nuxt/index.js" + }, + "./react": { + "browser": "./dist/react/index.mjs", + "import": "./dist/react/index.mjs", + "require": "./dist/react/index.js" + }, + "./remix": { + "browser": "./dist/remix/index.mjs", + "import": "./dist/remix/index.mjs", + "require": "./dist/remix/index.js" + }, + "./sveltekit": { + "svelte": "./dist/sveltekit/index.mjs", + "types": "./dist/sveltekit/index.d.ts" + }, + "./vue": { + "browser": "./dist/vue/index.mjs", + "import": "./dist/vue/index.mjs", + "require": "./dist/vue/index.js" + } + }, + "main": "./dist/index.js", + "types": "./dist/index.d.ts", + "typesVersions": { + "*": { + "*": [ + "dist/index.d.ts" + ], + "react": [ + "dist/react/index.d.ts" + ], + "next": [ + "dist/next/index.d.ts" + ], + "nuxt": [ + "dist/nuxt/index.d.ts" + ], + "remix": [ + "dist/remix/index.d.ts" + ], + "sveltekit": [ + "dist/sveltekit/index.d.ts" + ], + "vue": [ + "dist/vue/index.d.ts" + ] + } + }, + "devDependencies": { + "@jest/globals": "^29.7.0", + "@remix-run/react": "^2.5.0", + "@sveltejs/kit": "^2.7", + "@swc/core": "^1.3.103", + "@swc/jest": "^0.2.29", + "@testing-library/jest-dom": "^6.6.3", + "@testing-library/react": "^16.0.1", + "@types/node": "^20.11.4", + "@types/react": "^18.2.48", + "copyfiles": "^2.4.1", + "jest": "^29.7.0", + "jest-environment-jsdom": "^29.7.0", + "next": "^14.0.4", + "react": "^18.2.0", + "react-dom": "^18.2.0", + "svelte": "^5", + "tsup": "7.2.0", + "vue": "^3.4.14", + "vue-router": "^4.2.5" + }, + "peerDependencies": { + "@sveltejs/kit": "^1 || ^2", + "next": ">= 13", + "react": "^18 || ^19 || ^19.0.0-rc", + "svelte": ">= 4", + "vue": "^3", + "vue-router": "^4" + }, + "peerDependenciesMeta": { + "@sveltejs/kit": { + "optional": true + }, + "next": { + "optional": true + }, + "react": { + "optional": true + }, + "svelte": { + "optional": true + }, + "vue": { + "optional": true + }, + "vue-router": { + "optional": true + } + }, + "scripts": { + "build": "tsup && pnpm copy-astro", + "copy-astro": "cp -R src/astro dist/", + "dev": "pnpm copy-astro && tsup --watch", + "postinstall": "node scripts/postinstall.mjs", + "lint": "eslint .", + "lint-fix": "eslint . --fix", + "test": "jest", + "type-check": "tsc --noEmit" + } +} \ No newline at end of file diff --git a/node_modules/@vercel/speed-insights/scripts/postinstall.mjs b/node_modules/@vercel/speed-insights/scripts/postinstall.mjs new file mode 100644 index 0000000..eda0273 --- /dev/null +++ b/node_modules/@vercel/speed-insights/scripts/postinstall.mjs @@ -0,0 +1,91 @@ +/* eslint-disable no-console -- Allow the use of `console` */ +import fs from 'node:fs'; +import path from 'node:path'; + +const customPath = process.argv[2]; +const projectDir = customPath || path.resolve(process.cwd()); + +// Check .env files for the presence of the analyticsId key +function findEnvFileWithAnalyticsId() { + const files = ['.env.local', '.env.development.local', '.env']; + const envFile = files.find((file) => { + const envPath = path.join(projectDir, file); + if (!fs.existsSync(envPath)) { + return false; + } + + const envContent = fs.readFileSync(envPath, 'utf-8'); + + return envContent.includes('VERCEL_ANALYTICS_ID'); + }); + + return envFile; +} + +function isSpeedInsightsInstalled() { + const packageJsonPath = path.join(projectDir, 'package.json'); + + if (!fs.existsSync(packageJsonPath)) { + console.error('Error: package.json not found in the current directory.'); + return false; + } + + const packageJsonContent = fs.readFileSync(packageJsonPath, 'utf-8'); + const packageJson = JSON.parse(packageJsonContent); + + if (!packageJson.dependencies) { + return false; + } + + return Boolean(packageJson.dependencies['@vercel/speed-insights']); +} + +function isAnalyticsIdInNextConfig() { + const jsConfigPath = path.join(projectDir, 'next.config.js'); + const mjsConfigPath = path.join(projectDir, 'next.config.mjs'); + + let configFile; + + if (fs.existsSync(jsConfigPath)) { + configFile = jsConfigPath; + } else if (fs.existsSync(mjsConfigPath)) { + configFile = mjsConfigPath; + } else { + return; + } + + const configContent = fs.readFileSync(configFile, 'utf-8'); + + return configContent.includes('analyticsId'); +} + +function main() { + try { + if (!isSpeedInsightsInstalled()) { + // No @vercel/speed-insights installed, we don't need to continue + return; + } + + const isInConfig = isAnalyticsIdInNextConfig(); + const envFile = findEnvFileWithAnalyticsId(); + + if (isInConfig) { + console.warn( + '\x1b[31m', + `Please remove 'analyticsId' from your next.config.js file.`, + ); + } + if (envFile) { + console.log( + '\x1b[31m', + `Please remove 'VERCEL_ANALYTICS_ID' from your ${envFile} file.`, + ); + } + } catch (error) { + console.error( + `Failed to run @vercel/speed-insights postinstall script: ${error instanceof Error ? error.message : error}`, + ); + } +} + +main(); diff --git a/node_modules/@vercel/speed-insights/tsconfig.json b/node_modules/@vercel/speed-insights/tsconfig.json new file mode 100644 index 0000000..6a4fe18 --- /dev/null +++ b/node_modules/@vercel/speed-insights/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "module": "esnext" + }, + "include": ["src", "./jest.setup.ts"] +} diff --git a/node_modules/@vercel/speed-insights/tsup.config.js b/node_modules/@vercel/speed-insights/tsup.config.js new file mode 100644 index 0000000..5506086 --- /dev/null +++ b/node_modules/@vercel/speed-insights/tsup.config.js @@ -0,0 +1,74 @@ +import { defineConfig } from 'tsup'; + +const cfg = { + splitting: false, + sourcemap: true, + clean: true, + treeshake: false, + dts: true, + format: ['esm', 'cjs'], +}; + +export default defineConfig([ + { + ...cfg, + entry: { + index: 'src/generic.ts', + }, + outDir: 'dist', + }, + { + ...cfg, + entry: { + index: 'src/nextjs/index.tsx', + }, + external: ['react', 'next'], + outDir: 'dist/next', + esbuildOptions: (options) => { + // Append "use client" to the top of the react entry point + options.banner = { + js: '"use client";', + }; + }, + }, + { + ...cfg, + entry: { + index: 'src/nuxt/index.ts', + }, + external: ['vue', 'vue-router'], + outDir: 'dist/nuxt', + }, + { + ...cfg, + entry: { + index: 'src/remix/index.tsx', + }, + external: ['react', '@remix-run/react'], + outDir: 'dist/remix', + }, + { + ...cfg, + entry: { + index: 'src/sveltekit/index.ts', + }, + external: ['svelte', '@sveltejs/kit', '$app'], + outDir: 'dist/sveltekit', + }, + { + ...cfg, + entry: { + index: 'src/vue/index.ts', + }, + external: ['vue', 'vue-router'], + outDir: 'dist/vue', + }, + { + ...cfg, + entry: { + index: 'src/react/index.tsx', + }, + external: ['react'], + outDir: 'dist/react', + }, +]); diff --git a/package-lock.json b/package-lock.json index 565fe1c..2d7c82e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,10 +9,46 @@ "version": "1.0.0", "license": "ISC", "dependencies": { + "@vercel/speed-insights": "^1.1.0", "cors": "^2.8.5", "express": "^4.21.1" } }, + "node_modules/@vercel/speed-insights": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@vercel/speed-insights/-/speed-insights-1.1.0.tgz", + "integrity": "sha512-rAXxuhhO4mlRGC9noa5F7HLMtGg8YF1zAN6Pjd1Ny4pII4cerhtwSG4vympbCl+pWkH7nBS9kVXRD4FAn54dlg==", + "hasInstallScript": true, + "license": "Apache-2.0", + "peerDependencies": { + "@sveltejs/kit": "^1 || ^2", + "next": ">= 13", + "react": "^18 || ^19 || ^19.0.0-rc", + "svelte": ">= 4", + "vue": "^3", + "vue-router": "^4" + }, + "peerDependenciesMeta": { + "@sveltejs/kit": { + "optional": true + }, + "next": { + "optional": true + }, + "react": { + "optional": true + }, + "svelte": { + "optional": true + }, + "vue": { + "optional": true + }, + "vue-router": { + "optional": true + } + } + }, "node_modules/accepts": { "version": "1.3.8", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", diff --git a/package.json b/package.json index b93c882..8feee2e 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "author": "Abhishek Jain", "license": "ISC", "dependencies": { + "@vercel/speed-insights": "^1.1.0", "cors": "^2.8.5", "express": "^4.21.1" }