Revamping to matrix style

This commit is contained in:
2026-02-16 16:37:35 -05:00
parent 71852ec99a
commit 9d0e3938e4
14958 changed files with 2089572 additions and 114 deletions

7
node_modules/@vercel/speed-insights/.eslintrc.cjs generated vendored Normal file
View File

@@ -0,0 +1,7 @@
module.exports = {
extends: '../../.eslintrc.cjs',
rules: {
'tsdoc/syntax': 'off',
},
ignorePatterns: ['jest.setup.ts'],
};

190
node_modules/@vercel/speed-insights/LICENSE generated vendored Normal file
View File

@@ -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.

49
node_modules/@vercel/speed-insights/README.md generated vendored Normal file
View File

@@ -0,0 +1,49 @@
![Speed Insights](https://github.com/vercel/speed-insights/blob/main/.github/banner.png)
<div align="center"><strong>Vercel Speed Insights</strong></div>
<div align="center">Performance insights for your website</div>
<br />
<div align="center">
<a href="https://vercel.com/docs/speed-insights">Website</a>
<span> · </span>
<a href="https://vercel.com/docs/speed-insights/package">Documentation</a>
<span> · </span>
<a href="https://twitter.com/vercel">Twitter</a>
</div>
## 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 `<SpeedInsights />` 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).

View File

@@ -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';

View File

@@ -0,0 +1,53 @@
---
// 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<SpeedInsightsProps, 'framework' | 'beforeSend'>;
const propsStr = JSON.stringify(Astro.props);
const paramsStr = JSON.stringify(Astro.params);
---
<vercel-speed-insights
data-props={propsStr}
data-params={paramsStr}
data-pathname={Astro.url.pathname}></vercel-speed-insights>
<script>
import { injectSpeedInsights, computeRoute } from '../index.mjs';
function getBasePath(): string | undefined {
// !! important !!
// do not access env variables using import.meta.env[varname]
// some bundles won't replace the value at build time.
try {
return import.meta.env.PUBLIC_VERCEL_OBSERVABILITY_BASEPATH as
| string
| undefined;
} catch {
// do nothing
}
}
customElements.define(
'vercel-speed-insights',
class VercelSpeedInsights extends HTMLElement {
constructor() {
super();
try {
const props = JSON.parse(this.dataset.props ?? '{}');
const params = JSON.parse(this.dataset.params ?? '{}');
const route = computeRoute(this.dataset.pathname ?? '', params);
injectSpeedInsights({
route,
...props,
framework: 'astro',
basePath: getBasePath(),
beforeSend: window.speedInsightsBeforeSend,
});
} catch (err) {
throw new Error(`Failed to parse SpeedInsights properties: ${err}`);
}
}
},
);
</script>

58
node_modules/@vercel/speed-insights/dist/index.d.mts generated vendored Normal file
View File

@@ -0,0 +1,58 @@
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<T extends keyof Functions = keyof Functions> {
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<string, string | string[]> | 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;
basePath?: string;
}): {
setRoute: (route: string | null) => void;
} | null;
declare const _default: {
injectSpeedInsights: typeof injectSpeedInsights;
computeRoute: typeof computeRoute;
};
export { type SpeedInsightsProps, computeRoute, _default as default, injectSpeedInsights };

58
node_modules/@vercel/speed-insights/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,58 @@
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<T extends keyof Functions = keyof Functions> {
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<string, string | string[]> | 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;
basePath?: string;
}): {
setRoute: (route: string | null) => void;
} | null;
declare const _default: {
injectSpeedInsights: typeof injectSpeedInsights;
computeRoute: typeof computeRoute;
};
export { type SpeedInsightsProps, computeRoute, _default as default, injectSpeedInsights };

161
node_modules/@vercel/speed-insights/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,161 @@
"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.2.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, "\\$&");
}
function getScriptSrc(props) {
if (props.scriptSrc) {
return props.scriptSrc;
}
if (isDevelopment()) {
return "https://va.vercel-scripts.com/v1/speed-insights/script.debug.js";
}
if (props.dsn) {
return "https://va.vercel-scripts.com/v1/speed-insights/script.js";
}
if (props.basePath) {
return `${props.basePath}/speed-insights/script.js`;
}
return "/_vercel/speed-insights/script.js";
}
// src/generic.ts
function injectSpeedInsights(props = {}) {
var _a;
if (!isBrowser() || props.route === null) return null;
initQueue();
const src = getScriptSrc(props);
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;
} else if (props.basePath) {
script.dataset.endpoint = `${props.basePath}/speed-insights/vitals`;
}
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

