ccphoto 0.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 CCPhoto Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,251 @@
1
+ # CCPhoto
2
+
3
+ [![npm version](https://img.shields.io/npm/v/ccphoto)](https://www.npmjs.com/package/ccphoto)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
5
+ [![Node.js](https://img.shields.io/badge/node-%3E%3D18-brightgreen)](https://nodejs.org)
6
+
7
+ **Bridge your phone camera to Claude Code over the local network.**
8
+
9
+ CCPhoto is an MCP server that lets you take photos on your phone and send them
10
+ directly to Claude Code. Point your phone at a circuit board, a whiteboard, a
11
+ label -- anything -- and Claude sees it instantly. No app install required; your
12
+ phone's browser camera does all the work.
13
+
14
+ ```
15
+ +----------+ WiFi +-----------+ MCP +-------------+
16
+ | Phone | photos, voice, | CCPhoto | image/text | Claude |
17
+ | Camera | mode switches | Server | data | Code |
18
+ | + Mic | <--------------- | (local) | <--------------- | |
19
+ +----------+ TTS, guidance +-----------+ send_to_phone +-------------+
20
+ ```
21
+
22
+ ## Quick Start
23
+
24
+ ```bash
25
+ npx ccphoto --setup # One-time: register CCPhoto as an MCP server
26
+ ```
27
+
28
+ Then in Claude Code, just say **"take a photo"** -- Claude handles the rest.
29
+
30
+ ## How It Works
31
+
32
+ 1. Claude calls the `capture_photo` MCP tool.
33
+ 2. A QR code appears in your terminal.
34
+ 3. Scan it with your phone -- a camera page opens in your browser.
35
+ 4. Take a photo -- Claude receives the image directly.
36
+
37
+ No app install needed. The phone's native camera is accessed through the
38
+ `<input capture>` HTML attribute.
39
+
40
+ ### Always-On Mode
41
+
42
+ The server starts on the first `capture_photo` call and stays running for the
43
+ entire session. Your phone stays connected -- there is no need to re-scan the
44
+ QR code. Take as many photos as you like, and retrieve any of them by asking
45
+ Claude.
46
+
47
+ ### Photo Request Notifications
48
+
49
+ When your phone is already connected and Claude calls `capture_photo` again, the
50
+ phone receives an SSE push notification. The capture button pulses to let you
51
+ know Claude is waiting for a new photo. Just tap and shoot.
52
+
53
+ ### Bidirectional Messaging
54
+
55
+ Claude can send content to your phone using the `send_to_phone` tool. Text, markdown,
56
+ and images appear in a collapsible panel on the phone. This turns your phone into a
57
+ reference screen -- Claude can display wiring instructions, pinout diagrams, or code
58
+ snippets while you work with both hands.
59
+
60
+ ### Photo Annotations
61
+
62
+ After taking a photo, an annotation screen appears where you can draw on the image
63
+ before sending it. Use colored pens (red, blue, green, white) to circle components,
64
+ draw arrows, or highlight areas of interest. Tap "Send" to upload the annotated
65
+ image, or "Skip" to send the original photo without annotations.
66
+
67
+ ### Live Video Assistant
68
+
69
+ Start a semi-real-time video stream from your phone camera. Claude watches the
70
+ live feed (one frame every 3 seconds) and provides guidance in real-time -- point
71
+ the camera where Claude asks, and receive instructions on your phone screen.
72
+
73
+ Requires HTTPS (for camera access). On Android Chrome, accept the certificate
74
+ warning once. Currently Android/Chrome only; iOS support planned.
75
+
76
+ ### Voice Interaction
77
+
78
+ Tap the microphone button on your phone to speak to Claude. Speech is
79
+ transcribed using the browser's built-in Speech Recognition API and sent as
80
+ text. Claude can respond with spoken audio using `send_to_phone` with
81
+ `speak: true` -- the phone speaks the response aloud via Text-to-Speech.
82
+
83
+ This enables hands-free workflows: ask a question while holding a soldering
84
+ iron, and hear the answer without looking at a screen. The mic button
85
+ appears only on browsers that support Speech Recognition (Android Chrome).
86
+
87
+ ## Installation
88
+
89
+ ### npx (recommended, no install)
90
+
91
+ ```bash
92
+ npx ccphoto --setup
93
+ ```
94
+
95
+ ### Global install
96
+
97
+ ```bash
98
+ npm install -g ccphoto
99
+ ccphoto --setup
100
+ ```
101
+
102
+ ### From source
103
+
104
+ ```bash
105
+ git clone https://github.com/stepankaiser/ccphoto.git
106
+ cd ccphoto
107
+ npm install
108
+ npm run build
109
+ node dist/index.js --setup
110
+ ```
111
+
112
+ If you prefer to register the MCP server manually instead of using `--setup`:
113
+
114
+ ```bash
115
+ claude mcp add ccphoto -- npx ccphoto --mcp
116
+ ```
117
+
118
+ ## MCP Tools Reference
119
+
120
+ | Tool | Description | Parameters |
121
+ |------|-------------|------------|
122
+ | `capture_photo` | Start the server and display a QR code. If a phone is already connected, it receives a push notification instead. | -- |
123
+ | `wait_for_photo` | Block until a photo is uploaded or the timeout expires. Call this immediately after `capture_photo`. | `timeout_seconds` (optional, default: 120) |
124
+ | `get_latest_photo` | Return the most recent photo, or a specific photo by filename. | `filename` (optional) |
125
+ | `list_photos` | List all captured photos with filenames, timestamps, and sizes. | -- |
126
+ | `send_to_phone` | Send text (markdown) or images to the phone display. The phone becomes a reference screen for instructions, diagrams, or pinouts. | `text` (optional), `image_base64` (optional), `image_mime_type` (optional), `speak` (optional, boolean) |
127
+ | `start_livestream` | Start a live video stream from the phone camera. Generates HTTPS certificate and returns QR code. | -- |
128
+ | `get_live_frame` | Get the latest frame from the live camera stream with freshness timestamp. | -- |
129
+
130
+ ## Standalone CLI Mode
131
+
132
+ CCPhoto can also run independently, without Claude Code:
133
+
134
+ ```bash
135
+ npx ccphoto # Start with defaults
136
+ npx ccphoto --port 4000 --output-dir ./photos # Custom port and directory
137
+ ```
138
+
139
+ A QR code is printed to the terminal. Scan it, take photos, and they are saved
140
+ to disk. The server stays running for multiple captures.
141
+
142
+ ## CLI Options
143
+
144
+ | Option | Description | Default |
145
+ |--------|-------------|---------|
146
+ | `--setup` | Register CCPhoto as an MCP server in Claude Code | -- |
147
+ | `--mcp` | Run as an MCP server (used internally by Claude Code) | -- |
148
+ | `--port <number>` | HTTP server port | `3847` |
149
+ | `--output-dir <path>` | Directory where photos are saved | `~/.ccphoto/captures/` |
150
+ | `--help` | Show help | -- |
151
+
152
+ ## Configuration
153
+
154
+ | Environment Variable | Description | Default |
155
+ |----------------------|-------------|---------|
156
+ | `CCPHOTO_DIR` | Override the default photo storage directory | `~/.ccphoto/captures/` |
157
+
158
+ ## Security
159
+
160
+ - **Session token** -- A cryptographically random 32-character hex token is
161
+ generated for each server session. Every request must include the token.
162
+ - **Timing-safe comparison** -- Token validation uses `crypto.timingSafeEqual`
163
+ to prevent timing attacks.
164
+ - **Local network only** -- The server binds to your local network IP. No data
165
+ leaves your network.
166
+ - **No external services** -- Photos are transferred directly between your phone
167
+ and the server over HTTP on your LAN. Nothing is uploaded to the cloud.
168
+
169
+ ## Troubleshooting
170
+
171
+ ### Could not detect local network IP
172
+
173
+ Make sure your computer is connected to WiFi (not just Ethernet in some
174
+ configurations). CCPhoto needs a LAN IP address that your phone can reach.
175
+
176
+ ### QR code does not scan
177
+
178
+ Try increasing your terminal font size or reducing the terminal width so the QR
179
+ code renders at a scannable resolution. You can also copy the URL printed below
180
+ the QR code and type it into your phone's browser manually.
181
+
182
+ ### Phone camera does not open
183
+
184
+ The camera capture feature requires HTTPS on some browsers, but most mobile
185
+ browsers allow it on plain HTTP for local network addresses. If your browser
186
+ blocks camera access, try using Safari (iOS) or Chrome (Android).
187
+
188
+ ### Upload fails
189
+
190
+ Verify that your phone and computer are on the same WiFi network. Corporate
191
+ networks with client isolation may block device-to-device traffic. Try a
192
+ personal hotspot or home network instead.
193
+
194
+ ## Development
195
+
196
+ ```bash
197
+ npm install # Install dependencies
198
+ npm run build # Compile TypeScript
199
+ npm run dev # Watch mode (recompile on change)
200
+ npm test # Run the test suite (87 tests)
201
+ ```
202
+
203
+ Tests use the Node.js built-in test runner and require the `tsx` dev dependency
204
+ for TypeScript execution.
205
+
206
+ Project structure:
207
+
208
+ ```
209
+ src/
210
+ index.ts CLI entry point and arg parsing
211
+ mcp.ts MCP server with tool definitions
212
+ server.ts HTTP server, SSE, upload handling
213
+ mobile-page.ts Self-contained HTML for the phone camera page
214
+ storage.ts Photo file management
215
+ network.ts Local IP detection
216
+ token.ts Session token generation and validation
217
+ types.ts Shared TypeScript interfaces
218
+ ```
219
+
220
+ ## Roadmap
221
+
222
+ - **Real domain + Let's Encrypt certs** -- Use a registered domain with valid
223
+ certificates for zero browser warnings on any device, including iOS Safari.
224
+ - **iOS live video support** -- Live video streaming currently works on
225
+ Android/Chrome. iOS Safari support requires trusted certificates.
226
+ - **AR overlays on camera feed** -- Draw annotations directly on the live
227
+ camera view in real-time.
228
+ - **Multi-camera support** -- Connect multiple phones simultaneously for
229
+ different viewing angles.
230
+ - **npm publish to registry** -- Make CCPhoto installable via `npx ccphoto`.
231
+ - **WebRTC streaming** -- Replace HTTP frame polling with WebRTC when Claude's
232
+ vision processing latency improves.
233
+
234
+ ## Contributing
235
+
236
+ Contributions are welcome.
237
+
238
+ 1. Fork the repository
239
+ 2. Create a feature branch (`git checkout -b my-feature`)
240
+ 3. Make your changes
241
+ 4. Run `npm test` to verify nothing is broken
242
+ 5. Commit your changes (`git commit -m "Add my feature"`)
243
+ 6. Push to your branch (`git push origin my-feature`)
244
+ 7. Open a pull request
245
+
246
+ When reporting a bug, please include your Node.js version, OS, and the steps to
247
+ reproduce the issue.
248
+
249
+ ## License
250
+
251
+ [MIT](LICENSE)
package/dist/cert.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import type { CertPems } from "./types.js";
2
+ export declare function certsExist(): boolean;
3
+ export declare function areCertsValid(host: string): boolean;
4
+ export declare function loadCerts(): CertPems;
5
+ export declare function generateCerts(host: string): Promise<CertPems>;
6
+ export declare function ensureCerts(host: string): Promise<CertPems>;
package/dist/cert.js ADDED
@@ -0,0 +1,70 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import os from "node:os";
4
+ import crypto from "node:crypto";
5
+ import { generate } from "selfsigned";
6
+ const CERTS_DIR = path.join(os.homedir(), ".ccphoto", "certs");
7
+ function ensureCertsDir() {
8
+ fs.mkdirSync(CERTS_DIR, { recursive: true });
9
+ }
10
+ function certPaths() {
11
+ return {
12
+ keyPath: path.join(CERTS_DIR, "server.key"),
13
+ certPath: path.join(CERTS_DIR, "server.crt"),
14
+ };
15
+ }
16
+ export function certsExist() {
17
+ const { keyPath, certPath } = certPaths();
18
+ return fs.existsSync(keyPath) && fs.existsSync(certPath);
19
+ }
20
+ export function areCertsValid(host) {
21
+ if (!certsExist())
22
+ return false;
23
+ try {
24
+ const { certPath } = certPaths();
25
+ const pem = fs.readFileSync(certPath, "utf-8");
26
+ const cert = new crypto.X509Certificate(pem);
27
+ // Check not expired
28
+ if (new Date(cert.validTo) < new Date())
29
+ return false;
30
+ // Check IP matches (SAN contains the host)
31
+ const san = cert.subjectAltName ?? "";
32
+ if (!san.includes(host))
33
+ return false;
34
+ return true;
35
+ }
36
+ catch {
37
+ return false;
38
+ }
39
+ }
40
+ export function loadCerts() {
41
+ const { keyPath, certPath } = certPaths();
42
+ return {
43
+ key: fs.readFileSync(keyPath, "utf-8"),
44
+ cert: fs.readFileSync(certPath, "utf-8"),
45
+ };
46
+ }
47
+ export async function generateCerts(host) {
48
+ ensureCertsDir();
49
+ const attrs = [{ name: "commonName", value: "CCPhoto" }];
50
+ const notAfterDate = new Date();
51
+ notAfterDate.setFullYear(notAfterDate.getFullYear() + 1);
52
+ const pems = await generate(attrs, {
53
+ keySize: 2048,
54
+ notAfterDate,
55
+ extensions: [
56
+ { name: "subjectAltName", altNames: [{ type: 7, ip: host }] },
57
+ ],
58
+ });
59
+ const { keyPath, certPath } = certPaths();
60
+ fs.writeFileSync(keyPath, pems.private, { mode: 0o600 });
61
+ fs.writeFileSync(certPath, pems.cert);
62
+ return { key: pems.private, cert: pems.cert };
63
+ }
64
+ export async function ensureCerts(host) {
65
+ if (areCertsValid(host)) {
66
+ return loadCerts();
67
+ }
68
+ return generateCerts(host);
69
+ }
70
+ //# sourceMappingURL=cert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cert.js","sourceRoot":"","sources":["../src/cert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;AAE/D,SAAS,cAAc;IACrB,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAC/C,CAAC;AAED,SAAS,SAAS;IAChB,OAAO;QACL,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC;QAC3C,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC;KAC7C,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,MAAM,EAAE,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EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IACzD,MAAM,YAAY,GAAG,IAAI,IAAI,EAAE,CAAC;IAChC,YAAY,CAAC,WAAW,CAAC,YAAY,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,CAAC;IACzD,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,KAAK,EAAE;QACjC,OAAO,EAAE,IAAI;QACb,YAAY;QACZ,UAAU,EAAE;YACV,EAAE,IAAI,EAAE,gBAAgB,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;SAC9D;KACF,CAAC,CAAC;IACH,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,CAAC;IAC1C,EAAE,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACzD,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACtC,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;AAChD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,IAAY;IAC5C,IAAI,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,OAAO,SAAS,EAAE,CAAC;IACrB,CAAC;IACD,OAAO,aAAa,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,131 @@
1
+ #!/usr/bin/env node
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import { execSync } from "node:child_process";
5
+ import qrcode from "qrcode-terminal";
6
+ import { startServer, stopServer } from "./server.js";
7
+ import { getLocalIPv4 } from "./network.js";
8
+ import { generateToken } from "./token.js";
9
+ import { runMcpServer } from "./mcp.js";
10
+ const DEFAULT_PORT = 3847;
11
+ const DEFAULT_OUTPUT_DIR = path.join(os.homedir(), ".ccphoto", "captures");
12
+ function printHelp() {
13
+ console.log(`
14
+ CCPhoto — Bridge your phone camera to Claude Code
15
+
16
+ Usage:
17
+ ccphoto --setup Auto-register as MCP server in Claude Code
18
+ ccphoto --mcp Run as MCP server (used by Claude Code internally)
19
+ ccphoto Start standalone camera server with QR code
20
+
21
+ Options:
22
+ --port <number> Port number (default: ${DEFAULT_PORT})
23
+ --output-dir <path> Where to save photos (default: ~/.ccphoto/captures/)
24
+ --help Show this help
25
+
26
+ Setup (one time):
27
+ npx ccphoto --setup
28
+
29
+ Then in Claude Code, say "take a photo" and Claude will handle the rest.
30
+ `);
31
+ }
32
+ function runSetup() {
33
+ console.log("\nSetting up CCPhoto as MCP server for Claude Code...\n");
34
+ try {
35
+ execSync(`claude mcp add ccphoto -- npx ccphoto --mcp`, { stdio: "inherit" });
36
+ console.log("\nCCPhoto MCP server registered successfully!");
37
+ console.log("\nYou can now use CCPhoto in Claude Code:");
38
+ console.log(' Just say "take a photo" or "show me a photo from my phone"');
39
+ console.log(" Claude will handle starting the camera server and showing the QR code.\n");
40
+ }
41
+ catch {
42
+ console.error("\nFailed to auto-register. You can manually add the MCP server:");
43
+ console.error(" claude mcp add ccphoto -- npx ccphoto --mcp\n");
44
+ }
45
+ }
46
+ async function runStandalone(port, outputDir) {
47
+ const host = getLocalIPv4();
48
+ if (!host) {
49
+ console.error("Error: Could not detect local network IP.");
50
+ console.error("Make sure you're connected to WiFi.\n");
51
+ process.exit(1);
52
+ }
53
+ const token = generateToken();
54
+ const cfg = await startServer({ port, outputDir, token, host });
55
+ const url = `http://${cfg.host}:${cfg.port}/?token=${cfg.token}`;
56
+ console.log("");
57
+ console.log("╔══════════════════════════════════════╗");
58
+ console.log("║ CCPhoto Ready ║");
59
+ console.log("╚══════════════════════════════════════╝");
60
+ console.log("\nScan this QR code with your phone:\n");
61
+ qrcode.generate(url, { small: true }, (code) => {
62
+ console.log(code);
63
+ });
64
+ console.log(`\nOr open: ${url}`);
65
+ console.log(`\nPhotos will be saved to: ${cfg.outputDir}`);
66
+ console.log("Press Ctrl+C to stop.\n");
67
+ const shutdown = () => {
68
+ console.log("\nShutting down...");
69
+ stopServer();
70
+ process.exit(0);
71
+ };
72
+ process.on("SIGINT", shutdown);
73
+ process.on("SIGTERM", shutdown);
74
+ }
75
+ function parseArgs() {
76
+ const args = process.argv.slice(2);
77
+ let mode = "standalone";
78
+ let port = DEFAULT_PORT;
79
+ let outputDir = process.env.CCPHOTO_DIR || DEFAULT_OUTPUT_DIR;
80
+ for (let i = 0; i < args.length; i++) {
81
+ switch (args[i]) {
82
+ case "--help":
83
+ case "-h":
84
+ mode = "help";
85
+ break;
86
+ case "--setup":
87
+ mode = "setup";
88
+ break;
89
+ case "--mcp":
90
+ mode = "mcp";
91
+ break;
92
+ case "--port":
93
+ port = parseInt(args[++i], 10);
94
+ if (isNaN(port)) {
95
+ console.error("Error: --port requires a number");
96
+ process.exit(1);
97
+ }
98
+ break;
99
+ case "--output-dir":
100
+ outputDir = args[++i];
101
+ if (!outputDir) {
102
+ console.error("Error: --output-dir requires a path");
103
+ process.exit(1);
104
+ }
105
+ break;
106
+ }
107
+ }
108
+ return { mode, port, outputDir };
109
+ }
110
+ const { mode, port, outputDir } = parseArgs();
111
+ switch (mode) {
112
+ case "help":
113
+ printHelp();
114
+ break;
115
+ case "setup":
116
+ runSetup();
117
+ break;
118
+ case "mcp":
119
+ runMcpServer().catch((err) => {
120
+ process.stderr.write(`[ccphoto] MCP server error: ${err.message}\n`);
121
+ process.exit(1);
122
+ });
123
+ break;
124
+ case "standalone":
125
+ runStandalone(port, outputDir).catch((err) => {
126
+ console.error(`Error: ${err.message}`);
127
+ process.exit(1);
128
+ });
129
+ break;
130
+ }
131
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot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