Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@spotlightjs/spotlight

Package Overview
Dependencies
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@spotlightjs/spotlight - npm Package Compare versions

Comparing version 2.1.1 to 2.2.0

dist/overlay/assets/main-01097bb9.js

3

dist/vite-plugin.d.ts
import type { SpotlightOverlayOptions } from '@spotlightjs/overlay';
import type { Connect, PluginOption, ViteDevServer } from 'vite';
import type { PluginOption, ViteDevServer } from 'vite';
export declare function getSpotlightClientModulePath({ server, module, }?: {

@@ -19,3 +19,2 @@ server?: ViteDevServer;

export declare function buildClientInit(options: SpotlightInitOptions): string;
export declare const sourceContextMiddleware: Connect.NextHandleFunction;
export default function spotlight(options?: SpotlightInitOptions): PluginOption;

@@ -1,29 +0,26 @@

import { randomBytes as g } from "node:crypto";
import { readFileSync as S } from "node:fs";
import { CONTEXT_LINES_ENDPOINT as y } from "@spotlightjs/overlay";
import { resolve as O } from "import-meta-resolve";
import * as m from "source-map";
import { setupSidecar as v } from "@spotlightjs/sidecar";
const w = "@spotlightjs/spotlight", T = 7;
function f({
import { randomBytes as f } from "node:crypto";
import { resolve as g } from "import-meta-resolve";
import { setupSidecar as h } from "@spotlightjs/sidecar";
const u = "@spotlightjs/spotlight", d = 7;
function c({
server: t,
module: o = w
module: r = u
} = {}) {
const n = O(o, import.meta.url).slice(T).split("?", 1)[0];
return t && t.config.server.fs.allow.push(n), n;
const e = g(r, import.meta.url).slice(d).split("?", 1)[0];
return t && t.config.server.fs.allow.push(e), e;
}
const _ = /* @__PURE__ */ new Set(["importPath", "integrationNames", "port"]);
function C(t) {
const o = Object.fromEntries(
Object.entries(t).filter(([r, a]) => !r.startsWith("_") && !_.has(r))
const v = /* @__PURE__ */ new Set(["importPath", "integrationNames", "port"]);
function S(t) {
const r = Object.fromEntries(
Object.entries(t).filter(([i, l]) => !i.startsWith("_") && !v.has(i))
);
let n = JSON.stringify({
...o,
let e = JSON.stringify({
...r,
showTriggerButton: t.showTriggerButton !== !1,
injectImmediately: t.injectImmediately !== !1
});
const e = JSON.stringify({ sidecarUrl: t.sidecarUrl, openLastError: !0 });
return n = `{integrations: [${(t.integrationNames || ["sentry"]).map((r) => `Spotlight.${r}(${e})`).join(", ")}], ${n.slice(1)}`, [
`import * as Spotlight from ${JSON.stringify("/@fs" + (t.importPath || f()))};`,
`Spotlight.init(${n});`,
const n = JSON.stringify({ sidecarUrl: t.sidecarUrl, openLastError: !0 });
return e = `{integrations: [${(t.integrationNames || ["sentry"]).map((i) => `Spotlight.${i}(${n})`).join(", ")}], ${e.slice(1)}`, [
`import * as Spotlight from ${JSON.stringify("/@fs" + (t.importPath || c()))};`,
`Spotlight.init(${e});`,
"window.createErrorOverlay=function createErrorOverlay(err) { Spotlight.openSpotlight(); };"

@@ -33,88 +30,4 @@ ].join(`

}
async function M(t) {
try {
return (await fetch(t)).text();
} catch {
return;
}
}
function x(t) {
try {
return JSON.parse(t);
} catch {
return;
}
}
async function E(t, o) {
const n = await new m.SourceMapConsumer(t), e = n.originalPositionFor({
line: o.lineno,
column: o.colno,
bias: m.SourceMapConsumer.LEAST_UPPER_BOUND
});
if (e.source && e.line && e.column) {
o.lineno = e.line, o.colno = e.column;
const i = n.sourceContentFor(e.source), r = (i == null ? void 0 : i.split(void 0)) ?? [];
d(r, o);
}
return e;
}
function d(t, o, n = 5) {
const e = t.length, i = Math.max(Math.min(e - 1, o.lineno - 1), 0);
o.pre_context = t.slice(Math.max(0, i - n), i).map((r) => p(r, 0)), o.context_line = p(t[Math.min(e - 1, i)], o.colno || 0), o.post_context = t.slice(Math.min(i + 1, e), i + 1 + n).map((r) => p(r, 0));
}
function p(t, o) {
let n = t;
const e = n.length;
if (e <= 150)
return n;
o > e && (o = e);
let i = Math.max(o - 60, 0);
i < 5 && (i = 0);
let r = Math.min(i + 140, e);
return r > e - 5 && (r = e), r === e && (i = Math.max(r - 140, 0)), n = n.slice(i, r), i > 0 && (n = `'{snip} ${n}`), r < e && (n += " {snip}"), n;
}
function N(t) {
return !!t.filename && !!t.lineno && !!t.colno;
}
const P = function(t, o, n) {
if (t.url !== y || t.method !== "PUT")
return n();
let e = "";
t.on("data", (i) => {
e += i;
}), t.on("end", async () => {
const i = x(e);
if (!i) {
o.writeHead(500), o.end();
return;
}
for (const a of i.frames ?? []) {
if (!N(a) || // let's ignore dependencies for now with this naive check
a.filename.includes("/node_modules/"))
continue;
const { filename: c } = a;
if (c.includes("://")) {
const s = await M(a.filename);
if (!s)
continue;
const l = s.match(/\/\/# sourceMappingURL=data:application\/json;base64,(.*)/);
if (l && l[1]) {
const u = l[1], h = Buffer.from(u, "base64").toString("utf-8");
await E(h, a);
}
} else if (!c.includes(":"))
try {
const s = S(c, { encoding: "utf-8" }).split(/\r?\n/);
d(s, a);
} catch (s) {
if (s.code !== "ENOENT")
throw s;
}
}
const r = JSON.stringify(i);
o.writeHead(200, { "Content-Type": "application/json" }), o.end(r);
});
};
async function j(t, o = "http://localhost:8969/stream") {
var l;
async function y(t, r = "http://localhost:8969/stream") {
var a;
if (!t.errors) {

@@ -124,8 +37,8 @@ console.log(t);

}
const n = t.errors[0], e = (l = t.pluginCode) == null ? void 0 : l.split(`
`), i = n.location.lineText, r = e == null ? void 0 : e.indexOf(i), a = g(16).toString("hex"), c = /* @__PURE__ */ new Date(), s = [
{ event_id: a, sent_at: c.toISOString() },
const e = t.errors[0], n = (a = t.pluginCode) == null ? void 0 : a.split(`
`), o = e.location.lineText, i = n == null ? void 0 : n.indexOf(o), l = f(16).toString("hex"), s = /* @__PURE__ */ new Date(), p = [
{ event_id: l, sent_at: s.toISOString() },
{ type: "event" },
{
event_id: a,
event_id: l,
level: "error",

@@ -135,3 +48,3 @@ platform: "javascript",

tags: { runtime: "vite" },
timestamp: c.getTime(),
timestamp: s.getTime(),
exception: {

@@ -145,12 +58,12 @@ values: [

},
value: n.text,
value: e.text,
stacktrace: {
frames: [
n ? {
filename: n.location.file,
lineno: n.location.line,
colno: n.location.column,
context_line: i,
pre_context: e == null ? void 0 : e.slice(0, r),
post_context: r != null && r > -1 ? e == null ? void 0 : e.slice(r + 1) : void 0
e ? {
filename: e.location.file,
lineno: e.location.line,
colno: e.location.column,
context_line: o,
pre_context: n == null ? void 0 : n.slice(0, i),
post_context: i != null && i > -1 ? n == null ? void 0 : n.slice(i + 1) : void 0
} : {

@@ -165,23 +78,23 @@ filename: t.id

}
].map((u) => JSON.stringify(u)).join(`
].map((m) => JSON.stringify(m)).join(`
`);
return await fetch(o, {
return await fetch(r, {
method: "POST",
body: s,
body: p,
headers: { "Content-Type": "application/x-sentry-envelope" }
});
}
function B(t = {}) {
let o;
function w(t = {}) {
let r;
return {
name: "spotlight",
apply: "serve",
transform(n, e) {
if (e.endsWith("vite/dist/client/client.mjs"))
return `${C({ ...t, importPath: o })}${n}`;
transform(e, n) {
if (n.endsWith("vite/dist/client/client.mjs"))
return `${S({ ...t, importPath: r })}${e}`;
},
configureServer(n) {
return v({ port: t.port }), n.middlewares.use(P), o = f({ server: n }), () => n.middlewares.use(async function(i, r, a, c) {
if (await j(i), a.headersSent)
return c(i);
configureServer(e) {
return h({ port: t.port }), r = c({ server: e }), () => e.middlewares.use(async function(o, i, l, s) {
if (await y(o), l.headersSent)
return s(o);
});

@@ -192,6 +105,5 @@ }

export {
C as buildClientInit,
B as default,
f as getSpotlightClientModulePath,
P as sourceContextMiddleware
S as buildClientInit,
w as default,
c as getSpotlightClientModulePath
};
{
"name": "@spotlightjs/spotlight",
"description": "Spotlight - Sentry for development. Containing the overlay and the sidecar.",
"version": "2.1.1",
"version": "2.2.0",
"license": "Apache-2.0",

@@ -12,3 +12,3 @@ "type": "module",

"bin": {
"spotlight-sidecar": "./bin/run.js"
"spotlight": "./bin/run.js"
},

@@ -36,6 +36,5 @@ "main": "./dist/overlay.cjs",

"dependencies": {
"source-map": "^0.7.4",
"import-meta-resolve": "^4.1.0",
"@spotlightjs/overlay": "2.1.0",
"@spotlightjs/sidecar": "1.5.0"
"@spotlightjs/overlay": "2.2.0",
"@spotlightjs/sidecar": "1.6.0"
},

@@ -51,3 +50,7 @@ "devDependencies": {

},
"engines": {
"node": ">=18"
},
"scripts": {
"start": "./bin/run.js",
"dev": "vite build --watch",

@@ -54,0 +57,0 @@ "build": "vite build && vite build --config vite.overlay.config.ts && tsc",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc