Updates dockerfile
All checks were successful
Build and Push / build (push) Successful in 55s

This commit is contained in:
2026-02-16 15:09:37 -05:00
parent 8346776f2a
commit d181f77fb2
14943 changed files with 2078509 additions and 16 deletions

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