web-annotation-renderer 0.6.1 → 0.6.2

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 (81) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +26 -24
  4. package/dist/index.js.map +1 -1
  5. package/dist/index10.cjs +1 -1
  6. package/dist/index10.js +1 -1
  7. package/dist/index11.cjs +1 -1
  8. package/dist/index11.js +2 -2
  9. package/dist/index13.cjs +1 -1
  10. package/dist/index13.js +1 -1
  11. package/dist/index14.cjs +1 -1
  12. package/dist/index14.js +1 -1
  13. package/dist/index15.cjs +1 -1
  14. package/dist/index15.js +1 -1
  15. package/dist/index16.cjs +1 -1
  16. package/dist/index16.js +1 -1
  17. package/dist/index17.cjs +1 -1
  18. package/dist/index17.js +1 -1
  19. package/dist/index18.cjs +1 -1
  20. package/dist/index18.cjs.map +1 -1
  21. package/dist/index18.js +22 -117
  22. package/dist/index18.js.map +1 -1
  23. package/dist/index19.cjs +1 -1
  24. package/dist/index19.cjs.map +1 -1
  25. package/dist/index19.js +83 -69
  26. package/dist/index19.js.map +1 -1
  27. package/dist/index20.cjs +1 -1
  28. package/dist/index20.cjs.map +1 -1
  29. package/dist/index20.js +100 -76
  30. package/dist/index20.js.map +1 -1
  31. package/dist/index21.cjs +1 -1
  32. package/dist/index21.cjs.map +1 -1
  33. package/dist/index21.js +77 -138
  34. package/dist/index21.js.map +1 -1
  35. package/dist/index22.cjs +1 -1
  36. package/dist/index22.cjs.map +1 -1
  37. package/dist/index22.js +139 -36
  38. package/dist/index22.js.map +1 -1
  39. package/dist/index23.cjs +1 -1
  40. package/dist/index23.cjs.map +1 -1
  41. package/dist/index23.js +35 -34
  42. package/dist/index23.js.map +1 -1
  43. package/dist/index24.cjs +1 -1
  44. package/dist/index24.cjs.map +1 -1
  45. package/dist/index24.js +27 -28
  46. package/dist/index24.js.map +1 -1
  47. package/dist/index25.cjs +1 -1
  48. package/dist/index25.cjs.map +1 -1
  49. package/dist/index25.js +38 -40
  50. package/dist/index25.js.map +1 -1
  51. package/dist/index26.cjs +1 -1
  52. package/dist/index26.cjs.map +1 -1
  53. package/dist/index26.js +39 -4
  54. package/dist/index26.js.map +1 -1
  55. package/dist/index27.cjs +1 -1
  56. package/dist/index27.js +4 -4
  57. package/dist/index28.cjs +1 -1
  58. package/dist/index28.cjs.map +1 -1
  59. package/dist/index28.js +5 -71
  60. package/dist/index28.js.map +1 -1
  61. package/dist/index29.cjs +1 -1
  62. package/dist/index29.cjs.map +1 -1
  63. package/dist/index29.js +70 -4
  64. package/dist/index29.js.map +1 -1
  65. package/dist/index30.cjs +1 -1
  66. package/dist/index30.cjs.map +1 -1
  67. package/dist/index30.js +4 -991
  68. package/dist/index30.js.map +1 -1
  69. package/dist/index31.cjs +2 -0
  70. package/dist/index31.cjs.map +1 -0
  71. package/dist/index31.js +995 -0
  72. package/dist/index31.js.map +1 -0
  73. package/dist/index5.cjs +1 -1
  74. package/dist/index5.cjs.map +1 -1
  75. package/dist/index5.js +63 -56
  76. package/dist/index5.js.map +1 -1
  77. package/dist/index9.cjs +1 -1
  78. package/dist/index9.cjs.map +1 -1
  79. package/dist/index9.js +17 -15
  80. package/dist/index9.js.map +1 -1
  81. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index20.js","sources":["../src/pen/presets.js"],"sourcesContent":["/**\n * Client-side style presets for Digital Pen\n *\n * These presets use the same format as StrokeRenderer.setConfig().\n * Keys match annotation types: highlight, text, underline, arrow, circle.\n */\n\n/**\n * Default preset - Yellow highlights, crimson text\n */\nexport const DEFAULT_PRESET = {\n highlight: {\n color: 'rgba(255, 255, 0, 0.3)',\n width: 24\n },\n text: {\n color: 'rgba(220, 20, 60, 1.0)',\n width: 2\n },\n underline: {\n color: 'rgba(0, 80, 255, 1.0)',\n width: 2\n },\n arrow: {\n color: 'rgba(220, 30, 30, 1.0)',\n width: 2\n },\n circle: {\n color: 'rgba(255, 140, 0, 1.0)',\n width: 3\n }\n};\n\n/**\n * Blue preset - Blue theme\n */\nexport const BLUE_PRESET = {\n highlight: {\n color: 'rgba(100, 149, 237, 0.35)',\n width: 24\n },\n text: {\n color: 'rgba(30, 64, 175, 1.0)',\n width: 2\n },\n underline: {\n color: 'rgba(30, 64, 175, 1.0)',\n width: 2\n },\n arrow: {\n color: 'rgba(30, 64, 175, 1.0)',\n width: 2\n },\n circle: {\n color: 'rgba(30, 64, 175, 1.0)',\n width: 3\n }\n};\n\n/**\n * Minimal preset - Subtle gray\n */\nexport const MINIMAL_PRESET = {\n highlight: {\n color: 'rgba(156, 163, 175, 0.25)',\n width: 20\n },\n text: {\n color: 'rgba(75, 85, 99, 1.0)',\n width: 1.5\n },\n underline: {\n color: 'rgba(75, 85, 99, 1.0)',\n width: 1.5\n },\n arrow: {\n color: 'rgba(75, 85, 99, 1.0)',\n width: 1.5\n },\n circle: {\n color: 'rgba(75, 85, 99, 1.0)',\n width: 2\n }\n};\n\n/**\n * Preset registry\n */\nconst PRESETS = {\n default: DEFAULT_PRESET,\n blue: BLUE_PRESET,\n minimal: MINIMAL_PRESET\n};\n\n/**\n * Get a preset by name\n *\n * @param {string} name - Preset name\n * @returns {Object} Preset configuration\n */\nexport function getPreset(name) {\n return PRESETS[name] || PRESETS.default;\n}\n\n/**\n * Get all available preset names\n *\n * @returns {string[]} Array of preset names\n */\nexport function getPresetNames() {\n return Object.keys(PRESETS);\n}\n\nexport default PRESETS;\n"],"names":["DEFAULT_PRESET","BLUE_PRESET","MINIMAL_PRESET","PRESETS","getPreset","name","getPresetNames"],"mappings":"AAUY,MAACA,IAAiB;AAAA,EAC5B,WAAW;AAAA,IACT,OAAO;AAAA,IACP,OAAO;AAAA,EACX;AAAA,EACE,MAAM;AAAA,IACJ,OAAO;AAAA,IACP,OAAO;AAAA,EACX;AAAA,EACE,WAAW;AAAA,IACT,OAAO;AAAA,IACP,OAAO;AAAA,EACX;AAAA,EACE,OAAO;AAAA,IACL,OAAO;AAAA,IACP,OAAO;AAAA,EACX;AAAA,EACE,QAAQ;AAAA,IACN,OAAO;AAAA,IACP,OAAO;AAAA,EACX;AACA,GAKaC,IAAc;AAAA,EACzB,WAAW;AAAA,IACT,OAAO;AAAA,IACP,OAAO;AAAA,EACX;AAAA,EACE,MAAM;AAAA,IACJ,OAAO;AAAA,IACP,OAAO;AAAA,EACX;AAAA,EACE,WAAW;AAAA,IACT,OAAO;AAAA,IACP,OAAO;AAAA,EACX;AAAA,EACE,OAAO;AAAA,IACL,OAAO;AAAA,IACP,OAAO;AAAA,EACX;AAAA,EACE,QAAQ;AAAA,IACN,OAAO;AAAA,IACP,OAAO;AAAA,EACX;AACA,GAKaC,IAAiB;AAAA,EAC5B,WAAW;AAAA,IACT,OAAO;AAAA,IACP,OAAO;AAAA,EACX;AAAA,EACE,MAAM;AAAA,IACJ,OAAO;AAAA,IACP,OAAO;AAAA,EACX;AAAA,EACE,WAAW;AAAA,IACT,OAAO;AAAA,IACP,OAAO;AAAA,EACX;AAAA,EACE,OAAO;AAAA,IACL,OAAO;AAAA,IACP,OAAO;AAAA,EACX;AAAA,EACE,QAAQ;AAAA,IACN,OAAO;AAAA,IACP,OAAO;AAAA,EACX;AACA,GAKMC,IAAU;AAAA,EACd,SAASH;AAAA,EACT,MAAMC;AAAA,EACN,SAASC;AACX;AAQO,SAASE,EAAUC,GAAM;AAC9B,SAAOF,EAAQE,CAAI,KAAKF,EAAQ;AAClC;AAOO,SAASG,IAAiB;AAC/B,SAAO,OAAO,KAAKH,CAAO;AAC5B;"}
