web-annotation-renderer 0.1.4 → 0.3.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/README.md +176 -6
- package/ai-tools.js +11 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +41 -25
- package/dist/index.js.map +1 -1
- package/dist/index12.cjs +1 -1
- package/dist/index12.cjs.map +1 -1
- package/dist/index12.js +118 -189
- package/dist/index12.js.map +1 -1
- package/dist/index13.cjs +1 -1
- package/dist/index13.cjs.map +1 -1
- package/dist/index13.js +200 -15
- package/dist/index13.js.map +1 -1
- package/dist/index14.cjs +1 -1
- package/dist/index14.cjs.map +1 -1
- package/dist/index14.js +15 -123
- package/dist/index14.js.map +1 -1
- package/dist/index15.cjs +1 -1
- package/dist/index15.cjs.map +1 -1
- package/dist/index15.js +123 -32
- package/dist/index15.js.map +1 -1
- package/dist/index16.cjs +2 -0
- package/dist/index16.cjs.map +1 -0
- package/dist/index16.js +219 -0
- package/dist/index16.js.map +1 -0
- package/dist/index17.cjs +2 -0
- package/dist/index17.cjs.map +1 -0
- package/dist/index17.js +44 -0
- package/dist/index17.js.map +1 -0
- package/dist/index18.cjs +2 -0
- package/dist/index18.cjs.map +1 -0
- package/dist/index18.js +40 -0
- package/dist/index18.js.map +1 -0
- package/dist/index19.cjs +2 -0
- package/dist/index19.cjs.map +1 -0
- package/dist/index19.js +41 -0
- package/dist/index19.js.map +1 -0
- package/dist/index20.cjs +2 -0
- package/dist/index20.cjs.map +1 -0
- package/dist/index20.js +50 -0
- package/dist/index20.js.map +1 -0
- package/dist/index21.cjs +2 -0
- package/dist/index21.cjs.map +1 -0
- package/dist/index21.js +35 -0
- package/dist/index21.js.map +1 -0
- package/dist/index22.cjs +2 -0
- package/dist/index22.cjs.map +1 -0
- package/dist/index22.js +8 -0
- package/dist/index22.js.map +1 -0
- package/package.json +10 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index18.js","sources":["../src/ai-tools/creators/createHighlight.js"],"sourcesContent":["/**\n * Highlight Annotation Creator\n *\n * Converts AI-generated tool call arguments into valid highlight annotation objects\n * compatible with web-annotation-renderer library format.\n *\n * @module ai-tools/creators/createHighlight\n */\n\nimport { generateId } from '../../utils/idGenerator.js';\n\n/**\n * Create a highlight annotation from tool call arguments\n *\n * @param {Object} args - Tool call arguments from AI\n * @param {Array<Object>} args.quads - Rectangle objects with {x, y, w, h} (normalized 0-1)\n * @param {string} [args.color='rgba(255, 255, 0, 0.3)'] - Highlight color in rgba format\n * @param {number} args.page - Page number (1-indexed)\n * @param {string} args.sentence_ref - Sentence reference for timing (e.g., 'S1')\n * @returns {Object} Valid highlight annotation object\n * @example\n * ```javascript\n * const highlight = createHighlight({\n * quads: [{x: 0.1, y: 0.2, w: 0.8, h: 0.05}],\n * color: 'rgba(255, 255, 0, 0.3)',\n * page: 1,\n * sentence_ref: 'S2'\n * });\n * ```\n */\nexport function createHighlight(args) {\n // Validate required fields\n if (!args.quads || !Array.isArray(args.quads) || args.quads.length === 0) {\n throw new Error('Highlight annotation requires at least one quad');\n }\n\n if (!args.page || typeof args.page !== 'number' || args.page < 1) {\n throw new Error('Highlight annotation requires a valid page number (>= 1)');\n }\n\n if (!args.sentence_ref || typeof args.sentence_ref !== 'string') {\n throw new Error('Highlight annotation requires a sentence_ref for timing');\n }\n\n // Validate quad format - each quad must be an object with {x, y, w, h}\n args.quads.forEach((quad, index) => {\n if (typeof quad !== 'object' || quad === null || Array.isArray(quad)) {\n throw new Error(`Quad at index ${index} must be an object with {x, y, w, h} properties`);\n }\n\n const requiredProps = ['x', 'y', 'w', 'h'];\n for (const prop of requiredProps) {\n if (typeof quad[prop] !== 'number') {\n throw new Error(`Quad at index ${index} is missing required property '${prop}' or it's not a number`);\n }\n if (quad[prop] < 0 || quad[prop] > 1) {\n throw new Error(`Quad property '${prop}' at index ${index} must be between 0 and 1 (got ${quad[prop]})`);\n }\n }\n });\n\n // Validate color format (should be rgba)\n const color = args.color || 'rgba(255, 255, 0, 0.3)';\n\n // Create annotation object matching library format\n return {\n id: generateId('highlight'),\n type: 'highlight',\n mode: 'quads', // Required by HighlightLayer\n page: args.page,\n quads: args.quads, // Array of {x, y, w, h} objects\n style: {\n color: color // Color wrapped in style object\n },\n sentence_ref: args.sentence_ref,\n // Note: start/end will be added during timing sync phase\n };\n}\n"],"names":["createHighlight","args","quad","index","requiredProps","prop","color","generateId"],"mappings":";AA8BO,SAASA,EAAgBC,GAAM;AAEpC,MAAI,CAACA,EAAK,SAAS,CAAC,MAAM,QAAQA,EAAK,KAAK,KAAKA,EAAK,MAAM,WAAW;AACrE,UAAM,IAAI,MAAM,iDAAiD;AAGnE,MAAI,CAACA,EAAK,QAAQ,OAAOA,EAAK,QAAS,YAAYA,EAAK,OAAO;AAC7D,UAAM,IAAI,MAAM,0DAA0D;AAG5E,MAAI,CAACA,EAAK,gBAAgB,OAAOA,EAAK,gBAAiB;AACrD,UAAM,IAAI,MAAM,yDAAyD;AAI3E,EAAAA,EAAK,MAAM,QAAQ,CAACC,GAAMC,MAAU;AAClC,QAAI,OAAOD,KAAS,YAAYA,MAAS,QAAQ,MAAM,QAAQA,CAAI;AACjE,YAAM,IAAI,MAAM,iBAAiBC,CAAK,iDAAiD;AAGzF,UAAMC,IAAgB,CAAC,KAAK,KAAK,KAAK,GAAG;AACzC,eAAWC,KAAQD,GAAe;AAChC,UAAI,OAAOF,EAAKG,CAAI,KAAM;AACxB,cAAM,IAAI,MAAM,iBAAiBF,CAAK,kCAAkCE,CAAI,wBAAwB;AAEtG,UAAIH,EAAKG,CAAI,IAAI,KAAKH,EAAKG,CAAI,IAAI;AACjC,cAAM,IAAI,MAAM,kBAAkBA,CAAI,cAAcF,CAAK,iCAAiCD,EAAKG,CAAI,CAAC,GAAG;AAAA,IAE3G;AAAA,EACF,CAAC;AAGD,QAAMC,IAAQL,EAAK,SAAS;AAG5B,SAAO;AAAA,IACL,IAAIM,EAAW,WAAW;AAAA,IAC1B,MAAM;AAAA,IACN,MAAM;AAAA;AAAA,IACN,MAAMN,EAAK;AAAA,IACX,OAAOA,EAAK;AAAA;AAAA,IACZ,OAAO;AAAA,MACL,OAAOK;AAAA;AAAA,IACb;AAAA,IACI,cAAcL,EAAK;AAAA;AAAA,EAEvB;AACA;"}
|
package/dist/index19.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index22.cjs");function r(e){if(!e.content||typeof e.content!="string"||e.content.trim().length===0)throw new Error("Text annotation requires non-empty content");if(typeof e.x!="number"||e.x<0||e.x>1)throw new Error("Text annotation x position must be between 0 and 1");if(typeof e.y!="number"||e.y<0||e.y>1)throw new Error("Text annotation y position must be between 0 and 1");if(typeof e.w!="number"||e.w<0||e.w>1)throw new Error("Text annotation width (w) must be between 0 and 1");if(typeof e.h!="number"||e.h<0||e.h>1)throw new Error("Text annotation height (h) must be between 0 and 1");if(!e.page||typeof e.page!="number"||e.page<1)throw new Error("Text annotation requires a valid page number (>= 1)");if(!e.sentence_ref||typeof e.sentence_ref!="string")throw new Error("Text annotation requires a sentence_ref for timing");const t=e.textColor||"#1f2937",n=e.bgColor||"rgba(255, 255, 255, 0.9)";return{id:o.generateId("text"),type:"text",page:e.page,content:e.content.trim(),x:e.x,y:e.y,w:e.w,h:e.h,style:{bg:n,color:t},sentence_ref:e.sentence_ref}}exports.createText=r;
|
|
2
|
+
//# sourceMappingURL=index19.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index19.cjs","sources":["../src/ai-tools/creators/createText.js"],"sourcesContent":["/**\n * Text Annotation Creator\n *\n * Converts AI-generated tool call arguments into valid text annotation objects\n * compatible with web-annotation-renderer library format.\n *\n * @module ai-tools/creators/createText\n */\n\nimport { generateId } from '../../utils/idGenerator.js';\n\n/**\n * Create a text annotation from tool call arguments\n *\n * @param {Object} args - Tool call arguments from AI\n * @param {string} args.content - Text content\n * @param {number} args.x - Horizontal position (0-1)\n * @param {number} args.y - Vertical position (0-1)\n * @param {number} args.w - Width (0-1)\n * @param {number} args.h - Height (0-1)\n * @param {number} args.page - Page number (1-indexed)\n * @param {string} [args.textColor='#1f2937'] - Text color in hex format\n * @param {string} [args.bgColor='rgba(255, 255, 255, 0.9)'] - Background color in rgba format\n * @param {string} args.sentence_ref - Sentence reference for timing (e.g., 'S1')\n * @returns {Object} Valid text annotation object\n * @example\n * ```javascript\n * const textNote = createText({\n * content: 'This is important',\n * x: 0.1,\n * y: 0.5,\n * w: 0.3,\n * h: 0.1,\n * page: 1,\n * textColor: '#000000',\n * bgColor: 'rgba(255, 255, 255, 0.9)',\n * sentence_ref: 'S3'\n * });\n * ```\n */\nexport function createText(args) {\n // Validate required fields\n if (!args.content || typeof args.content !== 'string' || args.content.trim().length === 0) {\n throw new Error('Text annotation requires non-empty content');\n }\n\n if (typeof args.x !== 'number' || args.x < 0 || args.x > 1) {\n throw new Error('Text annotation x position must be between 0 and 1');\n }\n\n if (typeof args.y !== 'number' || args.y < 0 || args.y > 1) {\n throw new Error('Text annotation y position must be between 0 and 1');\n }\n\n if (typeof args.w !== 'number' || args.w < 0 || args.w > 1) {\n throw new Error('Text annotation width (w) must be between 0 and 1');\n }\n\n if (typeof args.h !== 'number' || args.h < 0 || args.h > 1) {\n throw new Error('Text annotation height (h) must be between 0 and 1');\n }\n\n if (!args.page || typeof args.page !== 'number' || args.page < 1) {\n throw new Error('Text annotation requires a valid page number (>= 1)');\n }\n\n if (!args.sentence_ref || typeof args.sentence_ref !== 'string') {\n throw new Error('Text annotation requires a sentence_ref for timing');\n }\n\n // Get colors with defaults\n const textColor = args.textColor || '#1f2937';\n const bgColor = args.bgColor || 'rgba(255, 255, 255, 0.9)';\n\n // Create annotation object matching library format\n return {\n id: generateId('text'),\n type: 'text', // Type name is 'text', not 'text_annotation'\n page: args.page,\n content: args.content.trim(),\n x: args.x, // Direct properties, not in position object\n y: args.y,\n w: args.w,\n h: args.h,\n style: { // Colors wrapped in style object\n bg: bgColor,\n color: textColor\n },\n sentence_ref: args.sentence_ref,\n // Note: start/end will be added during timing sync phase\n };\n}\n"],"names":["createText","args","textColor","bgColor","generateId"],"mappings":"iHAwCO,SAASA,EAAWC,EAAM,CAE/B,GAAI,CAACA,EAAK,SAAW,OAAOA,EAAK,SAAY,UAAYA,EAAK,QAAQ,OAAO,SAAW,EACtF,MAAM,IAAI,MAAM,4CAA4C,EAG9D,GAAI,OAAOA,EAAK,GAAM,UAAYA,EAAK,EAAI,GAAKA,EAAK,EAAI,EACvD,MAAM,IAAI,MAAM,oDAAoD,EAGtE,GAAI,OAAOA,EAAK,GAAM,UAAYA,EAAK,EAAI,GAAKA,EAAK,EAAI,EACvD,MAAM,IAAI,MAAM,oDAAoD,EAGtE,GAAI,OAAOA,EAAK,GAAM,UAAYA,EAAK,EAAI,GAAKA,EAAK,EAAI,EACvD,MAAM,IAAI,MAAM,mDAAmD,EAGrE,GAAI,OAAOA,EAAK,GAAM,UAAYA,EAAK,EAAI,GAAKA,EAAK,EAAI,EACvD,MAAM,IAAI,MAAM,oDAAoD,EAGtE,GAAI,CAACA,EAAK,MAAQ,OAAOA,EAAK,MAAS,UAAYA,EAAK,KAAO,EAC7D,MAAM,IAAI,MAAM,qDAAqD,EAGvE,GAAI,CAACA,EAAK,cAAgB,OAAOA,EAAK,cAAiB,SACrD,MAAM,IAAI,MAAM,oDAAoD,EAItE,MAAMC,EAAYD,EAAK,WAAa,UAC9BE,EAAUF,EAAK,SAAW,2BAGhC,MAAO,CACL,GAAIG,EAAAA,WAAW,MAAM,EACrB,KAAM,OACN,KAAMH,EAAK,KACX,QAASA,EAAK,QAAQ,KAAI,EAC1B,EAAGA,EAAK,EACR,EAAGA,EAAK,EACR,EAAGA,EAAK,EACR,EAAGA,EAAK,EACR,MAAO,CACL,GAAIE,EACJ,MAAOD,CACb,EACI,aAAcD,EAAK,YAEvB,CACA"}
|
package/dist/index19.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { generateId as o } from "./index22.js";
|
|
2
|
+
function i(e) {
|
|
3
|
+
if (!e.content || typeof e.content != "string" || e.content.trim().length === 0)
|
|
4
|
+
throw new Error("Text annotation requires non-empty content");
|
|
5
|
+
if (typeof e.x != "number" || e.x < 0 || e.x > 1)
|
|
6
|
+
throw new Error("Text annotation x position must be between 0 and 1");
|
|
7
|
+
if (typeof e.y != "number" || e.y < 0 || e.y > 1)
|
|
8
|
+
throw new Error("Text annotation y position must be between 0 and 1");
|
|
9
|
+
if (typeof e.w != "number" || e.w < 0 || e.w > 1)
|
|
10
|
+
throw new Error("Text annotation width (w) must be between 0 and 1");
|
|
11
|
+
if (typeof e.h != "number" || e.h < 0 || e.h > 1)
|
|
12
|
+
throw new Error("Text annotation height (h) must be between 0 and 1");
|
|
13
|
+
if (!e.page || typeof e.page != "number" || e.page < 1)
|
|
14
|
+
throw new Error("Text annotation requires a valid page number (>= 1)");
|
|
15
|
+
if (!e.sentence_ref || typeof e.sentence_ref != "string")
|
|
16
|
+
throw new Error("Text annotation requires a sentence_ref for timing");
|
|
17
|
+
const t = e.textColor || "#1f2937", n = e.bgColor || "rgba(255, 255, 255, 0.9)";
|
|
18
|
+
return {
|
|
19
|
+
id: o("text"),
|
|
20
|
+
type: "text",
|
|
21
|
+
// Type name is 'text', not 'text_annotation'
|
|
22
|
+
page: e.page,
|
|
23
|
+
content: e.content.trim(),
|
|
24
|
+
x: e.x,
|
|
25
|
+
// Direct properties, not in position object
|
|
26
|
+
y: e.y,
|
|
27
|
+
w: e.w,
|
|
28
|
+
h: e.h,
|
|
29
|
+
style: {
|
|
30
|
+
// Colors wrapped in style object
|
|
31
|
+
bg: n,
|
|
32
|
+
color: t
|
|
33
|
+
},
|
|
34
|
+
sentence_ref: e.sentence_ref
|
|
35
|
+
// Note: start/end will be added during timing sync phase
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
i as createText
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=index19.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index19.js","sources":["../src/ai-tools/creators/createText.js"],"sourcesContent":["/**\n * Text Annotation Creator\n *\n * Converts AI-generated tool call arguments into valid text annotation objects\n * compatible with web-annotation-renderer library format.\n *\n * @module ai-tools/creators/createText\n */\n\nimport { generateId } from '../../utils/idGenerator.js';\n\n/**\n * Create a text annotation from tool call arguments\n *\n * @param {Object} args - Tool call arguments from AI\n * @param {string} args.content - Text content\n * @param {number} args.x - Horizontal position (0-1)\n * @param {number} args.y - Vertical position (0-1)\n * @param {number} args.w - Width (0-1)\n * @param {number} args.h - Height (0-1)\n * @param {number} args.page - Page number (1-indexed)\n * @param {string} [args.textColor='#1f2937'] - Text color in hex format\n * @param {string} [args.bgColor='rgba(255, 255, 255, 0.9)'] - Background color in rgba format\n * @param {string} args.sentence_ref - Sentence reference for timing (e.g., 'S1')\n * @returns {Object} Valid text annotation object\n * @example\n * ```javascript\n * const textNote = createText({\n * content: 'This is important',\n * x: 0.1,\n * y: 0.5,\n * w: 0.3,\n * h: 0.1,\n * page: 1,\n * textColor: '#000000',\n * bgColor: 'rgba(255, 255, 255, 0.9)',\n * sentence_ref: 'S3'\n * });\n * ```\n */\nexport function createText(args) {\n // Validate required fields\n if (!args.content || typeof args.content !== 'string' || args.content.trim().length === 0) {\n throw new Error('Text annotation requires non-empty content');\n }\n\n if (typeof args.x !== 'number' || args.x < 0 || args.x > 1) {\n throw new Error('Text annotation x position must be between 0 and 1');\n }\n\n if (typeof args.y !== 'number' || args.y < 0 || args.y > 1) {\n throw new Error('Text annotation y position must be between 0 and 1');\n }\n\n if (typeof args.w !== 'number' || args.w < 0 || args.w > 1) {\n throw new Error('Text annotation width (w) must be between 0 and 1');\n }\n\n if (typeof args.h !== 'number' || args.h < 0 || args.h > 1) {\n throw new Error('Text annotation height (h) must be between 0 and 1');\n }\n\n if (!args.page || typeof args.page !== 'number' || args.page < 1) {\n throw new Error('Text annotation requires a valid page number (>= 1)');\n }\n\n if (!args.sentence_ref || typeof args.sentence_ref !== 'string') {\n throw new Error('Text annotation requires a sentence_ref for timing');\n }\n\n // Get colors with defaults\n const textColor = args.textColor || '#1f2937';\n const bgColor = args.bgColor || 'rgba(255, 255, 255, 0.9)';\n\n // Create annotation object matching library format\n return {\n id: generateId('text'),\n type: 'text', // Type name is 'text', not 'text_annotation'\n page: args.page,\n content: args.content.trim(),\n x: args.x, // Direct properties, not in position object\n y: args.y,\n w: args.w,\n h: args.h,\n style: { // Colors wrapped in style object\n bg: bgColor,\n color: textColor\n },\n sentence_ref: args.sentence_ref,\n // Note: start/end will be added during timing sync phase\n };\n}\n"],"names":["createText","args","textColor","bgColor","generateId"],"mappings":";AAwCO,SAASA,EAAWC,GAAM;AAE/B,MAAI,CAACA,EAAK,WAAW,OAAOA,EAAK,WAAY,YAAYA,EAAK,QAAQ,OAAO,WAAW;AACtF,UAAM,IAAI,MAAM,4CAA4C;AAG9D,MAAI,OAAOA,EAAK,KAAM,YAAYA,EAAK,IAAI,KAAKA,EAAK,IAAI;AACvD,UAAM,IAAI,MAAM,oDAAoD;AAGtE,MAAI,OAAOA,EAAK,KAAM,YAAYA,EAAK,IAAI,KAAKA,EAAK,IAAI;AACvD,UAAM,IAAI,MAAM,oDAAoD;AAGtE,MAAI,OAAOA,EAAK,KAAM,YAAYA,EAAK,IAAI,KAAKA,EAAK,IAAI;AACvD,UAAM,IAAI,MAAM,mDAAmD;AAGrE,MAAI,OAAOA,EAAK,KAAM,YAAYA,EAAK,IAAI,KAAKA,EAAK,IAAI;AACvD,UAAM,IAAI,MAAM,oDAAoD;AAGtE,MAAI,CAACA,EAAK,QAAQ,OAAOA,EAAK,QAAS,YAAYA,EAAK,OAAO;AAC7D,UAAM,IAAI,MAAM,qDAAqD;AAGvE,MAAI,CAACA,EAAK,gBAAgB,OAAOA,EAAK,gBAAiB;AACrD,UAAM,IAAI,MAAM,oDAAoD;AAItE,QAAMC,IAAYD,EAAK,aAAa,WAC9BE,IAAUF,EAAK,WAAW;AAGhC,SAAO;AAAA,IACL,IAAIG,EAAW,MAAM;AAAA,IACrB,MAAM;AAAA;AAAA,IACN,MAAMH,EAAK;AAAA,IACX,SAASA,EAAK,QAAQ,KAAI;AAAA,IAC1B,GAAGA,EAAK;AAAA;AAAA,IACR,GAAGA,EAAK;AAAA,IACR,GAAGA,EAAK;AAAA,IACR,GAAGA,EAAK;AAAA,IACR,OAAO;AAAA;AAAA,MACL,IAAIE;AAAA,MACJ,OAAOD;AAAA,IACb;AAAA,IACI,cAAcD,EAAK;AAAA;AAAA,EAEvB;AACA;"}
|
package/dist/index20.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./index22.cjs");function w(e){if(!e.strokes||!Array.isArray(e.strokes)||e.strokes.length===0)throw new Error("Ink annotation requires at least one stroke");if(!e.page||typeof e.page!="number"||e.page<1)throw new Error("Ink annotation requires a valid page number (>= 1)");if(!e.sentence_ref||typeof e.sentence_ref!="string")throw new Error("Ink annotation requires a sentence_ref for timing");return e.strokes.forEach((r,o)=>{if(typeof r!="object"||r===null||Array.isArray(r))throw new Error(`Stroke at index ${o} must be an object with {color, size, points} properties`);if(!r.points||!Array.isArray(r.points)||r.points.length<2)throw new Error(`Stroke at index ${o} must have at least 2 points`);r.points.forEach((t,n)=>{if(typeof t!="object"||t===null)throw new Error(`Point at stroke[${o}][${n}] must be an object with {t, x, y} properties`);const a=["t","x","y"];for(const s of a)if(typeof t[s]!="number")throw new Error(`Point at stroke[${o}][${n}] is missing required property '${s}' or it's not a number`);if(t.t<0)throw new Error(`Point time offset (t) at stroke[${o}][${n}] must be >= 0 (got ${t.t})`);if(t.x<0||t.x>1)throw new Error(`Point x coordinate at stroke[${o}][${n}] must be between 0 and 1 (got ${t.x})`);if(t.y<0||t.y>1)throw new Error(`Point y coordinate at stroke[${o}][${n}] must be between 0 and 1 (got ${t.y})`)});const i=r.size||3;if(i<1||i>10)throw new Error(`Stroke size at index ${o} must be between 1 and 10 pixels (got ${i})`)}),{id:f.generateId("ink"),type:"ink",page:e.page,strokes:e.strokes.map(r=>({color:r.color||"#1f2937",size:r.size||3,points:r.points})),sentence_ref:e.sentence_ref}}exports.createInk=w;
|
|
2
|
+
//# sourceMappingURL=index20.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index20.cjs","sources":["../src/ai-tools/creators/createInk.js"],"sourcesContent":["/**\n * Ink Annotation Creator\n *\n * Converts AI-generated tool call arguments into valid ink/drawing annotation objects\n * compatible with web-annotation-renderer library format.\n *\n * @module ai-tools/creators/createInk\n */\n\nimport { generateId } from '../../utils/idGenerator.js';\n\n/**\n * Create an ink (drawing) annotation from tool call arguments\n *\n * @param {Object} args - Tool call arguments from AI\n * @param {Array<Object>} args.strokes - Array of stroke objects with color, size, and points\n * @param {number} args.page - Page number (1-indexed)\n * @param {string} args.sentence_ref - Sentence reference for timing (e.g., 'S1')\n * @returns {Object} Valid ink annotation object\n * @example\n * ```javascript\n * const drawing = createInk({\n * strokes: [\n * {\n * color: '#FF0000',\n * size: 2,\n * points: [\n * {t: 0, x: 0.1, y: 0.1},\n * {t: 0.5, x: 0.2, y: 0.2}\n * ]\n * }\n * ],\n * page: 1,\n * sentence_ref: 'S4'\n * });\n * ```\n */\nexport function createInk(args) {\n // Validate required fields\n if (!args.strokes || !Array.isArray(args.strokes) || args.strokes.length === 0) {\n throw new Error('Ink annotation requires at least one stroke');\n }\n\n if (!args.page || typeof args.page !== 'number' || args.page < 1) {\n throw new Error('Ink annotation requires a valid page number (>= 1)');\n }\n\n if (!args.sentence_ref || typeof args.sentence_ref !== 'string') {\n throw new Error('Ink annotation requires a sentence_ref for timing');\n }\n\n // Validate stroke format - each stroke must be an object\n args.strokes.forEach((stroke, index) => {\n if (typeof stroke !== 'object' || stroke === null || Array.isArray(stroke)) {\n throw new Error(`Stroke at index ${index} must be an object with {color, size, points} properties`);\n }\n\n // Validate points array\n if (!stroke.points || !Array.isArray(stroke.points) || stroke.points.length < 2) {\n throw new Error(`Stroke at index ${index} must have at least 2 points`);\n }\n\n // Validate each point\n stroke.points.forEach((point, pointIndex) => {\n if (typeof point !== 'object' || point === null) {\n throw new Error(`Point at stroke[${index}][${pointIndex}] must be an object with {t, x, y} properties`);\n }\n\n const requiredProps = ['t', 'x', 'y'];\n for (const prop of requiredProps) {\n if (typeof point[prop] !== 'number') {\n throw new Error(`Point at stroke[${index}][${pointIndex}] is missing required property '${prop}' or it's not a number`);\n }\n }\n\n // Validate time offset (t >= 0)\n if (point.t < 0) {\n throw new Error(`Point time offset (t) at stroke[${index}][${pointIndex}] must be >= 0 (got ${point.t})`);\n }\n\n // Validate x and y coordinates (0-1)\n if (point.x < 0 || point.x > 1) {\n throw new Error(`Point x coordinate at stroke[${index}][${pointIndex}] must be between 0 and 1 (got ${point.x})`);\n }\n if (point.y < 0 || point.y > 1) {\n throw new Error(`Point y coordinate at stroke[${index}][${pointIndex}] must be between 0 and 1 (got ${point.y})`);\n }\n });\n\n // Validate size\n const size = stroke.size || 3;\n if (size < 1 || size > 10) {\n throw new Error(`Stroke size at index ${index} must be between 1 and 10 pixels (got ${size})`);\n }\n });\n\n // Create annotation object matching library format\n return {\n id: generateId('ink'),\n type: 'ink',\n page: args.page,\n strokes: args.strokes.map(stroke => ({\n color: stroke.color || '#1f2937', // Default dark gray\n size: stroke.size || 3, // Default 3px\n points: stroke.points // Array of {t, x, y} objects\n })),\n sentence_ref: args.sentence_ref,\n // Note: start/end will be added during timing sync phase\n };\n}\n"],"names":["createInk","args","stroke","index","point","pointIndex","requiredProps","prop","size","generateId"],"mappings":"iHAqCO,SAASA,EAAUC,EAAM,CAE9B,GAAI,CAACA,EAAK,SAAW,CAAC,MAAM,QAAQA,EAAK,OAAO,GAAKA,EAAK,QAAQ,SAAW,EAC3E,MAAM,IAAI,MAAM,6CAA6C,EAG/D,GAAI,CAACA,EAAK,MAAQ,OAAOA,EAAK,MAAS,UAAYA,EAAK,KAAO,EAC7D,MAAM,IAAI,MAAM,oDAAoD,EAGtE,GAAI,CAACA,EAAK,cAAgB,OAAOA,EAAK,cAAiB,SACrD,MAAM,IAAI,MAAM,mDAAmD,EAIrE,OAAAA,EAAK,QAAQ,QAAQ,CAACC,EAAQC,IAAU,CACtC,GAAI,OAAOD,GAAW,UAAYA,IAAW,MAAQ,MAAM,QAAQA,CAAM,EACvE,MAAM,IAAI,MAAM,mBAAmBC,CAAK,0DAA0D,EAIpG,GAAI,CAACD,EAAO,QAAU,CAAC,MAAM,QAAQA,EAAO,MAAM,GAAKA,EAAO,OAAO,OAAS,EAC5E,MAAM,IAAI,MAAM,mBAAmBC,CAAK,8BAA8B,EAIxED,EAAO,OAAO,QAAQ,CAACE,EAAOC,IAAe,CAC3C,GAAI,OAAOD,GAAU,UAAYA,IAAU,KACzC,MAAM,IAAI,MAAM,mBAAmBD,CAAK,KAAKE,CAAU,+CAA+C,EAGxG,MAAMC,EAAgB,CAAC,IAAK,IAAK,GAAG,EACpC,UAAWC,KAAQD,EACjB,GAAI,OAAOF,EAAMG,CAAI,GAAM,SACzB,MAAM,IAAI,MAAM,mBAAmBJ,CAAK,KAAKE,CAAU,mCAAmCE,CAAI,wBAAwB,EAK1H,GAAIH,EAAM,EAAI,EACZ,MAAM,IAAI,MAAM,mCAAmCD,CAAK,KAAKE,CAAU,uBAAuBD,EAAM,CAAC,GAAG,EAI1G,GAAIA,EAAM,EAAI,GAAKA,EAAM,EAAI,EAC3B,MAAM,IAAI,MAAM,gCAAgCD,CAAK,KAAKE,CAAU,kCAAkCD,EAAM,CAAC,GAAG,EAElH,GAAIA,EAAM,EAAI,GAAKA,EAAM,EAAI,EAC3B,MAAM,IAAI,MAAM,gCAAgCD,CAAK,KAAKE,CAAU,kCAAkCD,EAAM,CAAC,GAAG,CAEpH,CAAC,EAGD,MAAMI,EAAON,EAAO,MAAQ,EAC5B,GAAIM,EAAO,GAAKA,EAAO,GACrB,MAAM,IAAI,MAAM,wBAAwBL,CAAK,yCAAyCK,CAAI,GAAG,CAEjG,CAAC,EAGM,CACL,GAAIC,EAAAA,WAAW,KAAK,EACpB,KAAM,MACN,KAAMR,EAAK,KACX,QAASA,EAAK,QAAQ,IAAIC,IAAW,CACnC,MAAOA,EAAO,OAAS,UACvB,KAAMA,EAAO,MAAQ,EACrB,OAAQA,EAAO,MACrB,EAAM,EACF,aAAcD,EAAK,YAEvB,CACA"}
|
package/dist/index20.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { generateId as f } from "./index22.js";
|
|
2
|
+
function c(e) {
|
|
3
|
+
if (!e.strokes || !Array.isArray(e.strokes) || e.strokes.length === 0)
|
|
4
|
+
throw new Error("Ink annotation requires at least one stroke");
|
|
5
|
+
if (!e.page || typeof e.page != "number" || e.page < 1)
|
|
6
|
+
throw new Error("Ink annotation requires a valid page number (>= 1)");
|
|
7
|
+
if (!e.sentence_ref || typeof e.sentence_ref != "string")
|
|
8
|
+
throw new Error("Ink annotation requires a sentence_ref for timing");
|
|
9
|
+
return e.strokes.forEach((r, o) => {
|
|
10
|
+
if (typeof r != "object" || r === null || Array.isArray(r))
|
|
11
|
+
throw new Error(`Stroke at index ${o} must be an object with {color, size, points} properties`);
|
|
12
|
+
if (!r.points || !Array.isArray(r.points) || r.points.length < 2)
|
|
13
|
+
throw new Error(`Stroke at index ${o} must have at least 2 points`);
|
|
14
|
+
r.points.forEach((t, n) => {
|
|
15
|
+
if (typeof t != "object" || t === null)
|
|
16
|
+
throw new Error(`Point at stroke[${o}][${n}] must be an object with {t, x, y} properties`);
|
|
17
|
+
const a = ["t", "x", "y"];
|
|
18
|
+
for (const i of a)
|
|
19
|
+
if (typeof t[i] != "number")
|
|
20
|
+
throw new Error(`Point at stroke[${o}][${n}] is missing required property '${i}' or it's not a number`);
|
|
21
|
+
if (t.t < 0)
|
|
22
|
+
throw new Error(`Point time offset (t) at stroke[${o}][${n}] must be >= 0 (got ${t.t})`);
|
|
23
|
+
if (t.x < 0 || t.x > 1)
|
|
24
|
+
throw new Error(`Point x coordinate at stroke[${o}][${n}] must be between 0 and 1 (got ${t.x})`);
|
|
25
|
+
if (t.y < 0 || t.y > 1)
|
|
26
|
+
throw new Error(`Point y coordinate at stroke[${o}][${n}] must be between 0 and 1 (got ${t.y})`);
|
|
27
|
+
});
|
|
28
|
+
const s = r.size || 3;
|
|
29
|
+
if (s < 1 || s > 10)
|
|
30
|
+
throw new Error(`Stroke size at index ${o} must be between 1 and 10 pixels (got ${s})`);
|
|
31
|
+
}), {
|
|
32
|
+
id: f("ink"),
|
|
33
|
+
type: "ink",
|
|
34
|
+
page: e.page,
|
|
35
|
+
strokes: e.strokes.map((r) => ({
|
|
36
|
+
color: r.color || "#1f2937",
|
|
37
|
+
// Default dark gray
|
|
38
|
+
size: r.size || 3,
|
|
39
|
+
// Default 3px
|
|
40
|
+
points: r.points
|
|
41
|
+
// Array of {t, x, y} objects
|
|
42
|
+
})),
|
|
43
|
+
sentence_ref: e.sentence_ref
|
|
44
|
+
// Note: start/end will be added during timing sync phase
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
c as createInk
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=index20.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index20.js","sources":["../src/ai-tools/creators/createInk.js"],"sourcesContent":["/**\n * Ink Annotation Creator\n *\n * Converts AI-generated tool call arguments into valid ink/drawing annotation objects\n * compatible with web-annotation-renderer library format.\n *\n * @module ai-tools/creators/createInk\n */\n\nimport { generateId } from '../../utils/idGenerator.js';\n\n/**\n * Create an ink (drawing) annotation from tool call arguments\n *\n * @param {Object} args - Tool call arguments from AI\n * @param {Array<Object>} args.strokes - Array of stroke objects with color, size, and points\n * @param {number} args.page - Page number (1-indexed)\n * @param {string} args.sentence_ref - Sentence reference for timing (e.g., 'S1')\n * @returns {Object} Valid ink annotation object\n * @example\n * ```javascript\n * const drawing = createInk({\n * strokes: [\n * {\n * color: '#FF0000',\n * size: 2,\n * points: [\n * {t: 0, x: 0.1, y: 0.1},\n * {t: 0.5, x: 0.2, y: 0.2}\n * ]\n * }\n * ],\n * page: 1,\n * sentence_ref: 'S4'\n * });\n * ```\n */\nexport function createInk(args) {\n // Validate required fields\n if (!args.strokes || !Array.isArray(args.strokes) || args.strokes.length === 0) {\n throw new Error('Ink annotation requires at least one stroke');\n }\n\n if (!args.page || typeof args.page !== 'number' || args.page < 1) {\n throw new Error('Ink annotation requires a valid page number (>= 1)');\n }\n\n if (!args.sentence_ref || typeof args.sentence_ref !== 'string') {\n throw new Error('Ink annotation requires a sentence_ref for timing');\n }\n\n // Validate stroke format - each stroke must be an object\n args.strokes.forEach((stroke, index) => {\n if (typeof stroke !== 'object' || stroke === null || Array.isArray(stroke)) {\n throw new Error(`Stroke at index ${index} must be an object with {color, size, points} properties`);\n }\n\n // Validate points array\n if (!stroke.points || !Array.isArray(stroke.points) || stroke.points.length < 2) {\n throw new Error(`Stroke at index ${index} must have at least 2 points`);\n }\n\n // Validate each point\n stroke.points.forEach((point, pointIndex) => {\n if (typeof point !== 'object' || point === null) {\n throw new Error(`Point at stroke[${index}][${pointIndex}] must be an object with {t, x, y} properties`);\n }\n\n const requiredProps = ['t', 'x', 'y'];\n for (const prop of requiredProps) {\n if (typeof point[prop] !== 'number') {\n throw new Error(`Point at stroke[${index}][${pointIndex}] is missing required property '${prop}' or it's not a number`);\n }\n }\n\n // Validate time offset (t >= 0)\n if (point.t < 0) {\n throw new Error(`Point time offset (t) at stroke[${index}][${pointIndex}] must be >= 0 (got ${point.t})`);\n }\n\n // Validate x and y coordinates (0-1)\n if (point.x < 0 || point.x > 1) {\n throw new Error(`Point x coordinate at stroke[${index}][${pointIndex}] must be between 0 and 1 (got ${point.x})`);\n }\n if (point.y < 0 || point.y > 1) {\n throw new Error(`Point y coordinate at stroke[${index}][${pointIndex}] must be between 0 and 1 (got ${point.y})`);\n }\n });\n\n // Validate size\n const size = stroke.size || 3;\n if (size < 1 || size > 10) {\n throw new Error(`Stroke size at index ${index} must be between 1 and 10 pixels (got ${size})`);\n }\n });\n\n // Create annotation object matching library format\n return {\n id: generateId('ink'),\n type: 'ink',\n page: args.page,\n strokes: args.strokes.map(stroke => ({\n color: stroke.color || '#1f2937', // Default dark gray\n size: stroke.size || 3, // Default 3px\n points: stroke.points // Array of {t, x, y} objects\n })),\n sentence_ref: args.sentence_ref,\n // Note: start/end will be added during timing sync phase\n };\n}\n"],"names":["createInk","args","stroke","index","point","pointIndex","requiredProps","prop","size","generateId"],"mappings":";AAqCO,SAASA,EAAUC,GAAM;AAE9B,MAAI,CAACA,EAAK,WAAW,CAAC,MAAM,QAAQA,EAAK,OAAO,KAAKA,EAAK,QAAQ,WAAW;AAC3E,UAAM,IAAI,MAAM,6CAA6C;AAG/D,MAAI,CAACA,EAAK,QAAQ,OAAOA,EAAK,QAAS,YAAYA,EAAK,OAAO;AAC7D,UAAM,IAAI,MAAM,oDAAoD;AAGtE,MAAI,CAACA,EAAK,gBAAgB,OAAOA,EAAK,gBAAiB;AACrD,UAAM,IAAI,MAAM,mDAAmD;AAIrE,SAAAA,EAAK,QAAQ,QAAQ,CAACC,GAAQC,MAAU;AACtC,QAAI,OAAOD,KAAW,YAAYA,MAAW,QAAQ,MAAM,QAAQA,CAAM;AACvE,YAAM,IAAI,MAAM,mBAAmBC,CAAK,0DAA0D;AAIpG,QAAI,CAACD,EAAO,UAAU,CAAC,MAAM,QAAQA,EAAO,MAAM,KAAKA,EAAO,OAAO,SAAS;AAC5E,YAAM,IAAI,MAAM,mBAAmBC,CAAK,8BAA8B;AAIxE,IAAAD,EAAO,OAAO,QAAQ,CAACE,GAAOC,MAAe;AAC3C,UAAI,OAAOD,KAAU,YAAYA,MAAU;AACzC,cAAM,IAAI,MAAM,mBAAmBD,CAAK,KAAKE,CAAU,+CAA+C;AAGxG,YAAMC,IAAgB,CAAC,KAAK,KAAK,GAAG;AACpC,iBAAWC,KAAQD;AACjB,YAAI,OAAOF,EAAMG,CAAI,KAAM;AACzB,gBAAM,IAAI,MAAM,mBAAmBJ,CAAK,KAAKE,CAAU,mCAAmCE,CAAI,wBAAwB;AAK1H,UAAIH,EAAM,IAAI;AACZ,cAAM,IAAI,MAAM,mCAAmCD,CAAK,KAAKE,CAAU,uBAAuBD,EAAM,CAAC,GAAG;AAI1G,UAAIA,EAAM,IAAI,KAAKA,EAAM,IAAI;AAC3B,cAAM,IAAI,MAAM,gCAAgCD,CAAK,KAAKE,CAAU,kCAAkCD,EAAM,CAAC,GAAG;AAElH,UAAIA,EAAM,IAAI,KAAKA,EAAM,IAAI;AAC3B,cAAM,IAAI,MAAM,gCAAgCD,CAAK,KAAKE,CAAU,kCAAkCD,EAAM,CAAC,GAAG;AAAA,IAEpH,CAAC;AAGD,UAAMI,IAAON,EAAO,QAAQ;AAC5B,QAAIM,IAAO,KAAKA,IAAO;AACrB,YAAM,IAAI,MAAM,wBAAwBL,CAAK,yCAAyCK,CAAI,GAAG;AAAA,EAEjG,CAAC,GAGM;AAAA,IACL,IAAIC,EAAW,KAAK;AAAA,IACpB,MAAM;AAAA,IACN,MAAMR,EAAK;AAAA,IACX,SAASA,EAAK,QAAQ,IAAI,CAAAC,OAAW;AAAA,MACnC,OAAOA,EAAO,SAAS;AAAA;AAAA,MACvB,MAAMA,EAAO,QAAQ;AAAA;AAAA,MACrB,QAAQA,EAAO;AAAA;AAAA,IACrB,EAAM;AAAA,IACF,cAAcD,EAAK;AAAA;AAAA,EAEvB;AACA;"}
|
package/dist/index21.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t={page:1,start:0,end:0},o={mode:"quads",quads:[{x:.1,y:.1,w:.8,h:.05}],style:{color:"rgba(255, 255, 0, 0.3)"}},e={content:"[No content]",x:.1,y:.1,w:.3,h:.1,style:{bg:"rgba(255, 255, 255, 0.9)",color:"#000000"}},s={strokes:[{color:"#1f2937",size:3,points:[{t:0,x:.1,y:.1},{t:1,x:.2,y:.2}]}]};exports.BASE_DEFAULTS=t;exports.HIGHLIGHT_DEFAULTS=o;exports.INK_DEFAULTS=s;exports.TEXT_DEFAULTS=e;
|
|
2
|
+
//# sourceMappingURL=index21.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index21.cjs","sources":["../src/types/defaults.js"],"sourcesContent":["/**\n * Default Values for Annotation Normalization\n *\n * This module defines default values used when annotation fields are missing\n * or invalid. These defaults ensure annotations render visibly and safely.\n *\n * @module types/defaults\n */\n\n/**\n * Default values for base annotation fields (common to all types)\n *\n * @constant {Object}\n * @property {number} page - Default page number (first page)\n * @property {number} start - Default start time (display immediately)\n * @property {number} end - Default end time (static display, no animation)\n */\nexport const BASE_DEFAULTS = {\n page: 1,\n start: 0,\n end: 0\n};\n\n/**\n * Default values for highlight annotations\n *\n * Creates a visible yellow highlight near the top of the page.\n *\n * @constant {Object}\n * @property {string} mode - Highlight mode (only 'quads' supported)\n * @property {Array<Object>} quads - Default rectangular regions\n * @property {Object} style - Default styling\n */\nexport const HIGHLIGHT_DEFAULTS = {\n mode: 'quads',\n quads: [{ x: 0.1, y: 0.1, w: 0.8, h: 0.05 }],\n style: { color: 'rgba(255, 255, 0, 0.3)' }\n};\n\n/**\n * Default values for text annotations\n *\n * Creates a visible text box in the top-left with placeholder content.\n *\n * @constant {Object}\n * @property {string} content - Placeholder text\n * @property {number} x - Normalized x position (10% from left)\n * @property {number} y - Normalized y position (10% from top)\n * @property {number} w - Normalized width (30% of page width)\n * @property {number} h - Normalized height (10% of page height)\n * @property {Object} style - Default styling with white background and black text\n */\nexport const TEXT_DEFAULTS = {\n content: '[No content]',\n x: 0.1,\n y: 0.1,\n w: 0.3,\n h: 0.1,\n style: {\n bg: 'rgba(255, 255, 255, 0.9)',\n color: '#000000'\n }\n};\n\n/**\n * Default values for ink annotations\n *\n * Creates a visible diagonal line in dark gray.\n *\n * @constant {Object}\n * @property {Array<Object>} strokes - Default stroke with two points\n */\nexport const INK_DEFAULTS = {\n strokes: [{\n color: '#1f2937',\n size: 3,\n points: [\n { t: 0, x: 0.1, y: 0.1 },\n { t: 1, x: 0.2, y: 0.2 }\n ]\n }]\n};\n"],"names":["BASE_DEFAULTS","HIGHLIGHT_DEFAULTS","TEXT_DEFAULTS","INK_DEFAULTS"],"mappings":"gFAiBY,MAACA,EAAgB,CAC3B,KAAM,EACN,MAAO,EACP,IAAK,CACP,EAYaC,EAAqB,CAChC,KAAM,QACN,MAAO,CAAC,CAAE,EAAG,GAAK,EAAG,GAAK,EAAG,GAAK,EAAG,IAAM,EAC3C,MAAO,CAAE,MAAO,wBAAwB,CAC1C,EAeaC,EAAgB,CAC3B,QAAS,eACT,EAAG,GACH,EAAG,GACH,EAAG,GACH,EAAG,GACH,MAAO,CACL,GAAI,2BACJ,MAAO,SACX,CACA,EAUaC,EAAe,CAC1B,QAAS,CAAC,CACR,MAAO,UACP,KAAM,EACN,OAAQ,CACN,CAAE,EAAG,EAAG,EAAG,GAAK,EAAG,EAAG,EACtB,CAAE,EAAG,EAAG,EAAG,GAAK,EAAG,EAAG,CAC5B,CACA,CAAG,CACH"}
|
package/dist/index21.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const o = {
|
|
2
|
+
page: 1,
|
|
3
|
+
start: 0,
|
|
4
|
+
end: 0
|
|
5
|
+
}, t = {
|
|
6
|
+
mode: "quads",
|
|
7
|
+
quads: [{ x: 0.1, y: 0.1, w: 0.8, h: 0.05 }],
|
|
8
|
+
style: { color: "rgba(255, 255, 0, 0.3)" }
|
|
9
|
+
}, s = {
|
|
10
|
+
content: "[No content]",
|
|
11
|
+
x: 0.1,
|
|
12
|
+
y: 0.1,
|
|
13
|
+
w: 0.3,
|
|
14
|
+
h: 0.1,
|
|
15
|
+
style: {
|
|
16
|
+
bg: "rgba(255, 255, 255, 0.9)",
|
|
17
|
+
color: "#000000"
|
|
18
|
+
}
|
|
19
|
+
}, e = {
|
|
20
|
+
strokes: [{
|
|
21
|
+
color: "#1f2937",
|
|
22
|
+
size: 3,
|
|
23
|
+
points: [
|
|
24
|
+
{ t: 0, x: 0.1, y: 0.1 },
|
|
25
|
+
{ t: 1, x: 0.2, y: 0.2 }
|
|
26
|
+
]
|
|
27
|
+
}]
|
|
28
|
+
};
|
|
29
|
+
export {
|
|
30
|
+
o as BASE_DEFAULTS,
|
|
31
|
+
t as HIGHLIGHT_DEFAULTS,
|
|
32
|
+
e as INK_DEFAULTS,
|
|
33
|
+
s as TEXT_DEFAULTS
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=index21.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index21.js","sources":["../src/types/defaults.js"],"sourcesContent":["/**\n * Default Values for Annotation Normalization\n *\n * This module defines default values used when annotation fields are missing\n * or invalid. These defaults ensure annotations render visibly and safely.\n *\n * @module types/defaults\n */\n\n/**\n * Default values for base annotation fields (common to all types)\n *\n * @constant {Object}\n * @property {number} page - Default page number (first page)\n * @property {number} start - Default start time (display immediately)\n * @property {number} end - Default end time (static display, no animation)\n */\nexport const BASE_DEFAULTS = {\n page: 1,\n start: 0,\n end: 0\n};\n\n/**\n * Default values for highlight annotations\n *\n * Creates a visible yellow highlight near the top of the page.\n *\n * @constant {Object}\n * @property {string} mode - Highlight mode (only 'quads' supported)\n * @property {Array<Object>} quads - Default rectangular regions\n * @property {Object} style - Default styling\n */\nexport const HIGHLIGHT_DEFAULTS = {\n mode: 'quads',\n quads: [{ x: 0.1, y: 0.1, w: 0.8, h: 0.05 }],\n style: { color: 'rgba(255, 255, 0, 0.3)' }\n};\n\n/**\n * Default values for text annotations\n *\n * Creates a visible text box in the top-left with placeholder content.\n *\n * @constant {Object}\n * @property {string} content - Placeholder text\n * @property {number} x - Normalized x position (10% from left)\n * @property {number} y - Normalized y position (10% from top)\n * @property {number} w - Normalized width (30% of page width)\n * @property {number} h - Normalized height (10% of page height)\n * @property {Object} style - Default styling with white background and black text\n */\nexport const TEXT_DEFAULTS = {\n content: '[No content]',\n x: 0.1,\n y: 0.1,\n w: 0.3,\n h: 0.1,\n style: {\n bg: 'rgba(255, 255, 255, 0.9)',\n color: '#000000'\n }\n};\n\n/**\n * Default values for ink annotations\n *\n * Creates a visible diagonal line in dark gray.\n *\n * @constant {Object}\n * @property {Array<Object>} strokes - Default stroke with two points\n */\nexport const INK_DEFAULTS = {\n strokes: [{\n color: '#1f2937',\n size: 3,\n points: [\n { t: 0, x: 0.1, y: 0.1 },\n { t: 1, x: 0.2, y: 0.2 }\n ]\n }]\n};\n"],"names":["BASE_DEFAULTS","HIGHLIGHT_DEFAULTS","TEXT_DEFAULTS","INK_DEFAULTS"],"mappings":"AAiBY,MAACA,IAAgB;AAAA,EAC3B,MAAM;AAAA,EACN,OAAO;AAAA,EACP,KAAK;AACP,GAYaC,IAAqB;AAAA,EAChC,MAAM;AAAA,EACN,OAAO,CAAC,EAAE,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM;AAAA,EAC3C,OAAO,EAAE,OAAO,yBAAwB;AAC1C,GAeaC,IAAgB;AAAA,EAC3B,SAAS;AAAA,EACT,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,OAAO;AAAA,IACL,IAAI;AAAA,IACJ,OAAO;AAAA,EACX;AACA,GAUaC,IAAe;AAAA,EAC1B,SAAS,CAAC;AAAA,IACR,OAAO;AAAA,IACP,MAAM;AAAA,IACN,QAAQ;AAAA,MACN,EAAE,GAAG,GAAG,GAAG,KAAK,GAAG,IAAG;AAAA,MACtB,EAAE,GAAG,GAAG,GAAG,KAAK,GAAG,IAAG;AAAA,IAC5B;AAAA,EACA,CAAG;AACH;"}
|
package/dist/index22.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index22.cjs","sources":["../src/utils/idGenerator.js"],"sourcesContent":["/**\n * ID Generator Utility\n *\n * Generates unique IDs for annotations.\n *\n * @module utils/idGenerator\n */\n\n/**\n * Generate a unique ID for an annotation\n *\n * @param {string} [prefix='anno'] - ID prefix (e.g., 'highlight', 'text', 'ink')\n * @returns {string} Unique annotation ID\n * @example\n * ```javascript\n * const id = generateId('highlight');\n * // Returns: \"highlight-1234567890abc\"\n * ```\n */\nexport function generateId(prefix = 'anno') {\n const timestamp = Date.now().toString(36);\n const random = Math.random().toString(36).substring(2, 9);\n return `${prefix}-${timestamp}${random}`;\n}\n"],"names":["generateId","prefix","timestamp","random"],"mappings":"gFAmBO,SAASA,EAAWC,EAAS,OAAQ,CAC1C,MAAMC,EAAY,KAAK,IAAG,EAAG,SAAS,EAAE,EAClCC,EAAS,KAAK,SAAS,SAAS,EAAE,EAAE,UAAU,EAAG,CAAC,EACxD,MAAO,GAAGF,CAAM,IAAIC,CAAS,GAAGC,CAAM,EACxC"}
|
package/dist/index22.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index22.js","sources":["../src/utils/idGenerator.js"],"sourcesContent":["/**\n * ID Generator Utility\n *\n * Generates unique IDs for annotations.\n *\n * @module utils/idGenerator\n */\n\n/**\n * Generate a unique ID for an annotation\n *\n * @param {string} [prefix='anno'] - ID prefix (e.g., 'highlight', 'text', 'ink')\n * @returns {string} Unique annotation ID\n * @example\n * ```javascript\n * const id = generateId('highlight');\n * // Returns: \"highlight-1234567890abc\"\n * ```\n */\nexport function generateId(prefix = 'anno') {\n const timestamp = Date.now().toString(36);\n const random = Math.random().toString(36).substring(2, 9);\n return `${prefix}-${timestamp}${random}`;\n}\n"],"names":["generateId","prefix","timestamp","random"],"mappings":"AAmBO,SAASA,EAAWC,IAAS,QAAQ;AAC1C,QAAMC,IAAY,KAAK,IAAG,EAAG,SAAS,EAAE,GAClCC,IAAS,KAAK,SAAS,SAAS,EAAE,EAAE,UAAU,GAAG,CAAC;AACxD,SAAO,GAAGF,CAAM,IAAIC,CAAS,GAAGC,CAAM;AACxC;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "web-annotation-renderer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Framework-agnostic PDF annotation renderer with timeline synchronization for educational content and interactive documents",
|
|
6
6
|
"keywords": [
|
|
@@ -34,10 +34,19 @@
|
|
|
34
34
|
"import": "./dist/index.js",
|
|
35
35
|
"require": "./dist/index.cjs"
|
|
36
36
|
},
|
|
37
|
+
"./extract": {
|
|
38
|
+
"import": "./dist/index.js",
|
|
39
|
+
"require": "./dist/index.cjs"
|
|
40
|
+
},
|
|
41
|
+
"./ai-tools": {
|
|
42
|
+
"import": "./ai-tools.js",
|
|
43
|
+
"require": "./dist/index16.cjs"
|
|
44
|
+
},
|
|
37
45
|
"./package.json": "./package.json"
|
|
38
46
|
},
|
|
39
47
|
"files": [
|
|
40
48
|
"dist/",
|
|
49
|
+
"ai-tools.js",
|
|
41
50
|
"README.md",
|
|
42
51
|
"LICENSE",
|
|
43
52
|
"CHANGELOG.md"
|