File diff suppressed because one or more lines are too long

133
node_modules/@vercel/speed-insights/dist/index.mjs generated vendored Normal file
View File

@@ -0,0 +1,133 @@
// package.json
var name = "@vercel/speed-insights";
var version = "1.2.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, "\\$&");
}
function getScriptSrc(props) {
if (props.scriptSrc) {
return props.scriptSrc;
}
if (isDevelopment()) {
return "https://va.vercel-scripts.com/v1/speed-insights/script.debug.js";
}
if (props.dsn) {
return "https://va.vercel-scripts.com/v1/speed-insights/script.js";
}
if (props.basePath) {
return `${props.basePath}/speed-insights/script.js`;
}
return "/_vercel/speed-insights/script.js";
}
// src/generic.ts
function injectSpeedInsights(props = {}) {
var _a;
if (!isBrowser() || props.route === null) return null;
initQueue();
const src = getScriptSrc(props);
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;
} else if (props.basePath) {
script.dataset.endpoint = `${props.basePath}/speed-insights/vitals`;
}
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

File diff suppressed because one or more lines are too long

View File

@@ -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<T extends keyof Functions = keyof Functions> {
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<SpeedInsightsProps, 'route'>;
declare function SpeedInsights(props: Props): null;
export { SpeedInsights };

View File

@@ -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<T extends keyof Functions = keyof Functions> {
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<SpeedInsightsProps, 'route'>;
declare function SpeedInsights(props: Props): null;
export { SpeedInsights };

239
node_modules/@vercel/speed-insights/dist/next/index.js generated vendored Normal file
View File

@@ -0,0 +1,239 @@
"use strict";
"use client";
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.2.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, "\\$&");
}
function getScriptSrc(props) {
if (props.scriptSrc) {
return props.scriptSrc;
}
if (isDevelopment()) {
return "https://va.vercel-scripts.com/v1/speed-insights/script.debug.js";
}
if (props.dsn) {
return "https://va.vercel-scripts.com/v1/speed-insights/script.js";
}
if (props.basePath) {
return `${props.basePath}/speed-insights/script.js`;
}
return "/_vercel/speed-insights/script.js";
}
// src/generic.ts
function injectSpeedInsights(props = {}) {
var _a;
if (!isBrowser() || props.route === null) return null;
initQueue();
const src = getScriptSrc(props);
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;
} else if (props.basePath) {
script.dataset.endpoint = `${props.basePath}/speed-insights/vitals`;
}
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/utils.ts
function getBasePath() {
if (typeof process === "undefined" || typeof process.env === "undefined") {
return void 0;
}
return process.env.REACT_APP_VERCEL_OBSERVABILITY_BASEPATH;
}
// 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",
basePath: props.basePath ?? getBasePath(),
...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);
};
function getBasePath2() {
if (typeof process === "undefined" || typeof process.env === "undefined") {
return void 0;
}
return process.env.NEXT_PUBLIC_VERCEL_OBSERVABILITY_BASEPATH;
}
// src/nextjs/index.tsx
function SpeedInsightsComponent(props) {
const route = useRoute();
return /* @__PURE__ */ import_react2.default.createElement(
SpeedInsights,
{
route,
...props,
framework: "next",
basePath: getBasePath2()
}
);
}
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

File diff suppressed because one or more lines are too long

205
node_modules/@vercel/speed-insights/dist/next/index.mjs generated vendored Normal file
View File

