@ytspar/sweetlink 1.12.1 → 1.13.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.
@@ -132,6 +132,7 @@ These scenarios require multi-step browser state that Sweetlink cannot maintain
132
132
  | **Click then screenshot** (when click triggers navigation/animation) | Same statefulness issue — click and screenshot may not share the same page | `open` -> `click` -> `screenshot` |
133
133
  | **Multi-step interactions** (type + submit + wait for result) | Each command is stateless | `open` -> `type` -> `press Enter` -> `screenshot` |
134
134
  | **Custom viewport dimensions** (not `mobile`/`tablet` presets) | `--viewport` only supports named presets | `agent-browser open --viewport 1600x900` or use Sweetlink `--force-cdp` with preset |
135
+ | **Verifying SVG content** (colors, icons, shapes) | html2canvas does not render SVG elements — they appear blank/missing. Fine for layout checks where SVG content doesn't matter, but wrong when the SVGs themselves are what you're verifying (e.g., icon colors, logo accuracy) | Use Sweetlink with `--force-cdp`, or `agent-browser open` -> `screenshot` |
135
136
 
136
137
  > **Self-updating rule:** When you encounter a NEW Sweetlink failure mode not listed above — i.e., you try Sweetlink, it fails or produces incorrect results for a reason that would apply generally (not a transient network/server issue) — you MUST append a new row to this table before continuing with the Agent-Browser fallback. This keeps the list exhaustive and prevents future sessions from repeating the same mistake.
137
138
 
@@ -341,6 +342,7 @@ pnpm sweetlink screenshot --selector ".fixed-component" --output .tmp/screenshot
341
342
  | DOM queries | Sweetlink (`query`) | |
342
343
  | Click then screenshot same page | **Agent-Browser** | Sweetlink can't guarantee state between commands |
343
344
  | Navigate to specific page | Sweetlink (`--url` flag) | |
345
+ | Verifying SVG content (icons, colors) | Sweetlink (`--force-cdp`) or **Agent-Browser** | html2canvas can't render SVGs; only matters when SVG content is what you're checking |
344
346
  | Viewport testing (mobile/tablet) | Sweetlink (`--force-cdp --viewport`) | |
345
347
  | Custom viewport dimensions | **Agent-Browser** | Sweetlink only supports named presets |
346
348
  | Non-dev-server URL | Agent-Browser | |
