@spotlightjs/spotlight 4.1.4 → 4.3.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/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # `@spotlightjs/spotlight`
2
2
 
3
- This package combines the Overlay from `@spotlightjs/overlay` and the sidecar from `@spotlightjs/sidecar`.
3
+ This package combines the UI from `@spotlightjs/overlay` and the sidecar from `@spotlightjs/sidecar`.
4
4
 
5
- This means, you only need to install one package and you get everything required for Spotlight. Neat!
5
+ This is the package to use for Spotlight.
package/bin/instrument.js CHANGED
@@ -1,19 +1,26 @@
1
- import { init } from "@sentry/node";
1
+ import { init, flush, consoleLoggingIntegration } from "@sentry/node";
2
2
 
3
- init({
3
+ const sentry = init({
4
4
  dsn: "https://51bcd92dba1128934afd1c5726c84442@o1.ingest.us.sentry.io/4508404727283713",
5
5
  environment: process.env.NODE_ENV || "development",
6
6
  release: `spotlight@${process.env.npm_package_version}`,
7
7
  debug: Boolean(process.env.SENTRY_DEBUG),
8
8
 
9
9
  tracesSampleRate: 1,
10
+ enableLogs: true,
10
11
 
11
- beforeSendTransaction: event => {
12
+ integrations: [
13
+ consoleLoggingIntegration({
14
+ levels: ["log", "info", "warn", "error", "debug"],
15
+ }),
16
+ ],
17
+
18
+ beforeSendTransaction: (event) => {
12
19
  event.server_name = undefined; // Server name might contain PII
13
20
  return event;
14
21
  },
15
22
 
16
- beforeSend: event => {
23
+ beforeSend: (event) => {
17
24
  const exceptions = event.exception?.values;
18
25
  if (!exceptions) {
19
26
  return event;
@@ -37,3 +44,11 @@ init({
37
44
  return event;
38
45
  },
39
46
  });
47
+
48
+ function shutdown() {
49
+ sentry.close();
50
+ }
51
+
52
+ process.on("SIGINT", shutdown);
53
+ process.on("SIGTERM", shutdown);
54
+ // process.on("beforeExit", shutdown);
package/bin/run.js CHANGED
@@ -3,9 +3,8 @@ import { readFileSync } from "node:fs";
3
3
  import Module from "node:module";
4
4
  import { join } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
- import { inflateRawSync } from "node:zlib";
7
6
  import { setContext, startSpan } from "@sentry/node";
8
- import { parseCLIArgs, setupSidecar } from "@spotlightjs/sidecar";
7
+ import { main } from "@spotlightjs/sidecar/cli";
9
8
  import "./instrument.js";
10
9
  const require = Module.createRequire(import.meta.url);
11
10
  let sea = null;
@@ -46,88 +45,11 @@ const readAsset = withTracing(
46
45
  );
47
46
 
48
47
  startSpan({ name: "Spotlight CLI", op: "cli" }, async () => {
49
- startSpan({ name: "ASCII Art", op: "cli.art.ascii" }, () => {
50
- const MAX_COLS = process.stderr.columns;
51
- if (!process.stderr.isTTY || MAX_COLS < 35) return;
52
- let stderrBuffer = "";
53
-
54
- const data = startSpan(
55
- { name: "Inflate ASCII Art Data", op: "cli.art.ascii.inflate" },
56
- () =>
57
- Uint8Array.from(
58
- inflateRawSync(
59
- Buffer.from(
60
- "bY7LCgMxFEK9L5MwDDSL9P//1DJMKGXowoUcUaFZOk8dU2Op9+qZVkYQoFsaEqA6PZxxma1AoMG+TiONTgcfAd741YxxVf8gCzCgWcYB7OSj9sjW7t2/eKxKAxkIYv8NqL3FpVY25CmjrBSuDw==",
61
- "base64"
62
- )
63
- )
64
- )
65
- );
66
- const E = "\x1b[";
67
- const C = `${E}38;5;`;
68
- const M_COL = `${C}96m`;
69
- const F_COL = `${C}61m`;
70
- const BOLD = `${E}1m`;
71
- const RESET = `${E}0m`;
72
- const NL = `${RESET}\n`;
73
- let factor = 0.22;
74
- let c = 0;
75
- let col = 0;
76
- let line = 0;
77
- let lim = 26;
78
- let r = 0;
79
- for (let p of data) {
80
- if (p === 255) {
81
- stderrBuffer += NL;
82
- c = col = 0;
83
- if (line++ === 5) {
84
- factor = factor / -3;
85
- }
86
- lim = Math.round(lim * (1 + factor));
87
- r = Math.round(Math.random() * 18);
88
- } else {
89
- while (p-- >= 0 && col < MAX_COLS) {
90
- if (col < lim - 1) {
91
- stderrBuffer += M_COL;
92
- } else if (col === lim - 1) {
93
- stderrBuffer += F_COL;
94
- } else if (col === lim + r) {
95
- stderrBuffer += `${RESET}${BOLD}`;
96
- }
97
- stderrBuffer += c ? (col >= 35 ? "#" : "s") : " ";
98
- col++;
99
- }
100
- c = !c;
101
- }
102
- }
103
- stderrBuffer += NL;
104
- process.stderr.write(stderrBuffer);
105
- });
106
-
107
48
  await startSpan(
108
49
  { name: "Setup Sidecar", op: "cli.setup.sidecar" },
109
50
  async () => {
110
- const args = parseCLIArgs();
111
- if (args.help) {
112
- console.log(`
113
- Usage: spotlight [options]
114
-
115
- Options:
116
- -p, --port <port> Port to listen on (default: 8969)
117
- --stdio-mcp Enable MCP stdio transport
118
- -d, --debug Enable debug logging
119
- -h, --help Show this help message
120
-
121
- Examples:
122
- spotlight # Start on default port 8969
123
- spotlight --port 3000 # Start on port 3000
124
- spotlight -p 3000 -d # Start on port 3000 with debug logging
125
- `);
126
- process.exit(0);
127
- }
128
51
  const MANIFEST_NAME = "manifest.json";
129
52
  const ENTRY_POINT_NAME = "src/index.html";
130
- const basePath = process.cwd();
131
53
  const filesToServe = Object.create(null);
132
54
 
133
55
  startSpan(
@@ -143,11 +65,9 @@ Examples:
143
65
  }
144
66
  );
145
67
 
146
- await setupSidecar({
147
- ...args,
148
- basePath,
68
+ await main({
69
+ basePath: process.cwd(),
149
70
  filesToServe,
150
- isStandalone: true,
151
71
  });
152
72
  }
153
73
  );