@spotlightjs/spotlight
Advanced tools
Comparing version 2.5.0 to 2.6.0
#!/usr/bin/env node | ||
const { setupSidecar } = await import('../dist/sidecar.js'); | ||
import { setupSidecar } from '@spotlightjs/sidecar'; | ||
import { inflateRawSync } from 'node:zlib'; | ||
import { readFileSync } from 'node:fs'; | ||
import { join } from 'node:path'; | ||
import * as sea from 'node:sea'; | ||
import { fileURLToPath } from 'node:url'; | ||
if (process.stdout.isTTY) { | ||
const data = Uint8Array.from( | ||
inflateRawSync( | ||
Buffer.from( | ||
'bY7LCgMxFEK9L5MwDDSL9P//1DJMKGXowoUcUaFZOk8dU2Op9+qZVkYQoFsaEqA6PZxxma1AoMG+TiONTgcfAd741YxxVf8gCzCgWcYB7OSj9sjW7t2/eKxKAxkIYv8NqL3FpVY25CmjrBSuDw==', | ||
'base64', | ||
), | ||
), | ||
); | ||
const E = '\x1b['; | ||
const C = `${E}38;5;`; | ||
const M_COL = `${C}96m`; | ||
const F_COL = `${C}61m`; | ||
const BOLD = `${E}1m`; | ||
const RESET = `${E}0m`; | ||
const NL = `${RESET}\n`; | ||
let factor = 0.22; | ||
let c = 0; | ||
let col = 0; | ||
let line = 0; | ||
let lim = 26; | ||
let r = 0; | ||
for (let p of data) { | ||
if (p === 255) { | ||
process.stdout.write(NL); | ||
c = col = 0; | ||
if (line++ === 5) { | ||
factor = factor / -3; | ||
} | ||
lim = Math.round(lim * (1 + factor)); | ||
r = Math.round(Math.random() * 18); | ||
} else { | ||
while (p-- >= 0) { | ||
if (col < lim - 1) { | ||
process.stdout.write(M_COL); | ||
} else if (col === lim - 1) { | ||
process.stdout.write(F_COL); | ||
} else if (col === lim + r) { | ||
process.stdout.write(`${RESET}${BOLD}`); | ||
} | ||
process.stdout.write(c ? (col >= 35 ? '#' : 's') : ' '); | ||
col++; | ||
} | ||
c = !c; | ||
} | ||
} | ||
process.stdout.write(NL); | ||
} | ||
const readAsset = sea.isSea() | ||
? name => Buffer.from(sea.getRawAsset(name)) | ||
: (() => { | ||
const ASSET_DIR = join(fileURLToPath(import.meta.url), '../../dist/overlay/'); | ||
return name => readFileSync(join(ASSET_DIR, name)); | ||
})(); | ||
const port = process.argv.length >= 3 ? Number(process.argv[2]) : undefined; | ||
import { join } from 'path'; | ||
import { fileURLToPath } from 'url'; | ||
setupSidecar({ port, basePath: join(fileURLToPath(import.meta.url), '../../dist/overlay/') }); | ||
const MANIFEST_NAME = 'manifest.json'; | ||
const ENTRY_POINT_NAME = 'src/index.html'; | ||
const basePath = process.cwd(); | ||
const filesToServe = Object.create(null); | ||
// Following the guide here: https://vite.dev/guide/backend-integration.html | ||
const manifest = JSON.parse(readAsset(MANIFEST_NAME)); | ||
filesToServe[ENTRY_POINT_NAME] = readAsset(ENTRY_POINT_NAME); | ||
const entries = Object.values(manifest); | ||
for (const entry of entries) { | ||
filesToServe[entry.file] = readAsset(entry.file); | ||
} | ||
setupSidecar({ port, basePath, filesToServe }); |
@@ -1,16 +0,16 @@ | ||
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({ | ||
import { randomBytes as g } from "node:crypto"; | ||
import { resolve as u } from "import-meta-resolve"; | ||
import { setupSidecar as d } from "@spotlightjs/sidecar"; | ||
const S = "@spotlightjs/spotlight", v = 7; | ||
function p({ | ||
server: t, | ||
module: r = u | ||
module: r = S | ||
} = {}) { | ||
const e = g(r, import.meta.url).slice(d).split("?", 1)[0]; | ||
const e = u(r, import.meta.url).slice(v).split("?", 1)[0]; | ||
return t && t.config.server.fs.allow.push(e), e; | ||
} | ||
const v = /* @__PURE__ */ new Set(["importPath", "integrationNames", "port"]); | ||
function S(t) { | ||
const y = /* @__PURE__ */ new Set(["importPath", "integrationNames", "port"]); | ||
function O(t) { | ||
const r = Object.fromEntries( | ||
Object.entries(t).filter(([i, l]) => !i.startsWith("_") && !v.has(i)) | ||
Object.entries(t).filter(([i]) => !i.startsWith("_") && !y.has(i)) | ||
); | ||
@@ -22,5 +22,5 @@ let e = JSON.stringify({ | ||
}); | ||
const n = JSON.stringify({ sidecarUrl: t.sidecarUrl, openLastError: !0 }); | ||
const n = JSON.stringify({ 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()))};`, | ||
`import * as Spotlight from ${JSON.stringify("/@fs" + (t.importPath || p()))};`, | ||
`Spotlight.init(${e});`, | ||
@@ -31,4 +31,4 @@ "window.createErrorOverlay=function createErrorOverlay(err) { Spotlight.openSpotlight(); };" | ||
} | ||
async function y(t, r = "http://localhost:8969/stream") { | ||
var a; | ||
async function w(t, r = "http://localhost:8969/stream") { | ||
var c; | ||
if (!t.errors) { | ||
@@ -38,8 +38,11 @@ console.log(t); | ||
} | ||
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() }, | ||
const e = t.errors[0], n = (c = t.pluginCode) == null ? void 0 : c.split(` | ||
`), o = e.location.lineText, i = n == null ? void 0 : n.indexOf(o), s = g(16).toString("hex"), a = /* @__PURE__ */ new Date(), m = new URL(r); | ||
let l = r; | ||
m.pathname.endsWith("/stream") || (l = new URL("/stream", r).href); | ||
const f = [ | ||
{ event_id: s, sent_at: a.toISOString() }, | ||
{ type: "event" }, | ||
{ | ||
event_id: l, | ||
event_id: s, | ||
level: "error", | ||
@@ -49,3 +52,3 @@ platform: "javascript", | ||
tags: { runtime: "vite" }, | ||
timestamp: s.getTime(), | ||
timestamp: a.getTime(), | ||
exception: { | ||
@@ -78,11 +81,11 @@ values: [ | ||
} | ||
].map((m) => JSON.stringify(m)).join(` | ||
].map((h) => JSON.stringify(h)).join(` | ||
`); | ||
return await fetch(r, { | ||
return await fetch(l, { | ||
method: "POST", | ||
body: p, | ||
body: f, | ||
headers: { "Content-Type": "application/x-sentry-envelope" } | ||
}); | ||
} | ||
function w(t = {}) { | ||
function _(t = {}) { | ||
let r; | ||
@@ -94,8 +97,8 @@ return { | ||
if (n.endsWith("vite/dist/client/client.mjs")) | ||
return `${S({ ...t, importPath: r })}${e}`; | ||
return `${O({ ...t, importPath: r })}${e}`; | ||
}, | ||
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); | ||
return d({ port: t.port }), r = p({ server: e }), () => e.middlewares.use(async function(o, i, s, a) { | ||
if (await w(o, t.sidecarUrl), s.headersSent) | ||
return a(o); | ||
}); | ||
@@ -106,5 +109,5 @@ } | ||
export { | ||
S as buildClientInit, | ||
w as default, | ||
c as getSpotlightClientModulePath | ||
O as buildClientInit, | ||
_ as default, | ||
p as getSpotlightClientModulePath | ||
}; |
{ | ||
"name": "@spotlightjs/spotlight", | ||
"description": "Spotlight - Sentry for development. Containing the overlay and the sidecar.", | ||
"version": "2.5.0", | ||
"version": "2.6.0", | ||
"license": "Apache-2.0", | ||
@@ -36,9 +36,12 @@ "type": "module", | ||
"import-meta-resolve": "^4.1.0", | ||
"@spotlightjs/overlay": "2.6.0", | ||
"@spotlightjs/sidecar": "1.8.0" | ||
"macho-unsign": "^2.0.6", | ||
"portable-executable-signature": "^2.0.6", | ||
"postject": "1.0.0-alpha.6", | ||
"@spotlightjs/overlay": "2.7.0", | ||
"@spotlightjs/sidecar": "1.9.0" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^18", | ||
"typescript": "^5.0.2", | ||
"vite": "^4.5.3", | ||
"@types/node": "^18.19.55", | ||
"typescript": "^5.6.2", | ||
"vite": "^5.4.11", | ||
"@spotlightjs/tsconfig": "1.0.0" | ||
@@ -55,3 +58,3 @@ }, | ||
"dev": "vite build --watch", | ||
"build": "vite build && vite build --config vite.overlay.config.ts && tsc", | ||
"build": "vite build && vite build --config vite.overlay.config.ts && vite build --config vite.binary.config.ts && ./bin/build.js && tsc", | ||
"build:watch": "vite build --watch", | ||
@@ -58,0 +61,0 @@ "yalc:publish": "yalc publish --push --sig --private", |
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 2 instances 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
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 7 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
120699726
22
4568
6
3
14
12
+ Addedmacho-unsign@^2.0.6
+ Addedpostject@1.0.0-alpha.6
+ Added@spotlightjs/overlay@2.7.0(transitive)
+ Added@spotlightjs/sidecar@1.9.0(transitive)
+ Addedcommander@9.5.0(transitive)
+ Addedmacho-unsign@2.0.6(transitive)
+ Addedportable-executable-signature@2.0.6(transitive)
+ Addedpostject@1.0.0-alpha.6(transitive)
- Removed@spotlightjs/overlay@2.6.0(transitive)
- Removed@spotlightjs/sidecar@1.8.0(transitive)
Updated@spotlightjs/overlay@2.7.0
Updated@spotlightjs/sidecar@1.9.0