@@ -0,0 +1,205 @@
"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.2.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, "\\$&");
}
function getScriptSrc(props) {
if (props.scriptSrc) {
return props.scriptSrc;
}
if (isDevelopment()) {
return "https://va.vercel-scripts.com/v1/speed-insights/script.debug.js";
}
if (props.dsn) {
return "https://va.vercel-scripts.com/v1/speed-insights/script.js";
}
if (props.basePath) {
return `${props.basePath}/speed-insights/script.js`;
}
return "/_vercel/speed-insights/script.js";
}
// src/generic.ts
function injectSpeedInsights(props = {}) {
var _a;
if (!isBrowser() || props.route === null) return null;
initQueue();
const src = getScriptSrc(props);
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;
} else if (props.basePath) {
script.dataset.endpoint = `${props.basePath}/speed-insights/vitals`;
}
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/utils.ts
function getBasePath() {
if (typeof process === "undefined" || typeof process.env === "undefined") {
return void 0;
}
return process.env.REACT_APP_VERCEL_OBSERVABILITY_BASEPATH;
}
// 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",
basePath: props.basePath ?? getBasePath(),
...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);
};
function getBasePath2() {
if (typeof process === "undefined" || typeof process.env === "undefined") {
return void 0;
}
return process.env.NEXT_PUBLIC_VERCEL_OBSERVABILITY_BASEPATH;
}
// src/nextjs/index.tsx
function SpeedInsightsComponent(props) {
const route = useRoute();
return /* @__PURE__ */ React.createElement(
SpeedInsights,
{
route,
...props,
framework: "next",
basePath: getBasePath2()
}
);
}
function SpeedInsights2(props) {
return /* @__PURE__ */ React.createElement(Suspense, { fallback: null }, /* @__PURE__ */ React.createElement(SpeedInsightsComponent, { ...props }));
}
export {
SpeedInsights2 as SpeedInsights
};
//# sourceMappingURL=index.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,3 @@
declare const SpeedInsights: any;
export { SpeedInsights };

View File

@@ -0,0 +1,3 @@
declare const SpeedInsights: any;
export { SpeedInsights };

203
node_modules/@vercel/speed-insights/dist/nuxt/index.js generated vendored Normal file
View File

@@ -0,0 +1,203 @@
"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.2.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, "\\$&");
}
function getScriptSrc(props) {
if (props.scriptSrc) {
return props.scriptSrc;
}
if (isDevelopment()) {
return "https://va.vercel-scripts.com/v1/speed-insights/script.debug.js";
}
if (props.dsn) {
return "https://va.vercel-scripts.com/v1/speed-insights/script.js";
}
if (props.basePath) {
return `${props.basePath}/speed-insights/script.js`;
}
return "/_vercel/speed-insights/script.js";
}
// src/generic.ts
function injectSpeedInsights(props = {}) {
var _a;
if (!isBrowser() || props.route === null) return null;
initQueue();
const src = getScriptSrc(props);
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;
} else if (props.basePath) {
script.dataset.endpoint = `${props.basePath}/speed-insights/vitals`;
}
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/utils.ts
var import_meta = {};
function getBasePath() {
try {
return import_meta.env.VITE_VERCEL_OBSERVABILITY_BASEPATH;
} catch {
}
}
// 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,
basePath: getBasePath()
});
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

File diff suppressed because one or more lines are too long

175
node_modules/@vercel/speed-insights/dist/nuxt/index.mjs generated vendored Normal file
View File

@@ -0,0 +1,175 @@
// 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.2.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, "\\$&");
}
function getScriptSrc(props) {
if (props.scriptSrc) {
return props.scriptSrc;
}
if (isDevelopment()) {
return "https://va.vercel-scripts.com/v1/speed-insights/script.debug.js";
}
if (props.dsn) {
return "https://va.vercel-scripts.com/v1/speed-insights/script.js";
}
if (props.basePath) {
return `${props.basePath}/speed-insights/script.js`;
}
return "/_vercel/speed-insights/script.js";
}
// src/generic.ts
function injectSpeedInsights(props = {}) {
var _a;
if (!isBrowser() || props.route === null) return null;
initQueue();
const src = getScriptSrc(props);
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;
} else if (props.basePath) {
script.dataset.endpoint = `${props.basePath}/speed-insights/vitals`;
}
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/utils.ts
function getBasePath() {
try {
return import.meta.env.VITE_VERCEL_OBSERVABILITY_BASEPATH;
} catch {
}
}
// 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,
basePath: getBasePath()
});
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

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,42 @@
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<T extends keyof Functions = keyof Functions> {
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<string, string | string[]> | null): string | null;
declare function SpeedInsights(props: SpeedInsightsProps & {
framework?: string;
basePath?: string;
}): JSX.Element | null;
export { SpeedInsights, computeRoute };

View File

@@ -0,0 +1,42 @@
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<T extends keyof Functions = keyof Functions> {
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<string, string | string[]> | null): string | null;
declare function SpeedInsights(props: SpeedInsightsProps & {
framework?: string;
basePath?: string;
}): JSX.Element | null;
export { SpeedInsights, computeRoute };

192
node_modules/@vercel/speed-insights/dist/react/index.js generated vendored Normal file
View File

