web-annotation-renderer 0.6.4 → 0.7.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/CHANGELOG.md +129 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +62 -61
- package/dist/index.js.map +1 -1
- package/dist/index10.cjs +1 -1
- package/dist/index10.cjs.map +1 -1
- package/dist/index10.js +160 -13
- package/dist/index10.js.map +1 -1
- package/dist/index11.cjs +1 -1
- package/dist/index11.cjs.map +1 -1
- package/dist/index11.js +13 -50
- package/dist/index11.js.map +1 -1
- package/dist/index12.cjs +1 -1
- package/dist/index12.cjs.map +1 -1
- package/dist/index12.js +48 -155
- package/dist/index12.js.map +1 -1
- package/dist/index13.cjs +1 -1
- package/dist/index13.cjs.map +1 -1
- package/dist/index13.js +150 -34
- package/dist/index13.js.map +1 -1
- package/dist/index14.cjs +1 -1
- package/dist/index14.cjs.map +1 -1
- package/dist/index14.js +32 -65
- package/dist/index14.js.map +1 -1
- package/dist/index15.cjs +1 -1
- package/dist/index15.cjs.map +1 -1
- package/dist/index15.js +66 -33
- package/dist/index15.js.map +1 -1
- package/dist/index16.cjs +1 -1
- package/dist/index16.cjs.map +1 -1
- package/dist/index16.js +35 -77
- package/dist/index16.js.map +1 -1
- package/dist/index17.cjs +1 -1
- package/dist/index17.cjs.map +1 -1
- package/dist/index17.js +53 -28
- package/dist/index17.js.map +1 -1
- package/dist/index18.cjs +1 -1
- package/dist/index18.cjs.map +1 -1
- package/dist/index18.js +28 -22
- package/dist/index18.js.map +1 -1
- package/dist/index19.cjs +1 -1
- package/dist/index19.cjs.map +1 -1
- package/dist/index19.js +22 -117
- package/dist/index19.js.map +1 -1
- package/dist/index2.cjs +1 -1
- package/dist/index2.cjs.map +1 -1
- package/dist/index2.js +94 -98
- package/dist/index2.js.map +1 -1
- package/dist/index20.cjs +1 -1
- package/dist/index20.cjs.map +1 -1
- package/dist/index20.js +137 -100
- package/dist/index20.js.map +1 -1
- package/dist/index21.cjs +1 -1
- package/dist/index21.cjs.map +1 -1
- package/dist/index21.js +34 -76
- package/dist/index21.js.map +1 -1
- package/dist/index22.cjs +1 -1
- package/dist/index22.cjs.map +1 -1
- package/dist/index22.js +35 -139
- package/dist/index22.js.map +1 -1
- package/dist/index23.cjs +1 -1
- package/dist/index23.cjs.map +1 -1
- package/dist/index23.js +37 -37
- package/dist/index23.js.map +1 -1
- package/dist/index24.cjs +1 -1
- package/dist/index24.cjs.map +1 -1
- package/dist/index24.js +69 -37
- package/dist/index24.js.map +1 -1
- package/dist/index25.cjs +1 -1
- package/dist/index25.cjs.map +1 -1
- package/dist/index25.js +40 -38
- package/dist/index25.js.map +1 -1
- package/dist/index26.cjs +1 -1
- package/dist/index26.cjs.map +1 -1
- package/dist/index26.js +4 -39
- package/dist/index26.js.map +1 -1
- package/dist/index27.cjs +1 -1
- package/dist/index27.js +4 -4
- package/dist/index28.cjs +1 -1
- package/dist/index28.cjs.map +1 -1
- package/dist/index28.js +71 -5
- package/dist/index28.js.map +1 -1
- package/dist/index29.cjs +1 -1
- package/dist/index29.cjs.map +1 -1
- package/dist/index29.js +24 -69
- package/dist/index29.js.map +1 -1
- package/dist/index3.cjs +1 -1
- package/dist/index3.cjs.map +1 -1
- package/dist/index3.js +31 -31
- package/dist/index3.js.map +1 -1
- package/dist/index5.cjs +1 -1
- package/dist/index5.cjs.map +1 -1
- package/dist/index5.js +237 -190
- package/dist/index5.js.map +1 -1
- package/dist/index6.cjs +1 -1
- package/dist/index6.cjs.map +1 -1
- package/dist/index6.js +37 -19
- package/dist/index6.js.map +1 -1
- package/dist/index7.cjs +1 -1
- package/dist/index7.cjs.map +1 -1
- package/dist/index7.js +11 -17
- package/dist/index7.js.map +1 -1
- package/dist/index8.cjs +1 -1
- package/dist/index8.cjs.map +1 -1
- package/dist/index8.js +16 -125
- package/dist/index8.js.map +1 -1
- package/dist/index9.cjs +1 -1
- package/dist/index9.cjs.map +1 -1
- package/dist/index9.js +118 -201
- package/dist/index9.js.map +1 -1
- package/package.json +6 -3
package/dist/index22.js
CHANGED
|
@@ -1,144 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
}
|
|
1
|
+
import { generateId as h } from "./index30.js";
|
|
2
|
+
function p(e) {
|
|
3
|
+
if (!e.quads || !Array.isArray(e.quads) || e.quads.length === 0)
|
|
4
|
+
throw new Error("Highlight annotation requires at least one quad");
|
|
5
|
+
if (!e.page || typeof e.page != "number" || e.page < 1)
|
|
6
|
+
throw new Error("Highlight annotation requires a valid page number (>= 1)");
|
|
7
|
+
if (!e.sentence_ref || typeof e.sentence_ref != "string")
|
|
8
|
+
throw new Error("Highlight annotation requires a sentence_ref for timing");
|
|
9
|
+
e.quads.forEach((r, o) => {
|
|
10
|
+
if (typeof r != "object" || r === null || Array.isArray(r))
|
|
11
|
+
throw new Error(`Quad at index ${o} must be an object with {x, y, w, h} properties`);
|
|
12
|
+
const i = ["x", "y", "w", "h"];
|
|
13
|
+
for (const t of i) {
|
|
14
|
+
if (typeof r[t] != "number")
|
|
15
|
+
throw new Error(`Quad at index ${o} is missing required property '${t}' or it's not a number`);
|
|
16
|
+
if (r[t] < 0 || r[t] > 1)
|
|
17
|
+
throw new Error(`Quad property '${t}' at index ${o} must be between 0 and 1 (got ${r[t]})`);
|
|
63
18
|
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
}
|
|
127
|
-
}
|
|
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
|
-
);
|
|
19
|
+
});
|
|
20
|
+
const n = e.color || "rgba(255, 255, 0, 0.3)";
|
|
21
|
+
return {
|
|
22
|
+
id: h("highlight"),
|
|
23
|
+
type: "highlight",
|
|
24
|
+
mode: "quads",
|
|
25
|
+
// Required by HighlightLayer
|
|
26
|
+
page: e.page,
|
|
27
|
+
quads: e.quads,
|
|
28
|
+
// Array of {x, y, w, h} objects
|
|
29
|
+
style: {
|
|
30
|
+
color: n
|
|
31
|
+
// Color wrapped in style object
|
|
32
|
+
},
|
|
33
|
+
sentence_ref: e.sentence_ref
|
|
34
|
+
// Note: start/end will be added during timing sync phase
|
|
35
|
+
};
|
|
139
36
|
}
|
|
140
37
|
export {
|
|
141
|
-
|
|
142
|
-
o as getAnnotationTools
|
|
38
|
+
p as createHighlight
|
|
143
39
|
};
|
|
144
40
|
//# sourceMappingURL=index22.js.map
|
package/dist/index22.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index22.js","sources":["../src/ai-tools/
|
|
1
|
+
{"version":3,"file":"index22.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/index23.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index30.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||"transparent";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
2
|
//# sourceMappingURL=index23.cjs.map
|
package/dist/index23.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index23.cjs","sources":["../src/ai-tools/
|
|
1
|
+
{"version":3,"file":"index23.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='transparent'] - Background color (transparent by default, or 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: 'transparent', // or use rgba format like '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 (transparent background for better visibility)\n const textColor = args.textColor || '#1f2937';\n const bgColor = args.bgColor || 'transparent';\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,cAGhC,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/index23.js
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (
|
|
10
|
-
throw new Error("
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
1
|
+
import { generateId as o } from "./index30.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 || "transparent";
|
|
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
|
+
};
|
|
36
37
|
}
|
|
37
38
|
export {
|
|
38
|
-
|
|
39
|
-
h as handleToolCalls
|
|
39
|
+
i as createText
|
|
40
40
|
};
|
|
41
41
|
//# sourceMappingURL=index23.js.map
|
package/dist/index23.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index23.js","sources":["../src/ai-tools/
|
|
1
|
+
{"version":3,"file":"index23.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='transparent'] - Background color (transparent by default, or 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: 'transparent', // or use rgba format like '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 (transparent background for better visibility)\n const textColor = args.textColor || '#1f2937';\n const bgColor = args.bgColor || 'transparent';\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/index24.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=Object.freeze(["highlight","text","underline","arrow","circle","ink"]),o=500,e={highlight:{color:"rgba(255, 255, 0, 0.3)",widthScale:1,lineCap:"butt",roughness:1.5,bowing:1.4,curveFitting:.95,curveStepCount:9,maxRandomnessOffset:2.5,disableMultiStroke:!1},text:{color:"rgba(220, 20, 60, 1.0)",width:2,fontSize:16,lineCap:"round",roughness:.8},underline:{color:"rgba(0, 0, 255, 0.8)",width:2,lineCap:"round",roughness:1.4,bowing:1.5,curveFitting:.85,curveStepCount:9,maxRandomnessOffset:2,disableMultiStroke:!1},arrow:{color:"rgba(255, 0, 0, 0.8)",width:2,lineCap:"round",roughness:1.8,bowing:1.8,curveFitting:.9,curveStepCount:9,maxRandomnessOffset:2,disableMultiStroke:!1},circle:{color:"rgba(255, 165, 0, 0.8)",width:3,lineCap:"round",roughness:1.1,bowing:1.3,curveFitting:.8,curveStepCount:12,maxRandomnessOffset:2,disableMultiStroke:!1},ink:{color:"#DC143C",width:2,lineCap:"round"}};exports.ANNOTATION_TYPES=t;exports.DEFAULT_CONFIG=e;exports.REFERENCE_HEIGHT=o;exports.default=e;
|
|
2
2
|
//# sourceMappingURL=index24.cjs.map
|
package/dist/index24.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index24.cjs","sources":["../src/
|
|
1
|
+
{"version":3,"file":"index24.cjs","sources":["../src/config/defaults.js"],"sourcesContent":["/**\n * Default Configuration — Single Source of Truth\n *\n * Defines `DEFAULT_CONFIG` (per-type rendering + RoughJS options) and\n * shared rendering constants. Imported by `StrokeRenderer`, converter\n * helpers, and `config/presets.js` so that defaults live in one place.\n *\n * Per-type fields:\n * - color, width, lineCap — canvas stroke style\n * - widthScale (highlight) — relative thickness multiplier; actual width is\n * derived from the annotation's quad height at render time\n * - fontSize (text) — base font size in viewport pixels\n * - roughness, bowing, curveFitting, curveStepCount, maxRandomnessOffset,\n * disableMultiStroke — RoughJS path generation options\n *\n * @module config/defaults\n */\n\n/**\n * Supported annotation types.\n *\n * Order matches the public converter export order. Used by `StrokeRenderer`\n * to seed per-type config and by `setConfig` to distinguish global keys\n * from type-specific keys.\n *\n * @type {readonly string[]}\n */\nexport const ANNOTATION_TYPES = Object.freeze([\n 'highlight',\n 'text',\n 'underline',\n 'arrow',\n 'circle',\n 'ink',\n]);\n\n/**\n * Reference viewport height for stroke-width scaling.\n *\n * Stroke widths are authored relative to a 500px-tall viewport. At render\n * time the renderer multiplies `width` by `viewport.height / REFERENCE_HEIGHT`\n * so that strokes look the same thickness across viewport sizes.\n *\n * @type {number}\n */\nexport const REFERENCE_HEIGHT = 500;\n\n/**\n * Default per-type rendering configuration.\n *\n * Consumers should treat this object as immutable — clone before mutation.\n *\n * @type {Object<string, Object>}\n */\nexport const DEFAULT_CONFIG = {\n highlight: {\n color: 'rgba(255, 255, 0, 0.3)',\n widthScale: 1.0,\n lineCap: 'butt',\n roughness: 1.5,\n bowing: 1.4,\n curveFitting: 0.95,\n curveStepCount: 9,\n maxRandomnessOffset: 2.5,\n disableMultiStroke: false,\n },\n text: {\n color: 'rgba(220, 20, 60, 1.0)',\n width: 2,\n fontSize: 16,\n lineCap: 'round',\n roughness: 0.8,\n },\n underline: {\n color: 'rgba(0, 0, 255, 0.8)',\n width: 2,\n lineCap: 'round',\n roughness: 1.4,\n bowing: 1.5,\n curveFitting: 0.85,\n curveStepCount: 9,\n maxRandomnessOffset: 2,\n disableMultiStroke: false,\n },\n arrow: {\n color: 'rgba(255, 0, 0, 0.8)',\n width: 2,\n lineCap: 'round',\n roughness: 1.8,\n bowing: 1.8,\n curveFitting: 0.9,\n curveStepCount: 9,\n maxRandomnessOffset: 2,\n disableMultiStroke: false,\n },\n circle: {\n color: 'rgba(255, 165, 0, 0.8)',\n width: 3,\n lineCap: 'round',\n roughness: 1.1,\n bowing: 1.3,\n curveFitting: 0.8,\n curveStepCount: 12,\n maxRandomnessOffset: 2,\n disableMultiStroke: false,\n },\n ink: {\n color: '#DC143C',\n width: 2,\n lineCap: 'round',\n },\n};\n\nexport default DEFAULT_CONFIG;\n"],"names":["ANNOTATION_TYPES","REFERENCE_HEIGHT","DEFAULT_CONFIG"],"mappings":"4GA2BY,MAACA,EAAmB,OAAO,OAAO,CAC5C,YACA,OACA,YACA,QACA,SACA,KACF,CAAC,EAWYC,EAAmB,IASnBC,EAAiB,CAC5B,UAAW,CACT,MAAO,yBACP,WAAY,EACZ,QAAS,OACT,UAAW,IACX,OAAQ,IACR,aAAc,IACd,eAAgB,EAChB,oBAAqB,IACrB,mBAAoB,EACxB,EACE,KAAM,CACJ,MAAO,yBACP,MAAO,EACP,SAAU,GACV,QAAS,QACT,UAAW,EACf,EACE,UAAW,CACT,MAAO,uBACP,MAAO,EACP,QAAS,QACT,UAAW,IACX,OAAQ,IACR,aAAc,IACd,eAAgB,EAChB,oBAAqB,EACrB,mBAAoB,EACxB,EACE,MAAO,CACL,MAAO,uBACP,MAAO,EACP,QAAS,QACT,UAAW,IACX,OAAQ,IACR,aAAc,GACd,eAAgB,EAChB,oBAAqB,EACrB,mBAAoB,EACxB,EACE,OAAQ,CACN,MAAO,yBACP,MAAO,EACP,QAAS,QACT,UAAW,IACX,OAAQ,IACR,aAAc,GACd,eAAgB,GAChB,oBAAqB,EACrB,mBAAoB,EACxB,EACE,IAAK,CACH,MAAO,UACP,MAAO,EACP,QAAS,OACb,CACA"}
|
package/dist/index24.js
CHANGED
|
@@ -1,40 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
1
|
+
const e = Object.freeze([
|
|
2
|
+
"highlight",
|
|
3
|
+
"text",
|
|
4
|
+
"underline",
|
|
5
|
+
"arrow",
|
|
6
|
+
"circle",
|
|
7
|
+
"ink"
|
|
8
|
+
]), t = 500, n = {
|
|
9
|
+
highlight: {
|
|
10
|
+
color: "rgba(255, 255, 0, 0.3)",
|
|
11
|
+
widthScale: 1,
|
|
12
|
+
lineCap: "butt",
|
|
13
|
+
roughness: 1.5,
|
|
14
|
+
bowing: 1.4,
|
|
15
|
+
curveFitting: 0.95,
|
|
16
|
+
curveStepCount: 9,
|
|
17
|
+
maxRandomnessOffset: 2.5,
|
|
18
|
+
disableMultiStroke: !1
|
|
19
|
+
},
|
|
20
|
+
text: {
|
|
21
|
+
color: "rgba(220, 20, 60, 1.0)",
|
|
22
|
+
width: 2,
|
|
23
|
+
fontSize: 16,
|
|
24
|
+
lineCap: "round",
|
|
25
|
+
roughness: 0.8
|
|
26
|
+
},
|
|
27
|
+
underline: {
|
|
28
|
+
color: "rgba(0, 0, 255, 0.8)",
|
|
29
|
+
width: 2,
|
|
30
|
+
lineCap: "round",
|
|
31
|
+
roughness: 1.4,
|
|
32
|
+
bowing: 1.5,
|
|
33
|
+
curveFitting: 0.85,
|
|
34
|
+
curveStepCount: 9,
|
|
35
|
+
maxRandomnessOffset: 2,
|
|
36
|
+
disableMultiStroke: !1
|
|
37
|
+
},
|
|
38
|
+
arrow: {
|
|
39
|
+
color: "rgba(255, 0, 0, 0.8)",
|
|
40
|
+
width: 2,
|
|
41
|
+
lineCap: "round",
|
|
42
|
+
roughness: 1.8,
|
|
43
|
+
bowing: 1.8,
|
|
44
|
+
curveFitting: 0.9,
|
|
45
|
+
curveStepCount: 9,
|
|
46
|
+
maxRandomnessOffset: 2,
|
|
47
|
+
disableMultiStroke: !1
|
|
48
|
+
},
|
|
49
|
+
circle: {
|
|
50
|
+
color: "rgba(255, 165, 0, 0.8)",
|
|
51
|
+
width: 3,
|
|
52
|
+
lineCap: "round",
|
|
53
|
+
roughness: 1.1,
|
|
54
|
+
bowing: 1.3,
|
|
55
|
+
curveFitting: 0.8,
|
|
56
|
+
curveStepCount: 12,
|
|
57
|
+
maxRandomnessOffset: 2,
|
|
58
|
+
disableMultiStroke: !1
|
|
59
|
+
},
|
|
60
|
+
ink: {
|
|
61
|
+
color: "#DC143C",
|
|
62
|
+
width: 2,
|
|
63
|
+
lineCap: "round"
|
|
64
|
+
}
|
|
65
|
+
};
|
|
37
66
|
export {
|
|
38
|
-
|
|
67
|
+
e as ANNOTATION_TYPES,
|
|
68
|
+
n as DEFAULT_CONFIG,
|
|
69
|
+
t as REFERENCE_HEIGHT,
|
|
70
|
+
n as default
|
|
39
71
|
};
|
|
40
72
|
//# sourceMappingURL=index24.js.map
|