@spotlightjs/spotlight 3.0.1 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/run.js +78 -43
- package/dist/overlay/assets/index-BfFEknL3.js +1 -0
- package/dist/overlay/assets/main.js +121 -156
- package/dist/overlay/manifest.json +11 -1
- package/package.json +5 -10
- package/dist/vite-plugin.cjs +0 -4
- package/dist/vite-plugin.d.ts +0 -19
- package/dist/vite-plugin.js +0 -106
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
{
|
|
2
|
+
"../overlay/dist/index-BfFEknL3.js": {
|
|
3
|
+
"file": "assets/index-BfFEknL3.js",
|
|
4
|
+
"name": "index-BfFEknL3",
|
|
5
|
+
"src": "../overlay/dist/index-BfFEknL3.js",
|
|
6
|
+
"isDynamicEntry": true
|
|
7
|
+
},
|
|
2
8
|
"src/index.html": {
|
|
3
9
|
"file": "assets/main.js",
|
|
4
10
|
"name": "main",
|
|
5
11
|
"src": "src/index.html",
|
|
6
|
-
"isEntry": true
|
|
12
|
+
"isEntry": true,
|
|
13
|
+
"dynamicImports": [
|
|
14
|
+
"../overlay/dist/index-BfFEknL3.js",
|
|
15
|
+
"../overlay/dist/index-BfFEknL3.js"
|
|
16
|
+
]
|
|
7
17
|
}
|
|
8
18
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spotlightjs/spotlight",
|
|
3
3
|
"description": "Spotlight - Sentry for development. Containing the overlay and the sidecar.",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "4.0.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
@@ -24,21 +24,16 @@
|
|
|
24
24
|
"types": "./dist/sidecar.d.ts",
|
|
25
25
|
"import": "./dist/sidecar.js",
|
|
26
26
|
"require": "./dist/sidecar.cjs"
|
|
27
|
-
},
|
|
28
|
-
"./vite-plugin": {
|
|
29
|
-
"types": "./dist/vite-plugin.d.ts",
|
|
30
|
-
"import": "./dist/vite-plugin.js",
|
|
31
|
-
"require": "./dist/vite-plugin.cjs"
|
|
32
27
|
}
|
|
33
28
|
},
|
|
34
29
|
"dependencies": {
|
|
35
|
-
"@sentry/node": "^
|
|
30
|
+
"@sentry/node": "^10",
|
|
36
31
|
"import-meta-resolve": "^4.1.0",
|
|
37
|
-
"@spotlightjs/overlay": "
|
|
38
|
-
"@spotlightjs/sidecar": "
|
|
32
|
+
"@spotlightjs/overlay": "4.0.0",
|
|
33
|
+
"@spotlightjs/sidecar": "2.0.0"
|
|
39
34
|
},
|
|
40
35
|
"devDependencies": {
|
|
41
|
-
"@types/node": "^
|
|
36
|
+
"@types/node": "^22.15.21",
|
|
42
37
|
"fossilize": "^0.4.2",
|
|
43
38
|
"typescript": "^5.6.2",
|
|
44
39
|
"vite": "^5.4.19",
|
package/dist/vite-plugin.cjs
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const h=require("node:crypto"),S=require("import-meta-resolve"),v=require("@spotlightjs/sidecar");var a=typeof document<"u"?document.currentScript:null;const y="@spotlightjs/spotlight",O=7;function c({server:t,module:r=y}={}){const e=S.resolve(r,typeof document>"u"?require("url").pathToFileURL(__filename).href:a&&a.tagName.toUpperCase()==="SCRIPT"&&a.src||new URL("vite-plugin.cjs",document.baseURI).href).slice(O).split("?",1)[0];return t&&t.config.server.fs.allow.push(e),e}const _=new Set(["importPath","integrationNames","port"]);function m(t){const r=Object.fromEntries(Object.entries(t).filter(([i])=>!i.startsWith("_")&&!_.has(i)));let e=JSON.stringify({...r,showTriggerButton:t.showTriggerButton!==!1,injectImmediately:t.injectImmediately!==!1});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()}`)};`,`Spotlight.init(${e});`,"window.createErrorOverlay=function createErrorOverlay(err) { Spotlight.openSpotlight(); };"].join(`
|
|
2
|
-
`)}async function w(t,r="http://localhost:8969/stream"){var u;if(!t.errors){console.log(t);return}const e=t.errors[0],n=(u=t.pluginCode)==null?void 0:u.split(`
|
|
3
|
-
`),o=e.location.lineText,i=n==null?void 0:n.indexOf(o),s=h.randomBytes(16).toString("hex"),l=new Date,d=new URL(r);let p=r;d.pathname.endsWith("/stream")||(p=new URL("/stream",r).href);const f=[{event_id:s,sent_at:l.toISOString()},{type:"event"},{event_id:s,level:"error",platform:"javascript",environment:"development",tags:{runtime:"vite"},timestamp:l.getTime(),exception:{values:[{type:"Error",mechanism:{type:"instrument",handled:!1},value:e.text,stacktrace:{frames:[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}:{filename:t.id}]}}]}}].map(g=>JSON.stringify(g)).join(`
|
|
4
|
-
`);return await fetch(p,{method:"POST",body:f,headers:{"Content-Type":"application/x-sentry-envelope"}})}function T(t={}){let r;return{name:"spotlight",apply:"serve",transform(e,n){if(n.endsWith("vite/dist/client/client.mjs"))return`${m({...t,importPath:r})}${e}`},configureServer(e){return v.setupSidecar({port:t.port}),r=c({server:e}),()=>e.middlewares.use(async function(o,i,s,l){if(await w(o,t.sidecarUrl),s.headersSent)return l(o)})}}}exports.buildClientInit=m;exports.default=T;exports.getSpotlightClientModulePath=c;
|
package/dist/vite-plugin.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { SpotlightOverlayOptions } from "@spotlightjs/overlay";
|
|
2
|
-
import type { PluginOption, ViteDevServer } from "vite";
|
|
3
|
-
export declare function getSpotlightClientModulePath({ server, module, }?: {
|
|
4
|
-
server?: ViteDevServer;
|
|
5
|
-
module?: string;
|
|
6
|
-
}): string;
|
|
7
|
-
export type SpotlightIntegration = "sentry" | "viteInspect";
|
|
8
|
-
export type SpotlightInitOptions = {
|
|
9
|
-
importPath?: string;
|
|
10
|
-
integrationNames?: SpotlightIntegration[];
|
|
11
|
-
port?: number;
|
|
12
|
-
/**
|
|
13
|
-
* Additional debug options.
|
|
14
|
-
* WARNING: These options are not part of the public API and may change at any time.
|
|
15
|
-
*/
|
|
16
|
-
__debugOptions?: Record<string, unknown>;
|
|
17
|
-
} & SpotlightOverlayOptions;
|
|
18
|
-
export declare function buildClientInit(options: SpotlightInitOptions): string;
|
|
19
|
-
export default function spotlight(options?: SpotlightInitOptions): PluginOption;
|
package/dist/vite-plugin.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { randomBytes as g } from "node:crypto";
|
|
2
|
-
import { resolve as u } from "import-meta-resolve";
|
|
3
|
-
import { setupSidecar as d } from "@spotlightjs/sidecar";
|
|
4
|
-
const S = "@spotlightjs/spotlight", v = 7;
|
|
5
|
-
function p({
|
|
6
|
-
server: t,
|
|
7
|
-
module: r = S
|
|
8
|
-
} = {}) {
|
|
9
|
-
const e = u(r, import.meta.url).slice(v).split("?", 1)[0];
|
|
10
|
-
return t && t.config.server.fs.allow.push(e), e;
|
|
11
|
-
}
|
|
12
|
-
const y = /* @__PURE__ */ new Set(["importPath", "integrationNames", "port"]);
|
|
13
|
-
function O(t) {
|
|
14
|
-
const r = Object.fromEntries(
|
|
15
|
-
Object.entries(t).filter(([i]) => !i.startsWith("_") && !y.has(i))
|
|
16
|
-
);
|
|
17
|
-
let e = JSON.stringify({
|
|
18
|
-
...r,
|
|
19
|
-
showTriggerButton: t.showTriggerButton !== !1,
|
|
20
|
-
injectImmediately: t.injectImmediately !== !1
|
|
21
|
-
});
|
|
22
|
-
const n = JSON.stringify({ openLastError: !0 });
|
|
23
|
-
return e = `{integrations: [${(t.integrationNames || ["sentry"]).map((i) => `Spotlight.${i}(${n})`).join(", ")}], ${e.slice(1)}`, [
|
|
24
|
-
`import * as Spotlight from ${JSON.stringify(`/@fs${t.importPath || p()}`)};`,
|
|
25
|
-
`Spotlight.init(${e});`,
|
|
26
|
-
"window.createErrorOverlay=function createErrorOverlay(err) { Spotlight.openSpotlight(); };"
|
|
27
|
-
].join(`
|
|
28
|
-
`);
|
|
29
|
-
}
|
|
30
|
-
async function w(t, r = "http://localhost:8969/stream") {
|
|
31
|
-
var c;
|
|
32
|
-
if (!t.errors) {
|
|
33
|
-
console.log(t);
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
const e = t.errors[0], n = (c = t.pluginCode) == null ? void 0 : c.split(`
|
|
37
|
-
`), 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);
|
|
38
|
-
let l = r;
|
|
39
|
-
m.pathname.endsWith("/stream") || (l = new URL("/stream", r).href);
|
|
40
|
-
const f = [
|
|
41
|
-
{ event_id: s, sent_at: a.toISOString() },
|
|
42
|
-
{ type: "event" },
|
|
43
|
-
{
|
|
44
|
-
event_id: s,
|
|
45
|
-
level: "error",
|
|
46
|
-
platform: "javascript",
|
|
47
|
-
environment: "development",
|
|
48
|
-
tags: { runtime: "vite" },
|
|
49
|
-
timestamp: a.getTime(),
|
|
50
|
-
exception: {
|
|
51
|
-
values: [
|
|
52
|
-
{
|
|
53
|
-
type: "Error",
|
|
54
|
-
mechanism: {
|
|
55
|
-
type: "instrument",
|
|
56
|
-
handled: !1
|
|
57
|
-
},
|
|
58
|
-
value: e.text,
|
|
59
|
-
stacktrace: {
|
|
60
|
-
frames: [
|
|
61
|
-
e ? {
|
|
62
|
-
filename: e.location.file,
|
|
63
|
-
lineno: e.location.line,
|
|
64
|
-
colno: e.location.column,
|
|
65
|
-
context_line: o,
|
|
66
|
-
pre_context: n == null ? void 0 : n.slice(0, i),
|
|
67
|
-
post_context: i != null && i > -1 ? n == null ? void 0 : n.slice(i + 1) : void 0
|
|
68
|
-
} : {
|
|
69
|
-
filename: t.id
|
|
70
|
-
}
|
|
71
|
-
]
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
]
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
].map((h) => JSON.stringify(h)).join(`
|
|
78
|
-
`);
|
|
79
|
-
return await fetch(l, {
|
|
80
|
-
method: "POST",
|
|
81
|
-
body: f,
|
|
82
|
-
headers: { "Content-Type": "application/x-sentry-envelope" }
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
function _(t = {}) {
|
|
86
|
-
let r;
|
|
87
|
-
return {
|
|
88
|
-
name: "spotlight",
|
|
89
|
-
apply: "serve",
|
|
90
|
-
transform(e, n) {
|
|
91
|
-
if (n.endsWith("vite/dist/client/client.mjs"))
|
|
92
|
-
return `${O({ ...t, importPath: r })}${e}`;
|
|
93
|
-
},
|
|
94
|
-
configureServer(e) {
|
|
95
|
-
return d({ port: t.port }), r = p({ server: e }), () => e.middlewares.use(async function(o, i, s, a) {
|
|
96
|
-
if (await w(o, t.sidecarUrl), s.headersSent)
|
|
97
|
-
return a(o);
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
export {
|
|
103
|
-
O as buildClientInit,
|
|
104
|
-
_ as default,
|
|
105
|
-
p as getSpotlightClientModulePath
|
|
106
|
-
};
|