annotate-anything 0.0.0-stage → 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.
Files changed (40) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +239 -2
  3. package/agent/INSTRUCTIONS.md +70 -0
  4. package/dist/annotate-anything.iife.js +164 -0
  5. package/dist/cli.js +785 -0
  6. package/dist/client-file-B1I-YibZ.js +12 -0
  7. package/dist/index.js +1 -0
  8. package/dist/local-W-uyrETY.js +4 -0
  9. package/dist/middleware.js +18 -0
  10. package/dist/next-client.js +19 -0
  11. package/dist/next.js +49 -0
  12. package/dist/node-SB91dcoI.js +614 -0
  13. package/dist/react.js +13 -0
  14. package/dist/src-DTByJ6QG.js +2116 -0
  15. package/dist/types/anchor.d.ts +36 -0
  16. package/dist/types/annotator.d.ts +173 -0
  17. package/dist/types/auto.d.ts +1 -0
  18. package/dist/types/cli.d.ts +1 -0
  19. package/dist/types/icons.d.ts +13 -0
  20. package/dist/types/index.d.ts +19 -0
  21. package/dist/types/local.d.ts +2 -0
  22. package/dist/types/mcp.d.ts +2 -0
  23. package/dist/types/next-client.d.ts +4 -0
  24. package/dist/types/next.d.ts +10 -0
  25. package/dist/types/react.d.ts +4 -0
  26. package/dist/types/scheme.d.ts +2 -0
  27. package/dist/types/server/client-file.d.ts +1 -0
  28. package/dist/types/server/core.d.ts +57 -0
  29. package/dist/types/server/locate.d.ts +2 -0
  30. package/dist/types/server/middleware.d.ts +8 -0
  31. package/dist/types/server/node.d.ts +4 -0
  32. package/dist/types/server/serve.d.ts +9 -0
  33. package/dist/types/server/store.d.ts +43 -0
  34. package/dist/types/server/watcher.d.ts +21 -0
  35. package/dist/types/styles.d.ts +1 -0
  36. package/dist/types/transport.d.ts +23 -0
  37. package/dist/types/types.d.ts +75 -0
  38. package/dist/types/vite.d.ts +20 -0
  39. package/dist/vite.js +108 -0
  40. package/package.json +86 -4
@@ -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 };