annotate-anything 0.0.1 → 0.1.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 +21 -0
- package/README.md +238 -3
- package/agent/INSTRUCTIONS.md +70 -0
- package/dist/annotate-anything.iife.js +164 -0
- package/dist/cli.js +785 -0
- package/dist/client-file-B1I-YibZ.js +12 -0
- package/dist/index.js +1 -0
- package/dist/local-W-uyrETY.js +4 -0
- package/dist/middleware.js +18 -0
- package/dist/next-client.js +19 -0
- package/dist/next.js +49 -0
- package/dist/node-SB91dcoI.js +614 -0
- package/dist/react.js +13 -0
- package/dist/src-DTByJ6QG.js +2116 -0
- package/dist/types/anchor.d.ts +36 -0
- package/dist/types/annotator.d.ts +173 -0
- package/dist/types/auto.d.ts +1 -0
- package/dist/types/cli.d.ts +1 -0
- package/dist/types/icons.d.ts +13 -0
- package/dist/types/index.d.ts +19 -0
- package/dist/types/local.d.ts +2 -0
- package/dist/types/mcp.d.ts +2 -0
- package/dist/types/next-client.d.ts +4 -0
- package/dist/types/next.d.ts +10 -0
- package/dist/types/react.d.ts +4 -0
- package/dist/types/scheme.d.ts +2 -0
- package/dist/types/server/client-file.d.ts +1 -0
- package/dist/types/server/core.d.ts +57 -0
- package/dist/types/server/locate.d.ts +2 -0
- package/dist/types/server/middleware.d.ts +8 -0
- package/dist/types/server/node.d.ts +4 -0
- package/dist/types/server/serve.d.ts +9 -0
- package/dist/types/server/store.d.ts +43 -0
- package/dist/types/server/watcher.d.ts +21 -0
- package/dist/types/styles.d.ts +1 -0
- package/dist/types/transport.d.ts +23 -0
- package/dist/types/types.d.ts +75 -0
- package/dist/types/vite.d.ts +20 -0
- package/dist/vite.js +108 -0
- package/package.json +84 -3
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
// src/server/client-file.ts
|
|
5
|
+
function clientBundle() {
|
|
6
|
+
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
for (const p of [path.join(here, "annotate-anything.iife.js"), path.join(here, "../../dist/annotate-anything.iife.js")]) try {
|
|
8
|
+
return fs.readFileSync(p, "utf8");
|
|
9
|
+
} catch {}
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
export { clientBundle as t };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as annotate, n as clipboard, r as http, i as local, a as markdown } from "./src-DTByJ6QG.js";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// src/local.ts
|
|
2
|
+
var LOCAL_HOST = /^(localhost|127(\.\d+){3}|\[::1\]|0\.0\.0\.0|.+\.localhost|.+\.local|.+\.test|.+\.internal|.+\.lan|10(\.\d+){3}|192\.168(\.\d+){2}|172\.(1[6-9]|2\d|3[01])(\.\d+){2})$/;
|
|
3
|
+
var LOOPBACK_HOST = /^(localhost|127(\.\d+){3}|\[::1\]|.+\.localhost)$/;
|
|
4
|
+
export { LOOPBACK_HOST as n, LOCAL_HOST as t };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { i as inProduction, o as isLocalOrigin, r as createCore, s as isLoopbackOrigin, t as nodeRequest } from "./node-SB91dcoI.js";
|
|
2
|
+
import { t as clientBundle } from "./client-file-B1I-YibZ.js";
|
|
3
|
+
// src/server/middleware.ts
|
|
4
|
+
function createMiddleware(options = {}) {
|
|
5
|
+
const core = createCore({
|
|
6
|
+
clientScript: clientBundle,
|
|
7
|
+
...options
|
|
8
|
+
});
|
|
9
|
+
return function annotateMiddleware(req, res, next) {
|
|
10
|
+
if (inProduction(options)) return next();
|
|
11
|
+
core.handle(nodeRequest(req)).then((out) => {
|
|
12
|
+
if (!out) return next();
|
|
13
|
+
res.writeHead(out.status, out.headers);
|
|
14
|
+
res.end(out.body);
|
|
15
|
+
}).catch(next);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export { createMiddleware, isLocalOrigin, isLoopbackOrigin, nodeRequest };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { t as annotate } from "./src-DTByJ6QG.js";
|
|
3
|
+
import { useEffect } from "react";
|
|
4
|
+
import { useRouter } from "next/navigation";
|
|
5
|
+
// src/next-client.ts
|
|
6
|
+
function Annotate(props) {
|
|
7
|
+
const router = useRouter();
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
if (process.env.NODE_ENV === "production" && !props.enabled) return;
|
|
10
|
+
const tool = annotate({
|
|
11
|
+
endpoint: "/api/annotate",
|
|
12
|
+
navigate: (route) => router.push(route),
|
|
13
|
+
...props
|
|
14
|
+
});
|
|
15
|
+
return () => tool.destroy();
|
|
16
|
+
}, []);
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
export { Annotate, Annotate as default };
|
package/dist/next.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { i as inProduction, n as HttpError, r as createCore, t as nodeRequest } from "./node-SB91dcoI.js";
|
|
2
|
+
// src/next.ts
|
|
3
|
+
var BASE = "/api/annotate";
|
|
4
|
+
function annotateRoute(options = {}) {
|
|
5
|
+
const core = createCore({
|
|
6
|
+
base: BASE,
|
|
7
|
+
...options
|
|
8
|
+
});
|
|
9
|
+
async function handler(request) {
|
|
10
|
+
if (inProduction(options)) return new Response("Not found", { status: 404 });
|
|
11
|
+
const url = new URL(request.url);
|
|
12
|
+
const out = await core.handle({
|
|
13
|
+
method: request.method,
|
|
14
|
+
url: url.pathname + url.search,
|
|
15
|
+
header: (name) => request.headers.get(name) ?? void 0,
|
|
16
|
+
body: async (limit) => {
|
|
17
|
+
const text = await request.text();
|
|
18
|
+
if (Buffer.byteLength(text) > limit) throw new HttpError(413, "Request too large");
|
|
19
|
+
return text;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
if (!out) return new Response("Not found", { status: 404 });
|
|
23
|
+
return new Response(out.status === 204 ? null : out.body, {
|
|
24
|
+
status: out.status,
|
|
25
|
+
headers: out.headers
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
GET: handler,
|
|
30
|
+
POST: handler,
|
|
31
|
+
OPTIONS: handler
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function annotatePagesRoute(options = {}) {
|
|
35
|
+
const core = createCore({
|
|
36
|
+
base: BASE,
|
|
37
|
+
...options
|
|
38
|
+
});
|
|
39
|
+
return async (req, res) => {
|
|
40
|
+
const out = inProduction(options) ? null : await core.handle(nodeRequest(req));
|
|
41
|
+
if (!out) {
|
|
42
|
+
res.statusCode = 404;
|
|
43
|
+
return res.end("Not found");
|
|
44
|
+
}
|
|
45
|
+
res.writeHead(out.status, out.headers);
|
|
46
|
+
res.end(out.body);
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export { annotatePagesRoute, annotateRoute };
|