File without changes
File without changes
package/dist/next.d.ts ADDED
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Sweetlink Next.js Plugin
3
+ *
4
+ * Zero-config integration for Next.js projects.
5
+ * Wraps your Next.js config to automatically start the Sweetlink WebSocket server in dev mode.
6
+ *
7
+ * Usage:
8
+ * ```javascript
9
+ * // next.config.mjs
10
+ * import { withSweetlink } from '@ytspar/sweetlink/next';
11
+ *
12
+ * const nextConfig = { ... };
13
+ * export default withSweetlink(nextConfig);
14
+ * ```
15
+ *
16
+ * Port detection (in order of precedence):
17
+ * 1. process.argv: `--port 3002` or `-p 3002`
18
+ * 2. process.env.PORT
19
+ * 3. Default: 3000
20
+ */
21
+ export interface WithSweetlinkOptions {
22
+ /**
23
+ * Override the app port detection. If not specified, auto-detected from
24
+ * process.argv (--port / -p) or process.env.PORT, defaulting to 3000.
25
+ */
26
+ port?: number;
27
+ }
28
+ /**
29
+ * Wrap a Next.js config to auto-start Sweetlink in development.
30
+ *
31
+ * Mirrors the Vite plugin (`@ytspar/sweetlink/vite`) pattern:
32
+ * - Detects the app port from CLI args
33
+ * - Starts the WebSocket server on `appPort + 6223`
34
+ * - Registers graceful shutdown handlers
35
+ * - No-ops in production
36
+ */
37
+ export declare function withSweetlink<T>(nextConfig: T, options?: WithSweetlinkOptions): T;
38
+ export default withSweetlink;
39
+ //# sourceMappingURL=next.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"next.d.ts","sourceRoot":"","sources":["../src/next.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAKH,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AA+BD;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,CAAC,CAwBjF;AAED,eAAe,aAAa,CAAC"}
package/dist/next.js ADDED
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Sweetlink Next.js Plugin
3
+ *
4
+ * Zero-config integration for Next.js projects.
5
+ * Wraps your Next.js config to automatically start the Sweetlink WebSocket server in dev mode.
6
+ *
7
+ * Usage:
8
+ * ```javascript
9
+ * // next.config.mjs
10
+ * import { withSweetlink } from '@ytspar/sweetlink/next';
11
+ *
12
+ * const nextConfig = { ... };
13
+ * export default withSweetlink(nextConfig);
14
+ * ```
15
+ *
16
+ * Port detection (in order of precedence):
17
+ * 1. process.argv: `--port 3002` or `-p 3002`
18
+ * 2. process.env.PORT
19
+ * 3. Default: 3000
20
+ */
21
+ import { closeSweetlink, initSweetlink } from './server/index.js';
22
+ import { WS_PORT_OFFSET } from './types.js';
23
+ /**
24
+ * Detect the Next.js dev server port from CLI args or environment.
25
+ *
26
+ * Next.js `--port` flag does NOT set process.env.PORT, so we parse argv directly.
27
+ */
28
+ function detectNextPort() {
29
+ const args = process.argv;
30
+ for (let i = 0; i < args.length; i++) {
31
+ const arg = args[i];
32
+ // --port 3002 or -p 3002
33
+ if ((arg === '--port' || arg === '-p') && args[i + 1]) {
34
+ const port = parseInt(args[i + 1], 10);
35
+ if (!isNaN(port))
36
+ return port;
37
+ }
38
+ // --port=3002
39
+ if (arg?.startsWith('--port=')) {
40
+ const port = parseInt(arg.split('=')[1], 10);
41
+ if (!isNaN(port))
42
+ return port;
43
+ }
44
+ }
45
+ if (process.env.PORT) {
46
+ const port = parseInt(process.env.PORT, 10);
47
+ if (!isNaN(port))
48
+ return port;
49
+ }
50
+ return 3000;
51
+ }
52
+ /**
53
+ * Wrap a Next.js config to auto-start Sweetlink in development.
54
+ *
55
+ * Mirrors the Vite plugin (`@ytspar/sweetlink/vite`) pattern:
56
+ * - Detects the app port from CLI args
57
+ * - Starts the WebSocket server on `appPort + 6223`
58
+ * - Registers graceful shutdown handlers
59
+ * - No-ops in production
60
+ */
61
+ export function withSweetlink(nextConfig, options) {
62
+ if (process.env.NODE_ENV !== 'development')
63
+ return nextConfig;
64
+ const appPort = options?.port ?? detectNextPort();
65
+ const wsPort = appPort + WS_PORT_OFFSET;
66
+ initSweetlink({
67
+ port: wsPort,
68
+ appPort,
69
+ onReady: (actualPort) => {
70
+ if (actualPort !== wsPort) {
71
+ console.log(`[Sweetlink] Using port ${actualPort} (${wsPort} was in use)`);
72
+ }
73
+ console.log(`[Sweetlink] Ready for devbar connections (app port: ${appPort})`);
74
+ },
75
+ });
76
+ const handleShutdown = () => {
77
+ closeSweetlink();
78
+ };
79
+ process.on('SIGTERM', handleShutdown);
80
+ process.on('SIGINT', handleShutdown);
81
+ return nextConfig;
82
+ }
83
+ export default withSweetlink;
84
+ //# sourceMappingURL=next.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"next.js","sourceRoot":"","sources":["../src/next.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAU5C;;;;GAIG;AACH,SAAS,cAAc;IACrB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAC1B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,yBAAyB;QACzB,IAAI,CAAC,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YACtD,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAE,EAAE,EAAE,CAAC,CAAC;YACxC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;gBAAE,OAAO,IAAI,CAAC;QAChC,CAAC;QACD,cAAc;QACd,IAAI,GAAG,EAAE,UAAU,CAAC,SAAS,CAAC,EAA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AE,cAAc,CAAC,CAAC;IAErC,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,eAAe,aAAa,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ytspar/sweetlink",
3
- "version": "1.12.1",
3
+ "version": "1.13.0",
4
4
  "description": "Autonomous development toolkit for AI agents - screenshots, DOM queries, console logs, and JavaScript execution via WebSocket and Chrome DevTools Protocol",
5
5
  "keywords": [
6
6
  "autonomous-development",
@@ -80,6 +80,10 @@
80
80
  "./auto": {
81
81
  "types": "./dist/auto.d.ts",
82
82
  "import": "./dist/auto.js"
83
+ },
84
+ "./next": {
85
+ "types": "./dist/next.d.ts",
86
+ "import": "./dist/next.js"
83
87
  }
84
88
  },
85
89
  "bin": {
@@ -100,6 +104,14 @@
100
104
  "node": ">=20.0.0"
101
105
  },
102
106
  "private": false,
107
+ "scripts": {
108
+ "prepublishOnly": "node ../../scripts/check-release-notes.mjs && rm -rf dist && tsc",
109
+ "build": "rm -rf dist && tsc",
110
+ "test": "vitest run",
111
+ "dev": "node dist/cli/sweetlink-dev.js",
112
+ "typecheck": "tsc --noEmit",
113
+ "clean": "rm -rf dist claude-context"
114
+ },
103
115
  "peerDependencies": {
104
116
  "axe-core": "^4.0.0",
105
117
  "html2canvas-pro": "^2.0.0",
@@ -146,12 +158,5 @@
146
158
  "bugs": {
147
159
  "url": "https://github.com/ytspar/devbar/issues"
148
160
  },
149
- "homepage": "https://github.com/ytspar/devbar/tree/main/packages/sweetlink#readme",
150
- "scripts": {
151
- "build": "rm -rf dist && tsc",
152
- "test": "vitest run",
153
- "dev": "node dist/cli/sweetlink-dev.js",
154
- "typecheck": "tsc --noEmit",
155
- "clean": "rm -rf dist claude-context"
156
- }
157
- }
161
+ "homepage": "https://github.com/ytspar/devbar/tree/main/packages/sweetlink#readme"
162
+ }