1
+ {"version":3,"file":"index20.js","sources":["../src/pen/StrokeDrawer.js"],"sourcesContent":["/**\n * StrokeDrawer - Low-level canvas stroke drawing utilities\n *\n * Handles the actual drawing of strokes on canvas with support for:\n * - Progressive stroke reveal (partial drawing based on progress)\n * - Normalized to pixel coordinate conversion\n * - Variable width based on pressure data\n * - Smooth line rendering with round caps/joins\n */\nclass StrokeDrawer {\n /**\n * Creates a new StrokeDrawer instance\n *\n * @param {CanvasRenderingContext2D} ctx - Canvas 2D rendering context\n * @param {Object} viewport - Viewport dimensions for coordinate conversion\n * @param {number} viewport.width - Viewport width in pixels\n * @param {number} viewport.height - Viewport height in pixels\n */\n constructor(ctx, viewport) {\n this.ctx = ctx;\n this.viewport = viewport;\n }\n\n /**\n * Updates the viewport dimensions\n *\n * @param {Object} viewport - New viewport dimensions\n */\n setViewport(viewport) {\n this.viewport = viewport;\n }\n\n /**\n * Draws a stroke with optional progress for progressive reveal\n *\n * @param {Object} stroke - Stroke command object\n * @param {Array} stroke.points - Array of [x, y] normalized coordinates\n * @param {string} stroke.color - Stroke color (CSS color string)\n * @param {number} stroke.width - Base stroke width in pixels\n * @param {Array} [stroke.pressures] - Optional pressure values for variable width\n * @param {number} [progress=1.0] - Progress from 0 to 1 (for progressive reveal)\n */\n drawStroke(stroke, progress = 1.0) {\n const { points, color, width, pressures } = stroke;\n\n if (!points || points.length < 2) return;\n\n // Calculate how many points to draw based on progress\n const pointCount = Math.max(2, Math.floor(points.length * progress));\n const visiblePoints = points.slice(0, pointCount);\n\n // Configure stroke style\n this.ctx.strokeStyle = color || 'rgba(0, 0, 0, 0.5)';\n this.ctx.lineCap = 'round';\n this.ctx.lineJoin = 'round';\n\n // Draw with variable width if pressures provided\n if (pressures && pressures.length >= visiblePoints.length) {\n this._drawVariableWidthStroke(visiblePoints, width, pressures.slice(0, pointCount));\n } else {\n this._drawConstantWidthStroke(visiblePoints, width);\n }\n }\n\n /**\n * Draws a stroke with constant width\n *\n * @private\n * @param {Array} points - Array of [x, y] normalized coordinates\n * @param {number} width - Stroke width in pixels\n */\n _drawConstantWidthStroke(points, width) {\n this.ctx.lineWidth = width || 2;\n this.ctx.beginPath();\n\n for (let i = 0; i < points.length; i++) {\n const [px, py] = this._normalizedToPixel(points[i]);\n\n if (i === 0) {\n this.ctx.moveTo(px, py);\n } else {\n this.ctx.lineTo(px, py);\n }\n }\n\n this.ctx.stroke();\n }\n\n /**\n * Draws a stroke with variable width based on pressure\n *\n * Uses multiple line segments with varying widths for natural pen feel.\n *\n * @private\n * @param {Array} points - Array of [x, y] normalized coordinates\n * @param {number} baseWidth - Base stroke width in pixels\n * @param {Array} pressures - Pressure values (0-1) for each point\n */\n _drawVariableWidthStroke(points, baseWidth, pressures) {\n for (let i = 1; i < points.length; i++) {\n const [x1, y1] = this._normalizedToPixel(points[i - 1]);\n const [x2, y2] = this._normalizedToPixel(points[i]);\n\n // Average pressure between two points\n const p1 = pressures[i - 1] || 1;\n const p2 = pressures[i] || 1;\n const avgPressure = (p1 + p2) / 2;\n\n // Apply pressure to width (min 0.5, max 2x base width)\n const width = Math.max(0.5, baseWidth * avgPressure);\n\n this.ctx.lineWidth = width;\n this.ctx.beginPath();\n this.ctx.moveTo(x1, y1);\n this.ctx.lineTo(x2, y2);\n this.ctx.stroke();\n }\n }\n\n /**\n * Draws a single point (dot)\n *\n * Useful for single-point strokes or debugging.\n *\n * @param {number} x - Normalized x coordinate (0-1)\n * @param {number} y - Normalized y coordinate (0-1)\n * @param {number} radius - Dot radius in pixels\n * @param {string} color - Fill color\n */\n drawPoint(x, y, radius, color) {\n const [px, py] = this._normalizedToPixel([x, y]);\n\n this.ctx.fillStyle = color || 'rgba(0, 0, 0, 0.5)';\n this.ctx.beginPath();\n this.ctx.arc(px, py, radius, 0, Math.PI * 2);\n this.ctx.fill();\n }\n\n /**\n * Clears the entire canvas\n */\n clear() {\n const dpr = window.devicePixelRatio || 1;\n this.ctx.clearRect(0, 0, this.viewport.width * dpr, this.viewport.height * dpr);\n }\n\n /**\n * Converts normalized coordinates (0-1) to pixel coordinates\n *\n * @private\n * @param {Array} point - [x, y] normalized coordinates\n * @returns {Array} [x, y] pixel coordinates\n */\n _normalizedToPixel(point) {\n const [normX, normY] = point;\n return [\n normX * this.viewport.width,\n normY * this.viewport.height\n ];\n }\n}\n\nexport default StrokeDrawer;\n"],"names":["StrokeDrawer","ctx","viewport","stroke","progress","points","color","width","pressures","pointCount","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;AAAA;AAAA;AAAA;AAAA,EASA,mBAAmBC,GAAO;AACxB,UAAM,CAACC,GAAOC,CAAK,IAAIF;AACvB,WAAO;AAAA,MACLC,IAAQ,KAAK,SAAS;AAAA,MACtBC,IAAQ,KAAK,SAAS;AAAA,IAC5B;AAAA,EACE;AACF;"}
package/dist/index21.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=[{type:"function",function:{name:"create_highlight_annotation",description:"Create a highlight annotation at specified coordinates on the PDF page. Use this to emphasize important text or regions. Highlights are rectangular regions that can span multiple lines.",parameters:{type:"object",properties:{quads:{type:"array",description:"Array of rectangular regions defining the highlight areas. Each quad is an object with normalized coordinates (0-1): {x, y, w, h}. Multiple quads can be used for multi-line highlights.",items:{type:"object",properties:{x:{type:"number",description:"Normalized x position (0 = left, 1 = right)",minimum:0,maximum:1},y:{type:"number",description:"Normalized y position (0 = top, 1 = bottom)",minimum:0,maximum:1},w:{type:"number",description:"Normalized width (0-1)",minimum:0,maximum:1},h:{type:"number",description:"Normalized height (0-1)",minimum:0,maximum:1}},required:["x","y","w","h"]},minItems:1},color:{type:"string",description:"Highlight color in rgba format (e.g., 'rgba(255, 255, 0, 0.3)'). Default is semi-transparent yellow. Use rgba for transparency control.",default:"rgba(255, 255, 0, 0.3)"},page:{type:"integer",description:"Page number (1-indexed) where the annotation appears",minimum:1},sentence_ref:{type:"string",description:"Reference to sentence marker (e.g., 'S1', 'S2') for timing synchronization",pattern:"^S\\d+$"}},required:["quads","page","sentence_ref"]}}},{type:"function",function:{name:"create_text_annotation",description:"Create a text box annotation with explanatory content. Use this to add clarifying notes, definitions, or explanations. Text boxes have background and appear as overlays.",parameters:{type:"object",properties:{content:{type:"string",description:"The text content of the annotation",minLength:1,maxLength:500},x:{type:"number",description:"Normalized x position (0 = left edge, 1 = right edge)",minimum:0,maximum:1},y:{type:"number",description:"Normalized y position (0 = top edge, 1 = bottom edge)",minimum:0,maximum:1},w:{type:"number",description:"Normalized width (0-1) of the text box",minimum:0,maximum:1},h:{type:"number",description:"Normalized height (0-1) of the text box",minimum:0,maximum:1},page:{type:"integer",description:"Page number (1-indexed) where the annotation appears",minimum:1},textColor:{type:"string",description:"Text color in hex format (e.g., '#000000' for black). Default is dark gray.",default:"#1f2937"},bgColor:{type:"string",description:"Background color in rgba format or 'transparent' (e.g., 'rgba(255, 255, 255, 0.9)' or 'transparent'). Default is transparent for better visibility of underlying content. Use rgba format when background is needed.",default:"transparent"},sentence_ref:{type:"string",description:"Reference to sentence marker (e.g., 'S1', 'S2') for timing synchronization",pattern:"^S\\d+$"}},required:["content","x","y","w","h","page","sentence_ref"]}}}];function o(e=[]){if(!Array.isArray(e)||e.length===0)return[];const i={highlight:"create_highlight_annotation",text:"create_text_annotation"},r=e.map(t=>i[t]).filter(Boolean);return n.filter(t=>r.includes(t.function.name))}exports.annotationTools=n;exports.getAnnotationTools=o;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t={highlight:{color:"rgba(255, 255, 0, 0.3)",width:24},text:{color:"rgba(220, 20, 60, 1.0)",width:2},underline:{color:"rgba(0, 80, 255, 1.0)",width:2},arrow:{color:"rgba(220, 30, 30, 1.0)",width:2},circle:{color:"rgba(255, 140, 0, 1.0)",width:3}},e={highlight:{color:"rgba(100, 149, 237, 0.35)",width:24},text:{color:"rgba(30, 64, 175, 1.0)",width:2},underline:{color:"rgba(30, 64, 175, 1.0)",width:2},arrow:{color:"rgba(30, 64, 175, 1.0)",width:2},circle:{color:"rgba(30, 64, 175, 1.0)",width:3}},o={highlight:{color:"rgba(156, 163, 175, 0.25)",width:20},text:{color:"rgba(75, 85, 99, 1.0)",width:1.5},underline:{color:"rgba(75, 85, 99, 1.0)",width:1.5},arrow:{color:"rgba(75, 85, 99, 1.0)",width:1.5},circle:{color:"rgba(75, 85, 99, 1.0)",width:2}},r={default:t,blue:e,minimal:o};function l(i){return r[i]||r.default}function c(){return Object.keys(r)}exports.BLUE_PRESET=e;exports.DEFAULT_PRESET=t;exports.MINIMAL_PRESET=o;exports.default=r;exports.getPreset=l;exports.getPresetNames=c;
2
2
  //# sourceMappingURL=index21.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index21.cjs","sources":["../src/ai-tools/openai/schemas.js"],"sourcesContent":["/**\n * OpenAI Tool Schemas for PDF Annotation Generation\n *\n * Provides OpenAI-compatible function calling schemas for creating PDF annotations.\n * These schemas define the structure and parameters for AI-generated annotations.\n * Compatible with web-annotation-renderer library format.\n *\n * @module ai-tools/openai/schemas\n */\n\n/**\n * Complete set of annotation tools for OpenAI function calling\n *\n * Export this array to the OpenAI API's `tools` parameter to enable\n * AI-generated annotations.\n *\n * @constant {Array<Object>}\n * @example\n * ```javascript\n * import { annotationTools } from 'web-annotation-renderer/ai-tools';\n *\n * const response = await openai.chat.completions.create({\n * model: \"gpt-4\",\n * messages: [...],\n * tools: annotationTools\n * });\n * ```\n */\nexport const annotationTools = [\n {\n type: \"function\",\n function: {\n name: \"create_highlight_annotation\",\n description: \"Create a highlight annotation at specified coordinates on the PDF page. Use this to emphasize important text or regions. Highlights are rectangular regions that can span multiple lines.\",\n parameters: {\n type: \"object\",\n properties: {\n quads: {\n type: \"array\",\n description: \"Array of rectangular regions defining the highlight areas. Each quad is an object with normalized coordinates (0-1): {x, y, w, h}. Multiple quads can be used for multi-line highlights.\",\n items: {\n type: \"object\",\n properties: {\n x: {\n type: \"number\",\n description: \"Normalized x position (0 = left, 1 = right)\",\n minimum: 0,\n maximum: 1\n },\n y: {\n type: \"number\",\n description: \"Normalized y position (0 = top, 1 = bottom)\",\n minimum: 0,\n maximum: 1\n },\n w: {\n type: \"number\",\n description: \"Normalized width (0-1)\",\n minimum: 0,\n maximum: 1\n },\n h: {\n type: \"number\",\n description: \"Normalized height (0-1)\",\n minimum: 0,\n maximum: 1\n }\n },\n required: [\"x\", \"y\", \"w\", \"h\"]\n },\n minItems: 1\n },\n color: {\n type: \"string\",\n description: \"Highlight color in rgba format (e.g., 'rgba(255, 255, 0, 0.3)'). Default is semi-transparent yellow. Use rgba for transparency control.\",\n default: \"rgba(255, 255, 0, 0.3)\"\n },\n page: {\n type: \"integer\",\n description: \"Page number (1-indexed) where the annotation appears\",\n minimum: 1\n },\n sentence_ref: {\n type: \"string\",\n description: \"Reference to sentence marker (e.g., 'S1', 'S2') for timing synchronization\",\n pattern: \"^S\\\\d+$\"\n }\n },\n required: [\"quads\", \"page\", \"sentence_ref\"]\n }\n }\n },\n {\n type: \"function\",\n function: {\n name: \"create_text_annotation\",\n description: \"Create a text box annotation with explanatory content. Use this to add clarifying notes, definitions, or explanations. Text boxes have background and appear as overlays.\",\n parameters: {\n type: \"object\",\n properties: {\n content: {\n type: \"string\",\n description: \"The text content of the annotation\",\n minLength: 1,\n maxLength: 500\n },\n x: {\n type: \"number\",\n description: \"Normalized x position (0 = left edge, 1 = right edge)\",\n minimum: 0,\n maximum: 1\n },\n y: {\n type: \"number\",\n description: \"Normalized y position (0 = top edge, 1 = bottom edge)\",\n minimum: 0,\n maximum: 1\n },\n w: {\n type: \"number\",\n description: \"Normalized width (0-1) of the text box\",\n minimum: 0,\n maximum: 1\n },\n h: {\n type: \"number\",\n description: \"Normalized height (0-1) of the text box\",\n minimum: 0,\n maximum: 1\n },\n page: {\n type: \"integer\",\n description: \"Page number (1-indexed) where the annotation appears\",\n minimum: 1\n },\n textColor: {\n type: \"string\",\n description: \"Text color in hex format (e.g., '#000000' for black). Default is dark gray.\",\n default: \"#1f2937\"\n },\n bgColor: {\n type: \"string\",\n description: \"Background color in rgba format or 'transparent' (e.g., 'rgba(255, 255, 255, 0.9)' or 'transparent'). Default is transparent for better visibility of underlying content. Use rgba format when background is needed.\",\n default: \"transparent\"\n },\n sentence_ref: {\n type: \"string\",\n description: \"Reference to sentence marker (e.g., 'S1', 'S2') for timing synchronization\",\n pattern: \"^S\\\\d+$\"\n }\n },\n required: [\"content\", \"x\", \"y\", \"w\", \"h\", \"page\", \"sentence_ref\"]\n }\n }\n }\n];\n\n/**\n * Get filtered annotation tools based on enabled types\n *\n * @param {Array<string>} enabledTypes - Array of enabled tool types: ['highlight', 'text']\n * @returns {Array<Object>} Filtered annotation tools\n * @example\n * ```javascript\n * // Only enable highlights and text notes\n * const tools = getAnnotationTools(['highlight', 'text']);\n * ```\n */\nexport function getAnnotationTools(enabledTypes = []) {\n if (!Array.isArray(enabledTypes) || enabledTypes.length === 0) {\n return [];\n }\n\n const typeMap = {\n 'highlight': 'create_highlight_annotation',\n 'text': 'create_text_annotation'\n };\n\n const enabledFunctionNames = enabledTypes\n .map(type => typeMap[type])\n .filter(Boolean);\n\n return annotationTools.filter(tool =>\n enabledFunctionNames.includes(tool.function.name)\n );\n}\n"],"names":["annotationTools","getAnnotationTools","enabledTypes","typeMap","enabledFunctionNames","type","tool"],"mappings":"gFA4BY,MAACA,EAAkB,CAC7B,CACE,KAAM,WACN,SAAU,CACR,KAAM,8BACN,YAAa,4LACb,WAAY,CACV,KAAM,SACN,WAAY,CACV,MAAO,CACL,KAAM,QACN,YAAa,2LACb,MAAO,CACL,KAAM,SACN,WAAY,CACV,EAAG,CACD,KAAM,SACN,YAAa,8CACb,QAAS,EACT,QAAS,CAC3B,EACgB,EAAG,CACD,KAAM,SACN,YAAa,8CACb,QAAS,EACT,QAAS,CAC3B,EACgB,EAAG,CACD,KAAM,SACN,YAAa,yBACb,QAAS,EACT,QAAS,CAC3B,EACgB,EAAG,CACD,KAAM,SACN,YAAa,0BACb,QAAS,EACT,QAAS,CAC3B,CACA,EACc,SAAU,CAAC,IAAK,IAAK,IAAK,GAAG,CAC3C,EACY,SAAU,CACtB,EACU,MAAO,CACL,KAAM,SACN,YAAa,0IACb,QAAS,wBACrB,EACU,KAAM,CACJ,KAAM,UACN,YAAa,uDACb,QAAS,CACrB,EACU,aAAc,CACZ,KAAM,SACN,YAAa,6EACb,QAAS,SACrB,CACA,EACQ,SAAU,CAAC,QAAS,OAAQ,cAAc,CAClD,CACA,CACA,EACE,CACE,KAAM,WACN,SAAU,CACR,KAAM,yBACN,YAAa,4KACb,WAAY,CACV,KAAM,SACN,WAAY,CACV,QAAS,CACP,KAAM,SACN,YAAa,qCACb,UAAW,EACX,UAAW,GACvB,EACU,EAAG,CACD,KAAM,SACN,YAAa,wDACb,QAAS,EACT,QAAS,CACrB,EACU,EAAG,CACD,KAAM,SACN,YAAa,wDACb,QAAS,EACT,QAAS,CACrB,EACU,EAAG,CACD,KAAM,SACN,YAAa,yCACb,QAAS,EACT,QAAS,CACrB,EACU,EAAG,CACD,KAAM,SACN,YAAa,0CACb,QAAS,EACT,QAAS,CACrB,EACU,KAAM,CACJ,KAAM,UACN,YAAa,uDACb,QAAS,CACrB,EACU,UAAW,CACT,KAAM,SACN,YAAa,8EACb,QAAS,SACrB,EACU,QAAS,CACP,KAAM,SACN,YAAa,uNACb,QAAS,aACrB,EACU,aAAc,CACZ,KAAM,SACN,YAAa,6EACb,QAAS,SACrB,CACA,EACQ,SAAU,CAAC,UAAW,IAAK,IAAK,IAAK,IAAK,OAAQ,cAAc,CACxE,CACA,CACA,CACA,EAaO,SAASC,EAAmBC,EAAe,GAAI,CACpD,GAAI,CAAC,MAAM,QAAQA,CAAY,GAAKA,EAAa,SAAW,EAC1D,MAAO,CAAA,EAGT,MAAMC,EAAU,CACd,UAAa,8BACb,KAAQ,wBACZ,EAEQC,EAAuBF,EAC1B,IAAIG,GAAQF,EAAQE,CAAI,CAAC,EACzB,OAAO,OAAO,EAEjB,OAAOL,EAAgB,OAAOM,GAC5BF,EAAqB,SAASE,EAAK,SAAS,IAAI,CACpD,CACA"}
1
+ {"version":3,"file":"index21.cjs","sources":["../src/pen/presets.js"],"sourcesContent":["/**\n * Client-side style presets for Digital Pen\n *\n * These presets use the same format as StrokeRenderer.setConfig().\n * Keys match annotation types: highlight, text, underline, arrow, circle.\n */\n\n/**\n * Default preset - Yellow highlights, crimson text\n */\nexport const DEFAULT_PRESET = {\n highlight: {\n color: 'rgba(255, 255, 0, 0.3)',\n width: 24\n },\n text: {\n color: 'rgba(220, 20, 60, 1.0)',\n width: 2\n },\n underline: {\n color: 'rgba(0, 80, 255, 1.0)',\n width: 2\n },\n arrow: {\n color: 'rgba(220, 30, 30, 1.0)',\n width: 2\n },\n circle: {\n color: 'rgba(255, 140, 0, 1.0)',\n width: 3\n }\n};\n\n/**\n * Blue preset - Blue theme\n */\nexport const BLUE_PRESET = {\n highlight: {\n color: 'rgba(100, 149, 237, 0.35)',\n width: 24\n },\n text: {\n color: 'rgba(30, 64, 175, 1.0)',\n width: 2\n },\n underline: {\n color: 'rgba(30, 64, 175, 1.0)',\n width: 2\n },\n arrow: {\n color: 'rgba(30, 64, 175, 1.0)',\n width: 2\n },\n circle: {\n color: 'rgba(30, 64, 175, 1.0)',\n width: 3\n }\n};\n\n/**\n * Minimal preset - Subtle gray\n */\nexport const MINIMAL_PRESET = {\n highlight: {\n color: 'rgba(156, 163, 175, 0.25)',\n width: 20\n },\n text: {\n color: 'rgba(75, 85, 99, 1.0)',\n width: 1.5\n },\n underline: {\n color: 'rgba(75, 85, 99, 1.0)',\n width: 1.5\n },\n arrow: {\n color: 'rgba(75, 85, 99, 1.0)',\n width: 1.5\n },\n circle: {\n color: 'rgba(75, 85, 99, 1.0)',\n width: 2\n }\n};\n\n/**\n * Preset registry\n */\nconst PRESETS = {\n default: DEFAULT_PRESET,\n blue: BLUE_PRESET,\n minimal: MINIMAL_PRESET\n};\n\n/**\n * Get a preset by name\n *\n * @param {string} name - Preset name\n * @returns {Object} Preset configuration\n */\nexport function getPreset(name) {\n return PRESETS[name] || PRESETS.default;\n}\n\n/**\n * Get all available preset names\n *\n * @returns {string[]} Array of preset names\n */\nexport function getPresetNames() {\n return Object.keys(PRESETS);\n}\n\nexport default PRESETS;\n"],"names":["DEFAULT_PRESET","BLUE_PRESET","MINIMAL_PRESET","PRESETS","getPreset","name","getPresetNames"],"mappings":"4GAUY,MAACA,EAAiB,CAC5B,UAAW,CACT,MAAO,yBACP,MAAO,EACX,EACE,KAAM,CACJ,MAAO,yBACP,MAAO,CACX,EACE,UAAW,CACT,MAAO,wBACP,MAAO,CACX,EACE,MAAO,CACL,MAAO,yBACP,MAAO,CACX,EACE,OAAQ,CACN,MAAO,yBACP,MAAO,CACX,CACA,EAKaC,EAAc,CACzB,UAAW,CACT,MAAO,4BACP,MAAO,EACX,EACE,KAAM,CACJ,MAAO,yBACP,MAAO,CACX,EACE,UAAW,CACT,MAAO,yBACP,MAAO,CACX,EACE,MAAO,CACL,MAAO,yBACP,MAAO,CACX,EACE,OAAQ,CACN,MAAO,yBACP,MAAO,CACX,CACA,EAKaC,EAAiB,CAC5B,UAAW,CACT,MAAO,4BACP,MAAO,EACX,EACE,KAAM,CACJ,MAAO,wBACP,MAAO,GACX,EACE,UAAW,CACT,MAAO,wBACP,MAAO,GACX,EACE,MAAO,CACL,MAAO,wBACP,MAAO,GACX,EACE,OAAQ,CACN,MAAO,wBACP,MAAO,CACX,CACA,EAKMC,EAAU,CACd,QAASH,EACT,KAAMC,EACN,QAASC,CACX,EAQO,SAASE,EAAUC,EAAM,CAC9B,OAAOF,EAAQE,CAAI,GAAKF,EAAQ,OAClC,CAOO,SAASG,GAAiB,CAC/B,OAAO,OAAO,KAAKH,CAAO,CAC5B"}
package/dist/index21.js CHANGED
@@ -1,144 +1,83 @@
1
- const r = [
2
- {
3
- type: "function",
4
- function: {
5
- name: "create_highlight_annotation",
6
- description: "Create a highlight annotation at specified coordinates on the PDF page. Use this to emphasize important text or regions. Highlights are rectangular regions that can span multiple lines.",
7
- parameters: {
8
- type: "object",
9
- properties: {
10
- quads: {
11
- type: "array",
12
- description: "Array of rectangular regions defining the highlight areas. Each quad is an object with normalized coordinates (0-1): {x, y, w, h}. Multiple quads can be used for multi-line highlights.",
13
- items: {
14
- type: "object",
15
- properties: {
16
- x: {
17
- type: "number",
18
- description: "Normalized x position (0 = left, 1 = right)",
19
- minimum: 0,
20
- maximum: 1
21
- },
22
- y: {
23
- type: "number",
24
- description: "Normalized y position (0 = top, 1 = bottom)",
25
- minimum: 0,
26
- maximum: 1
27
- },
28
- w: {
29
- type: "number",
30
- description: "Normalized width (0-1)",
31
- minimum: 0,
32
- maximum: 1
33
- },
34
- h: {
35
- type: "number",
36
- description: "Normalized height (0-1)",
37
- minimum: 0,
38
- maximum: 1
39
- }
40
- },
41
- required: ["x", "y", "w", "h"]
42
- },
43
- minItems: 1
44
- },
45
- color: {
46
- type: "string",
47
- description: "Highlight color in rgba format (e.g., 'rgba(255, 255, 0, 0.3)'). Default is semi-transparent yellow. Use rgba for transparency control.",
48
- default: "rgba(255, 255, 0, 0.3)"
49
- },
50
- page: {
51
- type: "integer",
52
- description: "Page number (1-indexed) where the annotation appears",
53
- minimum: 1
54
- },
55
- sentence_ref: {
56
- type: "string",
57
- description: "Reference to sentence marker (e.g., 'S1', 'S2') for timing synchronization",
58
- pattern: "^S\\d+$"
59
- }
60
- },
61
- required: ["quads", "page", "sentence_ref"]
62
- }
63
- }
1
+ const o = {
2
+ highlight: {
3
+ color: "rgba(255, 255, 0, 0.3)",
4
+ width: 24
64
5
  },
65
- {
66
- type: "function",
67
- function: {
68
- name: "create_text_annotation",
69
- description: "Create a text box annotation with explanatory content. Use this to add clarifying notes, definitions, or explanations. Text boxes have background and appear as overlays.",
70
- parameters: {
71
- type: "object",
72
- properties: {
73
- content: {
74
- type: "string",
75
- description: "The text content of the annotation",
76
- minLength: 1,
77
- maxLength: 500
78
- },
79
- x: {
80
- type: "number",
81
- description: "Normalized x position (0 = left edge, 1 = right edge)",
82
- minimum: 0,
83
- maximum: 1
84
- },
85
- y: {
86
- type: "number",
87
- description: "Normalized y position (0 = top edge, 1 = bottom edge)",
88
- minimum: 0,
89
- maximum: 1
90
- },
91
- w: {
92
- type: "number",
93
- description: "Normalized width (0-1) of the text box",
94
- minimum: 0,
95
- maximum: 1
96
- },
97
- h: {
98
- type: "number",
99
- description: "Normalized height (0-1) of the text box",
100
- minimum: 0,
101
- maximum: 1
102
- },
103
- page: {
104
- type: "integer",
105
- description: "Page number (1-indexed) where the annotation appears",
106
- minimum: 1
107
- },
108
- textColor: {
109
- type: "string",
110
- description: "Text color in hex format (e.g., '#000000' for black). Default is dark gray.",
111
- default: "#1f2937"
112
- },
113
- bgColor: {
114
- type: "string",
115
- description: "Background color in rgba format or 'transparent' (e.g., 'rgba(255, 255, 255, 0.9)' or 'transparent'). Default is transparent for better visibility of underlying content. Use rgba format when background is needed.",
116
- default: "transparent"
117
- },
118
- sentence_ref: {
119
- type: "string",
120
- description: "Reference to sentence marker (e.g., 'S1', 'S2') for timing synchronization",
121
- pattern: "^S\\d+$"
122
- }
123
- },
124
- required: ["content", "x", "y", "w", "h", "page", "sentence_ref"]
125
- }
126
- }
6
+ text: {
7
+ color: "rgba(220, 20, 60, 1.0)",
8
+ width: 2
9
+ },
10
+ underline: {
11
+ color: "rgba(0, 80, 255, 1.0)",
12
+ width: 2
13
+ },
14
+ arrow: {
15
+ color: "rgba(220, 30, 30, 1.0)",
16
+ width: 2
17
+ },
18
+ circle: {
19
+ color: "rgba(255, 140, 0, 1.0)",
20
+ width: 3
21
+ }
22
+ }, i = {
23
+ highlight: {
24
+ color: "rgba(100, 149, 237, 0.35)",
25
+ width: 24
26
+ },
27
+ text: {
28
+ color: "rgba(30, 64, 175, 1.0)",
29
+ width: 2
30
+ },
31
+ underline: {
32
+ color: "rgba(30, 64, 175, 1.0)",
33
+ width: 2
34
+ },
35
+ arrow: {
36
+ color: "rgba(30, 64, 175, 1.0)",
37
+ width: 2
38
+ },
39
+ circle: {
40
+ color: "rgba(30, 64, 175, 1.0)",
41
+ width: 3
127
42
  }
128
- ];
129
- function o(e = []) {
130
- if (!Array.isArray(e) || e.length === 0)
131
- return [];
132
- const n = {
133
- highlight: "create_highlight_annotation",
134
- text: "create_text_annotation"
135
- }, i = e.map((t) => n[t]).filter(Boolean);
136
- return r.filter(
137
- (t) => i.includes(t.function.name)
138
- );
43
+ }, l = {
44
+ highlight: {
45
+ color: "rgba(156, 163, 175, 0.25)",
46
+ width: 20
47
+ },
48
+ text: {
49
+ color: "rgba(75, 85, 99, 1.0)",
50
+ width: 1.5
51
+ },
52
+ underline: {
53
+ color: "rgba(75, 85, 99, 1.0)",
54
+ width: 1.5
55
+ },
56
+ arrow: {
57
+ color: "rgba(75, 85, 99, 1.0)",
58
+ width: 1.5
59
+ },
60
+ circle: {
61
+ color: "rgba(75, 85, 99, 1.0)",
62
+ width: 2
63
+ }
64
+ }, r = {
65
+ default: o,
66
+ blue: i,
67
+ minimal: l
68
+ };
69
+ function c(t) {
70
+ return r[t] || r.default;
71
+ }
72
+ function e() {
73
+ return Object.keys(r);
139
74
  }
140
75
  export {
141
- r as annotationTools,
142
- o as getAnnotationTools
76
+ i as BLUE_PRESET,
77
+ o as DEFAULT_PRESET,
78
+ l as MINIMAL_PRESET,
79
+ r as default,
80
+ c as getPreset,
81
+ e as getPresetNames
143
82
  };
144
83
  //# sourceMappingURL=index21.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index21.js","sources":["../src/ai-tools/openai/schemas.js"],"sourcesContent":["/**\n * OpenAI Tool Schemas for PDF Annotation Generation\n *\n * Provides OpenAI-compatible function calling schemas for creating PDF annotations.\n * These schemas define the structure and parameters for AI-generated annotations.\n * Compatible with web-annotation-renderer library format.\n *\n * @module ai-tools/openai/schemas\n */\n\n/**\n * Complete set of annotation tools for OpenAI function calling\n *\n * Export this array to the OpenAI API's `tools` parameter to enable\n * AI-generated annotations.\n *\n * @constant {Array<Object>}\n * @example\n * ```javascript\n * import { annotationTools } from 'web-annotation-renderer/ai-tools';\n *\n * const response = await openai.chat.completions.create({\n * model: \"gpt-4\",\n * messages: [...],\n * tools: annotationTools\n * });\n * ```\n */\nexport const annotationTools = [\n {\n type: \"function\",\n function: {\n name: \"create_highlight_annotation\",\n description: \"Create a highlight annotation at specified coordinates on the PDF page. Use this to emphasize important text or regions. Highlights are rectangular regions that can span multiple lines.\",\n parameters: {\n type: \"object\",\n properties: {\n quads: {\n type: \"array\",\n description: \"Array of rectangular regions defining the highlight areas. Each quad is an object with normalized coordinates (0-1): {x, y, w, h}. Multiple quads can be used for multi-line highlights.\",\n items: {\n type: \"object\",\n properties: {\n x: {\n type: \"number\",\n description: \"Normalized x position (0 = left, 1 = right)\",\n minimum: 0,\n maximum: 1\n },\n y: {\n type: \"number\",\n description: \"Normalized y position (0 = top, 1 = bottom)\",\n minimum: 0,\n maximum: 1\n },\n w: {\n type: \"number\",\n description: \"Normalized width (0-1)\",\n minimum: 0,\n maximum: 1\n },\n h: {\n type: \"number\",\n description: \"Normalized height (0-1)\",\n minimum: 0,\n maximum: 1\n }\n },\n required: [\"x\", \"y\", \"w\", \"h\"]\n },\n minItems: 1\n },\n color: {\n type: \"string\",\n description: \"Highlight color in rgba format (e.g., 'rgba(255, 255, 0, 0.3)'). Default is semi-transparent yellow. Use rgba for transparency control.\",\n default: \"rgba(255, 255, 0, 0.3)\"\n },\n page: {\n type: \"integer\",\n description: \"Page number (1-indexed) where the annotation appears\",\n minimum: 1\n },\n sentence_ref: {\n type: \"string\",\n description: \"Reference to sentence marker (e.g., 'S1', 'S2') for timing synchronization\",\n pattern: \"^S\\\\d+$\"\n }\n },\n required: [\"quads\", \"page\", \"sentence_ref\"]\n }\n }\n },\n {\n type: \"function\",\n function: {\n name: \"create_text_annotation\",\n description: \"Create a text box annotation with explanatory content. Use this to add clarifying notes, definitions, or explanations. Text boxes have background and appear as overlays.\",\n parameters: {\n type: \"object\",\n properties: {\n content: {\n type: \"string\",\n description: \"The text content of the annotation\",\n minLength: 1,\n maxLength: 500\n },\n x: {\n type: \"number\",\n description: \"Normalized x position (0 = left edge, 1 = right edge)\",\n minimum: 0,\n maximum: 1\n },\n y: {\n type: \"number\",\n description: \"Normalized y position (0 = top edge, 1 = bottom edge)\",\n minimum: 0,\n maximum: 1\n },\n w: {\n type: \"number\",\n description: \"Normalized width (0-1) of the text box\",\n minimum: 0,\n maximum: 1\n },\n h: {\n type: \"number\",\n description: \"Normalized height (0-1) of the text box\",\n minimum: 0,\n maximum: 1\n },\n page: {\n type: \"integer\",\n description: \"Page number (1-indexed) where the annotation appears\",\n minimum: 1\n },\n textColor: {\n type: \"string\",\n description: \"Text color in hex format (e.g., '#000000' for black). Default is dark gray.\",\n default: \"#1f2937\"\n },\n bgColor: {\n type: \"string\",\n description: \"Background color in rgba format or 'transparent' (e.g., 'rgba(255, 255, 255, 0.9)' or 'transparent'). Default is transparent for better visibility of underlying content. Use rgba format when background is needed.\",\n default: \"transparent\"\n },\n sentence_ref: {\n type: \"string\",\n description: \"Reference to sentence marker (e.g., 'S1', 'S2') for timing synchronization\",\n pattern: \"^S\\\\d+$\"\n }\n },\n required: [\"content\", \"x\", \"y\", \"w\", \"h\", \"page\", \"sentence_ref\"]\n }\n }\n }\n];\n\n/**\n * Get filtered annotation tools based on enabled types\n *\n * @param {Array<string>} enabledTypes - Array of enabled tool types: ['highlight', 'text']\n * @returns {Array<Object>} Filtered annotation tools\n * @example\n * ```javascript\n * // Only enable highlights and text notes\n * const tools = getAnnotationTools(['highlight', 'text']);\n * ```\n */\nexport function getAnnotationTools(enabledTypes = []) {\n if (!Array.isArray(enabledTypes) || enabledTypes.length === 0) {\n return [];\n }\n\n const typeMap = {\n 'highlight': 'create_highlight_annotation',\n 'text': 'create_text_annotation'\n };\n\n const enabledFunctionNames = enabledTypes\n .map(type => typeMap[type])\n .filter(Boolean);\n\n return annotationTools.filter(tool =>\n enabledFunctionNames.includes(tool.function.name)\n );\n}\n"],"names":["annotationTools","getAnnotationTools","enabledTypes","typeMap","enabledFunctionNames","type","tool"],"mappings":"AA4BY,MAACA,IAAkB;AAAA,EAC7B;AAAA,IACE,MAAM;AAAA,IACN,UAAU;AAAA,MACR,MAAM;AAAA,MACN,aAAa;AAAA,MACb,YAAY;AAAA,QACV,MAAM;AAAA,QACN,YAAY;AAAA,UACV,OAAO;AAAA,YACL,MAAM;AAAA,YACN,aAAa;AAAA,YACb,OAAO;A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MAAM;AAAA,YACN,aAAa;AAAA,YACb,SAAS;AAAA,YACT,SAAS;AAAA,UACrB;AAAA,UACU,GAAG;AAAA,YACD,MAAM;AAAA,YACN,aAAa;AAAA,YACb,SAAS;AAAA,YACT,SAAS;AAAA,UACrB;AAAA,UACU,GAAG;AAAA,YACD,MAAM;AAAA,YACN,aAAa;AAAA,YACb,SAAS;AAAA,YACT,SAAS;AAAA,UACrB;AAAA,UACU,MAAM;AAAA,YACJ,MAAM;AAAA,YACN,aAAa;AAAA,YACb,SAAS;AAAA,UACrB;AAAA,UACU,WAAW;AAAA,YACT,MAAM;AAAA,YACN,aAAa;AAAA,YACb,SAAS;AAAA,UACrB;AAAA,UACU,SAAS;AAAA,YACP,MAAM;AAAA,YACN,aAAa;AAAA,YACb,SAAS;AAAA,UACrB;AAAA,UACU,cAAc;AAAA,YACZ,MAAM;AAAA,YACN,aAAa;AAAA,YACb,SAAS;AAAA,UACrB;AAAA,QACA;AAAA,QACQ,UAAU,CAAC,WAAW,KAAK,KAAK,KAAK,KAAK,QAAQ,cAAc;AAAA,MACxE;AAAA,IACA;AAAA,EACA;AACA;AAaO,SAASC,EAAmBC,IAAe,IAAI;AACpD,MAAI,CAAC,MAAM,QAAQA,CAAY,KAAKA,EAAa,WAAW;AAC1D,WAAO,CAAA;AAGT,QAAMC,IAAU;AAAA,IACd,WAAa;AAAA,IACb,MAAQ;AAAA,EACZ,GAEQC,IAAuBF,EAC1B,IAAI,CAAAG,MAAQF,EAAQE,CAAI,CAAC,EACzB,OAAO,OAAO;AAEjB,SAAOL,EAAgB;AAAA,IAAO,CAAAM,MAC5BF,EAAqB,SAASE,EAAK,SAAS,IAAI;AAAA,EACpD;AACA;"}
1
+ {"version":3,"file":"index21.js","sources":["../src/pen/presets.js"],"sourcesContent":["/**\n * Client-side style presets for Digital Pen\n *\n * These presets use the same format as StrokeRenderer.setConfig().\n * Keys match annotation types: highlight, text, underline, arrow, circle.\n */\n\n/**\n * Default preset - Yellow highlights, crimson text\n */\nexport const DEFAULT_PRESET = {\n highlight: {\n color: 'rgba(255, 255, 0, 0.3)',\n width: 24\n },\n text: {\n color: 'rgba(220, 20, 60, 1.0)',\n width: 2\n },\n underline: {\n color: 'rgba(0, 80, 255, 1.0)',\n width: 2\n },\n arrow: {\n color: 'rgba(220, 30, 30, 1.0)',\n width: 2\n },\n circle: {\n color: 'rgba(255, 140, 0, 1.0)',\n width: 3\n }\n};\n\n/**\n * Blue preset - Blue theme\n */\nexport const BLUE_PRESET = {\n highlight: {\n color: 'rgba(100, 149, 237, 0.35)',\n width: 24\n },\n text: {\n color: 'rgba(30, 64, 175, 1.0)',\n width: 2\n },\n underline: {\n color: 'rgba(30, 64, 175, 1.0)',\n width: 2\n },\n arrow: {\n color: 'rgba(30, 64, 175, 1.0)',\n width: 2\n },\n circle: {\n color: 'rgba(30, 64, 175, 1.0)',\n width: 3\n }\n};\n\n/**\n * Minimal preset - Subtle gray\n */\nexport const MINIMAL_PRESET = {\n highlight: {\n color: 'rgba(156, 163, 175, 0.25)',\n width: 20\n },\n text: {\n color: 'rgba(75, 85, 99, 1.0)',\n width: 1.5\n },\n underline: {\n color: 'rgba(75, 85, 99, 1.0)',\n width: 1.5\n },\n arrow: {\n color: 'rgba(75, 85, 99, 1.0)',\n width: 1.5\n },\n circle: {\n color: 'rgba(75, 85, 99, 1.0)',\n width: 2\n }\n};\n\n/**\n * Preset registry\n */\nconst PRESETS = {\n default: DEFAULT_PRESET,\n blue: BLUE_PRESET,\n minimal: MINIMAL_PRESET\n};\n\n/**\n * Get a preset by name\n *\n * @param {string} name - Preset name\n * @returns {Object} Preset configuration\n */\nexport function getPreset(name) {\n return PRESETS[name] || PRESETS.default;\n}\n\n/**\n * Get all available preset names\n *\n * @returns {string[]} Array of preset names\n */\nexport function getPresetNames() {\n return Object.keys(PRESETS);\n}\n\nexport default PRESETS;\n"],"names":["DEFAULT_PRESET","BLUE_PRESET","MINIMAL_PRESET","PRESETS","getPreset","name","getPresetNames"],"mappings":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+1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index23.cjs"),c=require("./index24.cjs");function o(r){if(!r||typeof r!="object")throw new Error("Invalid tool call: must be an object");if(!r.function||typeof r.function!="object")throw new Error("Invalid tool call: missing function property");const{name:t,arguments:e}=r.function;if(!t||typeof t!="string")throw new Error("Invalid tool call: missing or invalid function name");let n;try{n=typeof e=="string"?JSON.parse(e):e}catch(a){throw new Error(`Failed to parse tool call arguments: ${a.message}`)}switch(t){case"create_highlight_annotation":return i.createHighlight(n);case"create_text_annotation":return c.createText(n);default:throw new Error(`Unknown tool: ${t}. Supported tools: create_highlight_annotation, create_text_annotation`)}}function l(r){if(!Array.isArray(r))throw new Error("Tool calls must be an array");return r.map((t,e)=>{try{return o(t)}catch(n){throw new Error(`Error processing tool call at index ${e}: ${n.message}`)}})}exports.handleToolCall=o;exports.handleToolCalls=l;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=[{type:"function",function:{name:"create_highlight_annotation",description:"Create a highlight annotation at specified coordinates on the PDF page. Use this to emphasize important text or regions. Highlights are rectangular regions that can span multiple lines.",parameters:{type:"object",properties:{quads:{type:"array",description:"Array of rectangular regions defining the highlight areas. Each quad is an object with normalized coordinates (0-1): {x, y, w, h}. Multiple quads can be used for multi-line highlights.",items:{type:"object",properties:{x:{type:"number",description:"Normalized x position (0 = left, 1 = right)",minimum:0,maximum:1},y:{type:"number",description:"Normalized y position (0 = top, 1 = bottom)",minimum:0,maximum:1},w:{type:"number",description:"Normalized width (0-1)",minimum:0,maximum:1},h:{type:"number",description:"Normalized height (0-1)",minimum:0,maximum:1}},required:["x","y","w","h"]},minItems:1},color:{type:"string",description:"Highlight color in rgba format (e.g., 'rgba(255, 255, 0, 0.3)'). Default is semi-transparent yellow. Use rgba for transparency control.",default:"rgba(255, 255, 0, 0.3)"},page:{type:"integer",description:"Page number (1-indexed) where the annotation appears",minimum:1},sentence_ref:{type:"string",description:"Reference to sentence marker (e.g., 'S1', 'S2') for timing synchronization",pattern:"^S\\d+$"}},required:["quads","page","sentence_ref"]}}},{type:"function",function:{name:"create_text_annotation",description:"Create a text box annotation with explanatory content. Use this to add clarifying notes, definitions, or explanations. Text boxes have background and appear as overlays.",parameters:{type:"object",properties:{content:{type:"string",description:"The text content of the annotation",minLength:1,maxLength:500},x:{type:"number",description:"Normalized x position (0 = left edge, 1 = right edge)",minimum:0,maximum:1},y:{type:"number",description:"Normalized y position (0 = top edge, 1 = bottom edge)",minimum:0,maximum:1},w:{type:"number",description:"Normalized width (0-1) of the text box",minimum:0,maximum:1},h:{type:"number",description:"Normalized height (0-1) of the text box",minimum:0,maximum:1},page:{type:"integer",description:"Page number (1-indexed) where the annotation appears",minimum:1},textColor:{type:"string",description:"Text color in hex format (e.g., '#000000' for black). Default is dark gray.",default:"#1f2937"},bgColor:{type:"string",description:"Background color in rgba format or 'transparent' (e.g., 'rgba(255, 255, 255, 0.9)' or 'transparent'). Default is transparent for better visibility of underlying content. Use rgba format when background is needed.",default:"transparent"},sentence_ref:{type:"string",description:"Reference to sentence marker (e.g., 'S1', 'S2') for timing synchronization",pattern:"^S\\d+$"}},required:["content","x","y","w","h","page","sentence_ref"]}}}];function o(e=[]){if(!Array.isArray(e)||e.length===0)return[];const i={highlight:"create_highlight_annotation",text:"create_text_annotation"},r=e.map(t=>i[t]).filter(Boolean);return n.filter(t=>r.includes(t.function.name))}exports.annotationTools=n;exports.getAnnotationTools=o;
2
2
  //# sourceMappingURL=index22.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index22.cjs","sources":["../src/ai-tools/openai/handler.js"],"sourcesContent":["/**\n * OpenAI Tool Call Handler\n *\n * Processes OpenAI function calling responses and converts them into\n * valid annotation objects.\n *\n * @module ai-tools/openai/handler\n */\n\nimport { createHighlight } from '../creators/createHighlight.js';\nimport { createText } from '../creators/createText.js';\n\n/**\n * Handle an OpenAI tool call and convert it to a valid annotation\n *\n * @param {Object} toolCall - Tool call object from OpenAI API response\n * @param {Object} toolCall.function - Function call details\n * @param {string} toolCall.function.name - Function name\n * @param {string} toolCall.function.arguments - JSON string of arguments\n * @returns {Object} Valid annotation object\n * @throws {Error} If tool call is invalid or unsupported\n * @example\n * ```javascript\n * import { handleToolCall } from 'web-annotation-renderer/ai-tools';\n *\n * const response = await openai.chat.completions.create({\n * model: \"gpt-4\",\n * messages: [...],\n * tools: annotationTools\n * });\n *\n * const annotations = [];\n * if (response.choices[0].message.tool_calls) {\n * for (const toolCall of response.choices[0].message.tool_calls) {\n * const annotation = handleToolCall(toolCall);\n * annotations.push(annotation);\n * }\n * }\n * ```\n */\nexport function handleToolCall(toolCall) {\n // Validate tool call structure\n if (!toolCall || typeof toolCall !== 'object') {\n throw new Error('Invalid tool call: must be an object');\n }\n\n if (!toolCall.function || typeof toolCall.function !== 'object') {\n throw new Error('Invalid tool call: missing function property');\n }\n\n const { name, arguments: argsString } = toolCall.function;\n\n if (!name || typeof name !== 'string') {\n throw new Error('Invalid tool call: missing or invalid function name');\n }\n\n // Parse arguments\n let args;\n try {\n args = typeof argsString === 'string' ? JSON.parse(argsString) : argsString;\n } catch (error) {\n throw new Error(`Failed to parse tool call arguments: ${error.message}`);\n }\n\n // Route to appropriate creator function\n switch (name) {\n case 'create_highlight_annotation':\n return createHighlight(args);\n\n case 'create_text_annotation':\n return createText(args);\n\n default:\n throw new Error(`Unknown tool: ${name}. Supported tools: create_highlight_annotation, create_text_annotation`);\n }\n}\n\n/**\n * Process multiple tool calls from an OpenAI response\n *\n * @param {Array<Object>} toolCalls - Array of tool call objects from OpenAI\n * @returns {Array<Object>} Array of valid annotation objects\n * @example\n * ```javascript\n * const annotations = handleToolCalls(response.choices[0].message.tool_calls);\n * ```\n */\nexport function handleToolCalls(toolCalls) {\n if (!Array.isArray(toolCalls)) {\n throw new Error('Tool calls must be an array');\n }\n\n return toolCalls.map((toolCall, index) => {\n try {\n return handleToolCall(toolCall);\n } catch (error) {\n throw new Error(`Error processing tool call at index ${index}: ${error.message}`);\n }\n });\n}\n"],"names":["handleToolCall","toolCall","name","argsString","args","error","createHighlight","createText","handleToolCalls","toolCalls","index"],"mappings":"4IAwCO,SAASA,EAAeC,EAAU,CAEvC,GAAI,CAACA,GAAY,OAAOA,GAAa,SACnC,MAAM,IAAI,MAAM,sCAAsC,EAGxD,GAAI,CAACA,EAAS,UAAY,OAAOA,EAAS,UAAa,SACrD,MAAM,IAAI,MAAM,8CAA8C,EAGhE,KAAM,CAAE,KAAAC,EAAM,UAAWC,CAAU,EAAKF,EAAS,SAEjD,GAAI,CAACC,GAAQ,OAAOA,GAAS,SAC3B,MAAM,IAAI,MAAM,qDAAqD,EAIvE,IAAIE,EACJ,GAAI,CACFA,EAAO,OAAOD,GAAe,SAAW,KAAK,MAAMA,CAAU,EAAIA,CACnE,OAASE,EAAO,CACd,MAAM,IAAI,MAAM,wCAAwCA,EAAM,OAAO,EAAE,CACzE,CAGA,OAAQH,EAAI,CACV,IAAK,8BACH,OAAOI,EAAAA,gBAAgBF,CAAI,EAE7B,IAAK,yBACH,OAAOG,EAAAA,WAAWH,CAAI,EAExB,QACE,MAAM,IAAI,MAAM,iBAAiBF,CAAI,wEAAwE,CACnH,CACA,CAYO,SAASM,EAAgBC,EAAW,CACzC,GAAI,CAAC,MAAM,QAAQA,CAAS,EAC1B,MAAM,IAAI,MAAM,6BAA6B,EAG/C,OAAOA,EAAU,IAAI,CAACR,EAAUS,IAAU,CACxC,GAAI,CACF,OAAOV,EAAeC,CAAQ,CAChC,OAASI,EAAO,CACd,MAAM,IAAI,MAAM,uCAAuCK,CAAK,KAAKL,EAAM,OAAO,EAAE,CAClF,CACF,CAAC,CACH"}
1
+ {"version":3,"file":"index22.cjs","sources":["../src/ai-tools/openai/schemas.js"],"sourcesContent":["/**\n * OpenAI Tool Schemas for PDF Annotation Generation\n *\n * Provides OpenAI-compatible function calling schemas for creating PDF annotations.\n * These schemas define the structure and parameters for AI-generated annotations.\n * Compatible with web-annotation-renderer library format.\n *\n * @module ai-tools/openai/schemas\n */\n\n/**\n * Complete set of annotation tools for OpenAI function calling\n *\n * Export this array to the OpenAI API's `tools` parameter to enable\n * AI-generated annotations.\n *\n * @constant {Array<Object>}\n * @example\n * ```javascript\n * import { annotationTools } from 'web-annotation-renderer/ai-tools';\n *\n * const response = await openai.chat.completions.create({\n * model: \"gpt-4\",\n * messages: [...],\n * tools: annotationTools\n * });\n * ```\n */\nexport const annotationTools = [\n {\n type: \"function\",\n function: {\n name: \"create_highlight_annotation\",\n description: \"Create a highlight annotation at specified coordinates on the PDF page. Use this to emphasize important text or regions. Highlights are rectangular regions that can span multiple lines.\",\n parameters: {\n type: \"object\",\n properties: {\n quads: {\n type: \"array\",\n description: \"Array of rectangular regions defining the highlight areas. Each quad is an object with normalized coordinates (0-1): {x, y, w, h}. Multiple quads can be used for multi-line highlights.\",\n items: {\n type: \"object\",\n properties: {\n x: {\n type: \"number\",\n description: \"Normalized x position (0 = left, 1 = right)\",\n minimum: 0,\n maximum: 1\n },\n y: {\n type: \"number\",\n description: \"Normalized y position (0 = top, 1 = bottom)\",\n minimum: 0,\n maximum: 1\n },\n w: {\n type: \"number\",\n description: \"Normalized width (0-1)\",\n minimum: 0,\n maximum: 1\n },\n h: {\n type: \"number\",\n description: \"Normalized height (0-1)\",\n minimum: 0,\n maximum: 1\n }\n },\n required: [\"x\", \"y\", \"w\", \"h\"]\n },\n minItems: 1\n },\n color: {\n type: \"string\",\n description: \"Highlight color in rgba format (e.g., 'rgba(255, 255, 0, 0.3)'). Default is semi-transparent yellow. Use rgba for transparency control.\",\n default: \"rgba(255, 255, 0, 0.3)\"\n },\n page: {\n type: \"integer\",\n description: \"Page number (1-indexed) where the annotation appears\",\n minimum: 1\n },\n sentence_ref: {\n type: \"string\",\n description: \"Reference to sentence marker (e.g., 'S1', 'S2') for timing synchronization\",\n pattern: \"^S\\\\d+$\"\n }\n },\n required: [\"quads\", \"page\", \"sentence_ref\"]\n }\n }\n },\n {\n type: \"function\",\n function: {\n name: \"create_text_annotation\",\n description: \"Create a text box annotation with explanatory content. Use this to add clarifying notes, definitions, or explanations. Text boxes have background and appear as overlays.\",\n parameters: {\n type: \"object\",\n properties: {\n content: {\n type: \"string\",\n description: \"The text content of the annotation\",\n minLength: 1,\n maxLength: 500\n },\n x: {\n type: \"number\",\n description: \"Normalized x position (0 = left edge, 1 = right edge)\",\n minimum: 0,\n maximum: 1\n },\n y: {\n type: \"number\",\n description: \"Normalized y position (0 = top edge, 1 = bottom edge)\",\n minimum: 0,\n maximum: 1\n },\n w: {\n type: \"number\",\n description: \"Normalized width (0-1) of the text box\",\n minimum: 0,\n maximum: 1\n },\n h: {\n type: \"number\",\n description: \"Normalized height (0-1) of the text box\",\n minimum: 0,\n maximum: 1\n },\n page: {\n type: \"integer\",\n description: \"Page number (1-indexed) where the annotation appears\",\n minimum: 1\n },\n textColor: {\n type: \"string\",\n description: \"Text color in hex format (e.g., '#000000' for black). Default is dark gray.\",\n default: \"#1f2937\"\n },\n bgColor: {\n type: \"string\",\n description: \"Background color in rgba format or 'transparent' (e.g., 'rgba(255, 255, 255, 0.9)' or 'transparent'). Default is transparent for better visibility of underlying content. Use rgba format when background is needed.\",\n default: \"transparent\"\n },\n sentence_ref: {\n type: \"string\",\n description: \"Reference to sentence marker (e.g., 'S1', 'S2') for timing synchronization\",\n pattern: \"^S\\\\d+$\"\n }\n },\n required: [\"content\", \"x\", \"y\", \"w\", \"h\", \"page\", \"sentence_ref\"]\n }\n }\n }\n];\n\n/**\n * Get filtered annotation tools based on enabled types\n *\n * @param {Array<string>} enabledTypes - Array of enabled tool types: ['highlight', 'text']\n * @returns {Array<Object>} Filtered annotation tools\n * @example\n * ```javascript\n * // Only enable highlights and text notes\n * const tools = getAnnotationTools(['highlight', 'text']);\n * ```\n */\nexport function getAnnotationTools(enabledTypes = []) {\n if (!Array.isArray(enabledTypes) || enabledTypes.length === 0) {\n return [];\n }\n\n const typeMap = {\n 'highlight': 'create_highlight_annotation',\n 'text': 'create_text_annotation'\n };\n\n const enabledFunctionNames = enabledTypes\n .map(type => typeMap[type])\n .filter(Boolean);\n\n return annotationTools.filter(tool =>\n enabledFunctionNames.includes(tool.function.name)\n );\n}\n"],"names":["annotationTools","getAnnotationTools","enabledTypes","typeMap","enabledFunctionNames","type","tool"],"mappings":"gFA4BY,MAACA,EAAkB,CAC7B,CACE,KAAM,WACN,SAAU,CACR,KAAM,8BACN,YAAa,4LACb,WAAY,CACV,KAAM,SACN,WAAY,CACV,MAAO,CACL,KAAM,QACN,YAAa,2LACb,MAAO,CACL,KAAM,SACN,WAAY,CACV,EAAG,CACD,KAAM,SACN,YAAa,8CACb,QAAS,EACT,QAAS,CAC3B,EACgB,EAAG,CACD,KAAM,SACN,YAAa,8CACb,QAAS,EACT,QAAS,CAC3B,EACgB,EAAG,CACD,KAAM,SACN,YAAa,yBACb,QAAS,EACT,QAAS,CAC3B,EACgB,EAAG,CACD,KAAM,SACN,YAAa,0BACb,QAAS,EACT,QAAS,CAC3B,CACA,EACc,SAAU,CAAC,IAAK,IAAK,IAAK,GAAG,CAC3C,EACY,SAAU,CACtB,EACU,MAAO,CACL,KAAM,SACN,YAAa,0IACb,QAAS,wBACrB,EACU,KAAM,CACJ,KAAM,UACN,YAAa,uDACb,QAAS,CACrB,EACU,aAAc,CACZ,KAAM,SACN,YAAa,6EACb,QAAS,SACrB,CACA,EACQ,SAAU,CAAC,QAAS,OAAQ,cAAc,CAClD,CACA,CACA,EACE,CACE,KAAM,WACN,SAAU,CACR,KAAM,yBACN,YAAa,4KACb,WAAY,CACV,KAAM,SACN,WAAY,CACV,QAAS,CACP,KAAM,SACN,YAAa,qCACb,UAAW,EACX,UAAW,GACvB,EACU,EAAG,CACD,KAAM,SACN,YAAa,wDACb,QAAS,EACT,QAAS,CACrB,EACU,EAAG,CACD,KAAM,SACN,YAAa,wDACb,QAAS,EACT,QAAS,CACrB,EACU,EAAG,CACD,KAAM,SACN,YAAa,yCACb,QAAS,EACT,QAAS,CACrB,E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