@@ -0,0 +1,192 @@
"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.2.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, "\\$&");
}
function getScriptSrc(props) {
if (props.scriptSrc) {
return props.scriptSrc;
}
if (isDevelopment()) {
return "https://va.vercel-scripts.com/v1/speed-insights/script.debug.js";
}
if (props.dsn) {
return "https://va.vercel-scripts.com/v1/speed-insights/script.js";
}
if (props.basePath) {
return `${props.basePath}/speed-insights/script.js`;
}
return "/_vercel/speed-insights/script.js";
}
// src/generic.ts
function injectSpeedInsights(props = {}) {
var _a;
if (!isBrowser() || props.route === null) return null;
initQueue();
const src = getScriptSrc(props);
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;
} else if (props.basePath) {
script.dataset.endpoint = `${props.basePath}/speed-insights/vitals`;
}
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/utils.ts
function getBasePath() {
if (typeof process === "undefined" || typeof process.env === "undefined") {
return void 0;
}
return process.env.REACT_APP_VERCEL_OBSERVABILITY_BASEPATH;
}
// 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",
basePath: props.basePath ?? getBasePath(),
...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

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,167 @@
"use client";
// src/react/index.tsx
import { useEffect, useRef } from "react";
// package.json
var name = "@vercel/speed-insights";
var version = "1.2.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, "\\$&");
}
function getScriptSrc(props) {
if (props.scriptSrc) {
return props.scriptSrc;
}
if (isDevelopment()) {
return "https://va.vercel-scripts.com/v1/speed-insights/script.debug.js";
}
if (props.dsn) {
return "https://va.vercel-scripts.com/v1/speed-insights/script.js";
}
if (props.basePath) {
return `${props.basePath}/speed-insights/script.js`;
}
return "/_vercel/speed-insights/script.js";
}
// src/generic.ts
function injectSpeedInsights(props = {}) {
var _a;
if (!isBrowser() || props.route === null) return null;
initQueue();
const src = getScriptSrc(props);
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;
} else if (props.basePath) {
script.dataset.endpoint = `${props.basePath}/speed-insights/vitals`;
}
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/utils.ts
function getBasePath() {
if (typeof process === "undefined" || typeof process.env === "undefined") {
return void 0;
}
return process.env.REACT_APP_VERCEL_OBSERVABILITY_BASEPATH;
}
// 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",
basePath: props.basePath ?? getBasePath(),
...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

File diff suppressed because one or more lines are too long

View File

@@ -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<T extends keyof Functions = keyof Functions> {
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<SpeedInsightsProps, 'route'>): JSX.Element;
export { SpeedInsights };

View File

@@ -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<T extends keyof Functions = keyof Functions> {
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<SpeedInsightsProps, 'route'>): JSX.Element;
export { SpeedInsights };

231
node_modules/@vercel/speed-insights/dist/remix/index.js generated vendored Normal file
View File

@@ -0,0 +1,231 @@
"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.2.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, "\\$&");
}
function getScriptSrc(props) {
if (props.scriptSrc) {
return props.scriptSrc;
}
if (isDevelopment()) {
return "https://va.vercel-scripts.com/v1/speed-insights/script.debug.js";
}
if (props.dsn) {
return "https://va.vercel-scripts.com/v1/speed-insights/script.js";
}
if (props.basePath) {
return `${props.basePath}/speed-insights/script.js`;
}
return "/_vercel/speed-insights/script.js";
}
// src/generic.ts
function injectSpeedInsights(props = {}) {
var _a;
if (!isBrowser() || props.route === null) return null;
initQueue();
const src = getScriptSrc(props);
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;
} else if (props.basePath) {
script.dataset.endpoint = `${props.basePath}/speed-insights/vitals`;
}
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/utils.ts
function getBasePath() {
if (typeof process === "undefined" || typeof process.env === "undefined") {
return void 0;
}
return process.env.REACT_APP_VERCEL_OBSERVABILITY_BASEPATH;
}
// 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",
basePath: props.basePath ?? getBasePath(),
...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 import_meta = {};
var useRoute = () => {
const params = (0, import_react2.useParams)();
const location = (0, import_react2.useLocation)();
return computeRoute(location.pathname, params);
};
function getBasePath2() {
try {
return import_meta.env.VITE_VERCEL_OBSERVABILITY_BASEPATH;
} catch {
}
}
// src/remix/index.tsx
function SpeedInsights2(props) {
const route = useRoute();
return /* @__PURE__ */ import_react3.default.createElement(
SpeedInsights,
{
route,
...props,
framework: "remix",
basePath: getBasePath2()
}
);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
SpeedInsights
});
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,195 @@
// 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.2.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, "\\$&");
}
function getScriptSrc(props) {
if (props.scriptSrc) {
return props.scriptSrc;
}
if (isDevelopment()) {
return "https://va.vercel-scripts.com/v1/speed-insights/script.debug.js";
}
if (props.dsn) {
return "https://va.vercel-scripts.com/v1/speed-insights/script.js";
}
if (props.basePath) {
return `${props.basePath}/speed-insights/script.js`;
}
return "/_vercel/speed-insights/script.js";
}
// src/generic.ts
function injectSpeedInsights(props = {}) {
var _a;
if (!isBrowser() || props.route === null) return null;
initQueue();
const src = getScriptSrc(props);
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;
} else if (props.basePath) {
script.dataset.endpoint = `${props.basePath}/speed-insights/vitals`;
}
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/utils.ts
function getBasePath() {
if (typeof process === "undefined" || typeof process.env === "undefined") {
return void 0;
}
return process.env.REACT_APP_VERCEL_OBSERVABILITY_BASEPATH;
}
// 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",
basePath: props.basePath ?? getBasePath(),
...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);
};
function getBasePath2() {
try {
return import.meta.env.VITE_VERCEL_OBSERVABILITY_BASEPATH;
} catch {
}
}
// src/remix/index.tsx
function SpeedInsights2(props) {
const route = useRoute();
return /* @__PURE__ */ React.createElement(
SpeedInsights,
{
route,
...props,
framework: "remix",
basePath: getBasePath2()
}
);
}
export {
SpeedInsights2 as SpeedInsights
};
//# sourceMappingURL=index.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -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<T extends keyof Functions = keyof Functions> {
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<SpeedInsightsProps, 'framework'>): void;
export { injectSpeedInsights };

