This commit is contained in:
42
node_modules/@vercel/speed-insights/dist/react/index.d.mts
generated
vendored
42
node_modules/@vercel/speed-insights/dist/react/index.d.mts
generated
vendored
@@ -1,42 +0,0 @@
|
||||
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 };
|
||||
42
node_modules/@vercel/speed-insights/dist/react/index.d.ts
generated
vendored
42
node_modules/@vercel/speed-insights/dist/react/index.d.ts
generated
vendored
@@ -1,42 +0,0 @@
|
||||
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
192
node_modules/@vercel/speed-insights/dist/react/index.js
generated
vendored
@@ -1,192 +0,0 @@
|
||||
"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
|
||||
1
node_modules/@vercel/speed-insights/dist/react/index.js.map
generated
vendored
1
node_modules/@vercel/speed-insights/dist/react/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
167
node_modules/@vercel/speed-insights/dist/react/index.mjs
generated
vendored
167
node_modules/@vercel/speed-insights/dist/react/index.mjs
generated
vendored
@@ -1,167 +0,0 @@
|
||||
"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
|
||||
1
node_modules/@vercel/speed-insights/dist/react/index.mjs.map
generated
vendored
1
node_modules/@vercel/speed-insights/dist/react/index.mjs.map
generated
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user