@vercel/speed-insights
Advanced tools
Comparing version 0.0.2 to 0.0.3-beta.0
@@ -39,3 +39,5 @@ interface SpeedInsightsProps { | ||
*/ | ||
declare function inject(props: SpeedInsightsProps): { | ||
declare function inject(props: SpeedInsightsProps & { | ||
framework?: string; | ||
}): { | ||
setRoute: (route: string) => void; | ||
@@ -42,0 +44,0 @@ } | null; |
@@ -0,4 +1,31 @@ | ||
"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, { | ||
default: () => generic_default, | ||
inject: () => inject | ||
}); | ||
module.exports = __toCommonJS(generic_exports); | ||
// package.json | ||
var name = "@vercel/speed-insights"; | ||
var version = "0.0.2"; | ||
var version = "0.0.3-beta.0"; | ||
@@ -40,12 +67,12 @@ // src/queue.ts | ||
initQueue(); | ||
const src = props.scriptSrc || (isDevelopment() ? DEV_SCRIPT_URL : SCRIPT_URL); | ||
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 src = props.scriptSrc || (isDevelopment() ? DEV_SCRIPT_URL : SCRIPT_URL); | ||
if (document.head.querySelector(`script[src*="${src}"]`)) | ||
return null; | ||
const script = document.createElement("script"); | ||
script.src = src; | ||
script.defer = true; | ||
script.dataset.sdkn = name; | ||
script.dataset.sdkn = name + (props.framework ? `/${props.framework}` : ""); | ||
script.dataset.sdkv = version; | ||
@@ -83,6 +110,6 @@ if (props.sampleRate) { | ||
}; | ||
export { | ||
generic_default as default, | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
inject | ||
}; | ||
}); | ||
//# sourceMappingURL=index.js.map |
"use client"; | ||
"use strict"; | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __export = (target, all) => { | ||
for (var name2 in all) | ||
__defProp(target, name2, { get: all[name2], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
// If the importer is in node compatibility mode or this is not an ESM | ||
// file that has been converted to a CommonJS file using a Babel- | ||
// compatible transform (i.e. "__esModule" has not been set), then set | ||
// "default" to the CommonJS "module.exports" for node compatibility. | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
mod | ||
)); | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
// src/nextjs/index.tsx | ||
import React from "react"; | ||
var nextjs_exports = {}; | ||
__export(nextjs_exports, { | ||
SpeedInsights: () => SpeedInsights2 | ||
}); | ||
module.exports = __toCommonJS(nextjs_exports); | ||
var import_react3 = __toESM(require("react")); | ||
// src/react/index.tsx | ||
import { useEffect, useRef } from "react"; | ||
var import_react = require("react"); | ||
// package.json | ||
var name = "@vercel/speed-insights"; | ||
var version = "0.0.2"; | ||
var version = "0.0.3-beta.0"; | ||
@@ -64,12 +97,12 @@ // src/queue.ts | ||
initQueue(); | ||
const src = props.scriptSrc || (isDevelopment() ? DEV_SCRIPT_URL : SCRIPT_URL); | ||
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 src = props.scriptSrc || (isDevelopment() ? DEV_SCRIPT_URL : SCRIPT_URL); | ||
if (document.head.querySelector(`script[src*="${src}"]`)) | ||
return null; | ||
const script = document.createElement("script"); | ||
script.src = src; | ||
script.defer = true; | ||
script.dataset.sdkn = name; | ||
script.dataset.sdkn = name + (props.framework ? `/${props.framework}` : ""); | ||
script.dataset.sdkv = version; | ||
@@ -107,6 +140,9 @@ if (props.sampleRate) { | ||
function SpeedInsights(props) { | ||
const setScriptRoute = useRef(null); | ||
useEffect(() => { | ||
const setScriptRoute = (0, import_react.useRef)(null); | ||
(0, import_react.useEffect)(() => { | ||
if (!setScriptRoute.current) { | ||
const script = inject(props); | ||
const script = inject({ | ||
framework: props.framework || "react", | ||
...props | ||
}); | ||
if (script) { | ||
@@ -123,9 +159,9 @@ setScriptRoute.current = script.setRoute; | ||
// src/nextjs/utils.ts | ||
import { useParams, usePathname, useSearchParams } from "next/navigation"; | ||
import { useMemo } from "react"; | ||
var import_navigation = require("next/navigation"); | ||
var import_react2 = require("react"); | ||
var useRoute = () => { | ||
const params = useParams(); | ||
const searchParams = useSearchParams(); | ||
const path = usePathname(); | ||
const finalParams = useMemo(() => { | ||
const params = (0, import_navigation.useParams)(); | ||
const searchParams = (0, import_navigation.useSearchParams)(); | ||
const path = (0, import_navigation.usePathname)(); | ||
const finalParams = (0, import_react2.useMemo)(() => { | ||
if (!params) | ||
@@ -144,7 +180,8 @@ return null; | ||
const route = useRoute(); | ||
return /* @__PURE__ */ React.createElement(SpeedInsights, { route, ...props }); | ||
return /* @__PURE__ */ import_react3.default.createElement(SpeedInsights, { route, ...props, framework: "next" }); | ||
} | ||
export { | ||
SpeedInsights2 as SpeedInsights | ||
}; | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
SpeedInsights | ||
}); | ||
//# sourceMappingURL=index.js.map |
@@ -0,10 +1,44 @@ | ||
"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 | ||
import React from "react"; | ||
var remix_exports = {}; | ||
__export(remix_exports, { | ||
SpeedInsights: () => SpeedInsights2 | ||
}); | ||
module.exports = __toCommonJS(remix_exports); | ||
var import_react3 = __toESM(require("react")); | ||
// src/react/index.tsx | ||
import { useEffect, useRef } from "react"; | ||
var import_react = require("react"); | ||
// package.json | ||
var name = "@vercel/speed-insights"; | ||
var version = "0.0.2"; | ||
var version = "0.0.3-beta.0"; | ||
@@ -62,12 +96,12 @@ // src/queue.ts | ||
initQueue(); | ||
const src = props.scriptSrc || (isDevelopment() ? DEV_SCRIPT_URL : SCRIPT_URL); | ||
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 src = props.scriptSrc || (isDevelopment() ? DEV_SCRIPT_URL : SCRIPT_URL); | ||
if (document.head.querySelector(`script[src*="${src}"]`)) | ||
return null; | ||
const script = document.createElement("script"); | ||
script.src = src; | ||
script.defer = true; | ||
script.dataset.sdkn = name; | ||
script.dataset.sdkn = name + (props.framework ? `/${props.framework}` : ""); | ||
script.dataset.sdkv = version; | ||
@@ -105,6 +139,9 @@ if (props.sampleRate) { | ||
function SpeedInsights(props) { | ||
const setScriptRoute = useRef(null); | ||
useEffect(() => { | ||
const setScriptRoute = (0, import_react.useRef)(null); | ||
(0, import_react.useEffect)(() => { | ||
if (!setScriptRoute.current) { | ||
const script = inject(props); | ||
const script = inject({ | ||
framework: props.framework || "react", | ||
...props | ||
}); | ||
if (script) { | ||
@@ -121,6 +158,6 @@ setScriptRoute.current = script.setRoute; | ||
// src/remix/utils.ts | ||
import { useLocation, useParams } from "@remix-run/react"; | ||
var import_react2 = require("@remix-run/react"); | ||
var useRoute = () => { | ||
const params = useParams(); | ||
const location = useLocation(); | ||
const params = (0, import_react2.useParams)(); | ||
const location = (0, import_react2.useLocation)(); | ||
return computeRoute(location.pathname, params); | ||
@@ -132,7 +169,15 @@ }; | ||
const route = useRoute(); | ||
return /* @__PURE__ */ React.createElement(SpeedInsights, { ...route && { route }, ...props }); | ||
return /* @__PURE__ */ import_react3.default.createElement( | ||
SpeedInsights, | ||
{ | ||
...route && { route }, | ||
...props, | ||
framework: "remix" | ||
} | ||
); | ||
} | ||
export { | ||
SpeedInsights2 as SpeedInsights | ||
}; | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
SpeedInsights | ||
}); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@vercel/speed-insights", | ||
"version": "0.0.2", | ||
"version": "0.0.3-beta.0", | ||
"description": "Speed Insights is a tool for measuring web performance and providing suggestions for improvement.", | ||
@@ -14,3 +14,2 @@ "keywords": [ | ||
"license": "MPL-2.0", | ||
"type": "module", | ||
"exports": { | ||
@@ -32,2 +31,6 @@ "./package.json": "./package.json", | ||
"require": "./dist/remix/index.cjs" | ||
}, | ||
"./sveltekit": { | ||
"svelte": "./dist/sveltekit/index.mjs", | ||
"types": "./dist/sveltekit/index.d.ts" | ||
} | ||
@@ -50,2 +53,5 @@ }, | ||
"dist/remix/index.d.ts" | ||
], | ||
"sveltekit": [ | ||
"dist/sveltekit/index.d.ts" | ||
] | ||
@@ -56,2 +62,3 @@ } | ||
"@remix-run/react": "^2.0.1", | ||
"@sveltejs/kit": "^1.20.4", | ||
"@swc/core": "^1.3.82", | ||
@@ -64,2 +71,3 @@ "@swc/jest": "^0.2.29", | ||
"@types/react": "^18.2.21", | ||
"copyfiles": "^2.4.1", | ||
"jest": "^29.6.4", | ||
@@ -70,8 +78,9 @@ "jest-environment-jsdom": "^29.6.4", | ||
"react-dom": "^18.2.0", | ||
"svelte": "^4.0.5", | ||
"tsup": "7.2.0" | ||
}, | ||
"scripts": { | ||
"build": "tsup", | ||
"build": "tsup ", | ||
"dev": "tsup --watch", | ||
"postinstall": "node scripts/postinstall.js", | ||
"postinstall": "node scripts/postinstall.mjs", | ||
"lint": "eslint .", | ||
@@ -78,0 +87,0 @@ "lint-fix": "eslint . --fix", |
@@ -42,2 +42,10 @@ import { defineConfig } from 'tsup'; | ||
}, | ||
{ | ||
...cfg, | ||
entry: { | ||
index: 'src/sveltekit/index.ts', | ||
}, | ||
external: ['svelte', '@sveltejs/kit', '$app'], | ||
outDir: 'dist/sveltekit', | ||
}, | ||
]); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
145343
33
1315
17
7
No