View File

@@ -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<T extends keyof Functions = keyof Functions> {
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<SpeedInsightsProps, 'framework'>): void;
export { injectSpeedInsights };

View File

@@ -0,0 +1,154 @@
"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.2.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 getScriptSrc(props) {
if (props.scriptSrc) {
return props.scriptSrc;
}
if (isDevelopment()) {
return "https://va.vercel-scripts.com/v1/speed-insights/script.debug.js";
}
if (props.dsn) {
return "https://va.vercel-scripts.com/v1/speed-insights/script.js";
}
if (props.basePath) {
return `${props.basePath}/speed-insights/script.js`;
}
return "/_vercel/speed-insights/script.js";
}
// src/generic.ts
function injectSpeedInsights(props = {}) {
var _a;
if (!isBrowser() || props.route === null) return null;
initQueue();
const src = getScriptSrc(props);
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;
} else if (props.basePath) {
script.dataset.endpoint = `${props.basePath}/speed-insights/vitals`;
}
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/utils.ts
var import_meta = {};
function getBasePath() {
try {
return import_meta.env.VITE_VERCEL_OBSERVABILITY_BASEPATH;
} catch {
}
}
// 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",
basePath: getBasePath()
});
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

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,128 @@
// src/sveltekit/index.ts
import { get } from "svelte/store";
// package.json
var name = "@vercel/speed-insights";
var version = "1.2.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 getScriptSrc(props) {
if (props.scriptSrc) {
return props.scriptSrc;
}
if (isDevelopment()) {
return "https://va.vercel-scripts.com/v1/speed-insights/script.debug.js";
}
if (props.dsn) {
return "https://va.vercel-scripts.com/v1/speed-insights/script.js";
}
if (props.basePath) {
return `${props.basePath}/speed-insights/script.js`;
}
return "/_vercel/speed-insights/script.js";
}
// src/generic.ts
function injectSpeedInsights(props = {}) {
var _a;
if (!isBrowser() || props.route === null) return null;
initQueue();
const src = getScriptSrc(props);
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;
} else if (props.basePath) {
script.dataset.endpoint = `${props.basePath}/speed-insights/vitals`;
}
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/utils.ts
function getBasePath() {
try {
return import.meta.env.VITE_VERCEL_OBSERVABILITY_BASEPATH;
} catch {
}
}
// 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",
basePath: getBasePath()
});
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

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,3 @@
declare const SpeedInsights: any;
export { SpeedInsights };

View File

@@ -0,0 +1,3 @@
declare const SpeedInsights: any;
export { SpeedInsights };

203
node_modules/@vercel/speed-insights/dist/vue/index.js generated vendored Normal file
View File

@@ -0,0 +1,203 @@
"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.2.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, "\\$&");
}
function getScriptSrc(props) {
if (props.scriptSrc) {
return props.scriptSrc;
}
if (isDevelopment()) {
return "https://va.vercel-scripts.com/v1/speed-insights/script.debug.js";
}
if (props.dsn) {
return "https://va.vercel-scripts.com/v1/speed-insights/script.js";
}
if (props.basePath) {
return `${props.basePath}/speed-insights/script.js`;
}
return "/_vercel/speed-insights/script.js";
}
// src/generic.ts
function injectSpeedInsights(props = {}) {
var _a;
if (!isBrowser() || props.route === null) return null;
initQueue();
const src = getScriptSrc(props);
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;
} else if (props.basePath) {
script.dataset.endpoint = `${props.basePath}/speed-insights/vitals`;
}
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/utils.ts
var import_meta = {};
function getBasePath() {
try {
return import_meta.env.VITE_VERCEL_OBSERVABILITY_BASEPATH;
} catch {
}
}
// 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,
basePath: getBasePath()
});
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

File diff suppressed because one or more lines are too long

175
node_modules/@vercel/speed-insights/dist/vue/index.mjs generated vendored Normal file
View File

@@ -0,0 +1,175 @@
// 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.2.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, "\\$&");
}
function getScriptSrc(props) {
if (props.scriptSrc) {
return props.scriptSrc;
}
if (isDevelopment()) {
return "https://va.vercel-scripts.com/v1/speed-insights/script.debug.js";
}
if (props.dsn) {
return "https://va.vercel-scripts.com/v1/speed-insights/script.js";
}
if (props.basePath) {
return `${props.basePath}/speed-insights/script.js`;
}
return "/_vercel/speed-insights/script.js";
}
// src/generic.ts
function injectSpeedInsights(props = {}) {
var _a;
if (!isBrowser() || props.route === null) return null;
initQueue();
const src = getScriptSrc(props);
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;
} else if (props.basePath) {
script.dataset.endpoint = `${props.basePath}/speed-insights/vitals`;
}
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/utils.ts
function getBasePath() {
try {
return import.meta.env.VITE_VERCEL_OBSERVABILITY_BASEPATH;
} catch {
}
}
// 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,
basePath: getBasePath()
});
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

File diff suppressed because one or more lines are too long

138
node_modules/@vercel/speed-insights/package.json generated vendored Normal file
View File

@@ -0,0 +1,138 @@
{
"name": "@vercel/speed-insights",
"version": "1.2.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": {
"@remix-run/react": "^2.14.0",
"@sveltejs/kit": "^2.8.1",
"@swc/core": "^1.9.2",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.0.1",
"@types/node": "^22.9.1",
"@types/react": "^18.3.12",
"copyfiles": "^2.4.1",
"jsdom": "^25.0.1",
"next": "^14.0.4",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"svelte": "^5.2.7",
"tsup": "8.3.5",
"vitest": "^2.1.5",
"vue": "^3.5.13",
"vue-router": "^4.4.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": "vitest",
"type-check": "tsc --noEmit"
}
}

View File

@@ -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();

11
node_modules/@vercel/speed-insights/test.setup.ts generated vendored Normal file
View File

@@ -0,0 +1,11 @@
import { beforeEach } from 'vitest';
import '@testing-library/jest-dom/vitest';
beforeEach(() => {
if (typeof window === 'undefined') return;
// reset dom before each test
const html = document.querySelector('html');
if (html) {
html.innerHTML = '';
}
});

7
node_modules/@vercel/speed-insights/tsconfig.json generated vendored Normal file
View File

@@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"module": "esnext"
},
"include": ["src", "./test.setup.ts"]
}

68
node_modules/@vercel/speed-insights/tsup.config.js generated vendored Normal file
View File

@@ -0,0 +1,68 @@
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',
},
{
...cfg,
entry: {
index: 'src/nuxt/index.ts',
},
external: ['vue', 'vue-router'],
outDir: 'dist/nuxt',
},
{
...cfg,
entry: {
index: 'src/react/index.tsx',
},
external: ['react'],
outDir: 'dist/react',
},
{
...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',
},
]);

10
node_modules/@vercel/speed-insights/vitest.config.mts generated vendored Normal file
View File

@@ -0,0 +1,10 @@
/// <reference types="vitest" />
import { defineConfig } from 'vitest/config';
// eslint-disable-next-line import/no-default-export -- vitest needs a default export.
export default defineConfig({
test: {
environment: 'jsdom',
setupFiles: './test.setup.ts',
},
});