web-annotation-renderer 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +49 -42
  4. package/dist/index.js.map +1 -1
  5. package/dist/index10.cjs +1 -1
  6. package/dist/index10.cjs.map +1 -1
  7. package/dist/index10.js +172 -17
  8. package/dist/index10.js.map +1 -1
  9. package/dist/index11.cjs +1 -1
  10. package/dist/index11.cjs.map +1 -1
  11. package/dist/index11.js +13 -20
  12. package/dist/index11.js.map +1 -1
  13. package/dist/index12.cjs +1 -1
  14. package/dist/index12.cjs.map +1 -1
  15. package/dist/index12.js +148 -123
  16. package/dist/index12.js.map +1 -1
  17. package/dist/index13.cjs +1 -1
  18. package/dist/index13.cjs.map +1 -1
  19. package/dist/index13.js +29 -198
  20. package/dist/index13.js.map +1 -1
  21. package/dist/index14.cjs +1 -1
  22. package/dist/index14.cjs.map +1 -1
  23. package/dist/index14.js +56 -15
  24. package/dist/index14.js.map +1 -1
  25. package/dist/index15.cjs +1 -1
  26. package/dist/index15.cjs.map +1 -1
  27. package/dist/index15.js +115 -120
  28. package/dist/index15.js.map +1 -1
  29. package/dist/index16.cjs +1 -1
  30. package/dist/index16.cjs.map +1 -1
  31. package/dist/index16.js +100 -212
  32. package/dist/index16.js.map +1 -1
  33. package/dist/index17.cjs +1 -1
  34. package/dist/index17.cjs.map +1 -1
  35. package/dist/index17.js +55 -37
  36. package/dist/index17.js.map +1 -1
  37. package/dist/index18.cjs +1 -1
  38. package/dist/index18.cjs.map +1 -1
  39. package/dist/index18.js +139 -35
  40. package/dist/index18.js.map +1 -1
  41. package/dist/index19.cjs +1 -1
  42. package/dist/index19.cjs.map +1 -1
  43. package/dist/index19.js +37 -37
  44. package/dist/index19.js.map +1 -1
  45. package/dist/index2.cjs +1 -1
  46. package/dist/index2.cjs.map +1 -1
  47. package/dist/index2.js +65 -73
  48. package/dist/index2.js.map +1 -1
  49. package/dist/index20.cjs +1 -1
  50. package/dist/index20.cjs.map +1 -1
  51. package/dist/index20.js +29 -39
  52. package/dist/index20.js.map +1 -1
  53. package/dist/index21.cjs +1 -1
  54. package/dist/index21.cjs.map +1 -1
  55. package/dist/index21.js +38 -32
  56. package/dist/index21.js.map +1 -1
  57. package/dist/index22.cjs +1 -1
  58. package/dist/index22.cjs.map +1 -1
  59. package/dist/index22.js +22 -5
  60. package/dist/index22.js.map +1 -1
  61. package/dist/index23.cjs +2 -0
  62. package/dist/index23.cjs.map +1 -0
  63. package/dist/index23.js +8 -0
  64. package/dist/index23.js.map +1 -0
  65. package/dist/index24.cjs +2 -0
  66. package/dist/index24.cjs.map +1 -0
  67. package/dist/index24.js +8 -0
  68. package/dist/index24.js.map +1 -0
  69. package/dist/index3.cjs +1 -1
  70. package/dist/index3.cjs.map +1 -1
  71. package/dist/index3.js +1 -1
  72. package/dist/index4.cjs +1 -1
  73. package/dist/index4.cjs.map +1 -1
  74. package/dist/index4.js +72 -71
  75. package/dist/index4.js.map +1 -1
  76. package/dist/index5.cjs +1 -1
  77. package/dist/index5.cjs.map +1 -1
  78. package/dist/index5.js +153 -65
  79. package/dist/index5.js.map +1 -1
  80. package/dist/index6.cjs +1 -1
  81. package/dist/index6.cjs.map +1 -1
  82. package/dist/index6.js +60 -114
  83. package/dist/index6.js.map +1 -1
  84. package/dist/index7.cjs +1 -1
  85. package/dist/index7.cjs.map +1 -1
  86. package/dist/index7.js +19 -91
  87. package/dist/index7.js.map +1 -1
  88. package/dist/index8.cjs +1 -1
  89. package/dist/index8.cjs.map +1 -1
  90. package/dist/index8.js +19 -105
  91. package/dist/index8.js.map +1 -1
  92. package/dist/index9.cjs +1 -1
  93. package/dist/index9.cjs.map +1 -1
  94. package/dist/index9.js +123 -98
  95. package/dist/index9.js.map +1 -1
  96. package/package.json +4 -3
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./index2.cjs"),a=require("./index3.cjs"),o=require("./index4.cjs"),i=require("./index5.cjs"),l=require("./index6.cjs"),c=require("./index7.cjs"),s=require("./index8.cjs"),u=require("./index9.cjs"),d=require("./index10.cjs"),g=require("./index11.cjs"),e=require("./index12.cjs"),q=require("./index13.cjs"),y=require("./index14.cjs"),T=require("./index15.cjs"),r=require("./index16.cjs"),t=require("./index17.cjs"),h=require("./index18.cjs"),A=require("./index19.cjs"),x=require("./index20.cjs"),L="0.3.0",f="web-annotation-renderer";exports.AnnotationRenderer=n.AnnotationRenderer;exports.PDFRenderer=a.PDFRenderer;exports.LayerManager=o.LayerManager;exports.TimelineSync=i.TimelineSync;exports.BaseLayer=l.default;exports.HighlightLayer=c.default;exports.TextLayer=s.default;exports.DrawingLayer=u.default;exports.coordinateUtils=d;exports.viewportUtils=g;exports.extractAllBlocks=e.extractAllBlocks;exports.extractMultiplePages=e.extractMultiplePages;exports.extractPDFBlocks=e.extractAllBlocks;exports.normalizeAnnotationArray=q.normalizeAnnotationArray;exports.TypeValidators=y;exports.AnnotPdf=T.default;exports.annotationTools=r.annotationTools;exports.getAnnotationTools=r.getAnnotationTools;exports.handleToolCall=t.handleToolCall;exports.handleToolCalls=t.handleToolCalls;exports.createHighlight=h.createHighlight;exports.createText=A.createText;exports.createInk=x.createInk;exports.LIB_NAME=f;exports.VERSION=L;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index2.cjs"),i=require("./index3.cjs"),l=require("./index4.cjs"),s=require("./index5.cjs"),e=require("./index6.cjs"),c=require("./index7.cjs"),d=require("./index8.cjs"),t=require("./index9.cjs"),u=require("./index10.cjs"),g=require("./index11.cjs"),p=require("./index12.cjs"),h=require("./index13.cjs"),q=require("./index14.cjs"),T=require("./index15.cjs"),P=require("./index16.cjs"),r=require("./index17.cjs"),o=require("./index18.cjs"),n=require("./index19.cjs"),A=require("./index20.cjs"),S=require("./index21.cjs"),R="1.0.0",x="web-annotation-renderer";exports.AnnotationRenderer=a.AnnotationRenderer;exports.PDFRenderer=i.PDFRenderer;exports.TimelineSync=l.TimelineSync;exports.StrokeRenderer=s.StrokeRenderer;exports.applyJitter=e.applyJitter;exports.applyPressure=e.applyPressure;exports.applyWobble=e.applyWobble;exports.deepMerge=e.deepMerge;exports.seededRandom=e.seededRandom;exports.coordinateUtils=c;exports.viewportUtils=d;exports.extractAllBlocks=t.extractAllBlocks;exports.extractMultiplePages=t.extractMultiplePages;exports.extractPDFBlocks=t.extractAllBlocks;exports.normalizeAnnotationArray=u.normalizeAnnotationArray;exports.TypeValidators=g;exports.AnnotPdf=p.default;exports.highlightToStrokes=h.highlightToStrokes;exports.textToStrokes=q.textToStrokes;exports.GradualRenderer=T.default;exports.StrokeDrawer=P.default;exports.getPenPreset=r.getPreset;exports.getPenPresetNames=r.getPresetNames;exports.annotationTools=o.annotationTools;exports.getAnnotationTools=o.getAnnotationTools;exports.handleToolCall=n.handleToolCall;exports.handleToolCalls=n.handleToolCalls;exports.createHighlight=A.createHighlight;exports.createText=S.createText;exports.LIB_NAME=x;exports.VERSION=R;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/index.js"],"sourcesContent":["/**\n * @ai-annotator/renderer - Public API\n *\n * Single entry point for the Dynamic PDF Annotation Renderer library.\n * Exports all core subsystems, layers, utilities, and types.\n *\n * @module @ai-annotator/renderer\n */\n\n// ============================================================================\n// Core Rendering Engine\n// ============================================================================\n\n// Import statements\nimport { AnnotationRenderer } from './core/AnnotationRenderer.js';\nimport { PDFRenderer } from './core/PDFRenderer.js';\nimport { LayerManager } from './core/LayerManager.js';\nimport { TimelineSync } from './core/TimelineSync.js';\n\n// Export statements\nexport { AnnotationRenderer };\nexport { PDFRenderer };\nexport { LayerManager };\nexport { TimelineSync };\n\n// ============================================================================\n// Annotation Layers\n// ============================================================================\n\n// Framework-agnostic layer classes\n// BaseLayer: Abstract base class for creating custom layers\n// HighlightLayer, TextLayer, DrawingLayer: Built-in layer implementations\n\nimport BaseLayer from './layers/BaseLayer.js';\nimport HighlightLayer from './layers/HighlightLayer.js';\nimport TextLayer from './layers/TextLayer.js';\nimport DrawingLayer from './layers/DrawingLayer.js';\n\nexport { BaseLayer };\nexport { HighlightLayer };\nexport { TextLayer };\nexport { DrawingLayer };\n\n// ============================================================================\n// Utilities\n// ============================================================================\n\nimport * as coordinateUtils from './utils/coordinateUtils.js';\nimport * as viewportUtils from './utils/viewportUtils.js';\n\nexport { coordinateUtils };\nexport { viewportUtils };\n\n// Future: colorUtils, validators\n// import * as colorUtils from './utils/colorUtils.js';\n// export { colorUtils };\n\n// ============================================================================\n// PDF Extraction Utilities\n// ============================================================================\n\n/**\n * PDF data extraction utilities for text and image blocks\n * Uses PDF.js getOperatorList() for efficient metadata extraction without rendering\n */\nimport { extractAllBlocks, extractMultiplePages } from './utils/pdfExtractor.js';\n\nexport { extractAllBlocks };\nexport { extractMultiplePages };\n\n// Alias for backwards compatibility and API consistency\nexport { extractAllBlocks as extractPDFBlocks };\n\n// ============================================================================\n// Type Definitions & Validators\n// ============================================================================\n\n// Type definitions in src/types/annotations.js\n\n/**\n * Type Validators - Optional data normalization\n *\n * Import separately to use defensive normalization for annotation data.\n * These validators are standalone utilities that do not modify the core system.\n */\nexport { normalizeAnnotationArray } from './types/validators.js';\n\n// Namespace export for all validator utilities\nexport * as TypeValidators from './types/index.js';\n\n// ============================================================================\n// Framework Adapters\n// ============================================================================\n// Declarative framework-specific wrappers for AnnotationRenderer\n// These provide idiomatic APIs for React, Vue, and other frameworks\n\n/**\n * React adapter component for declarative PDF annotation rendering\n * @see {@link AnnotPdf}\n */\nexport { AnnotPdf } from './adapters/index.js';\n\n// Future framework adapters will be exported here:\n// export { VuePdfViewer } from './adapters/index.js';\n// export { SveltePdfViewer } from './adapters/index.js';\n\n// ============================================================================\n// AI Tools for Annotation Generation\n// ============================================================================\n\n/**\n * AI-powered annotation generation tools\n *\n * Provides OpenAI-compatible function calling schemas and handlers\n * for generating PDF annotations with AI models.\n *\n * @see {@link module:ai-tools}\n */\nexport {\n annotationTools,\n getAnnotationTools,\n handleToolCall,\n handleToolCalls,\n createHighlight,\n createText,\n createInk\n} from './ai-tools/index.js';\n\n// ============================================================================\n// Package Metadata\n// ============================================================================\n\n/**\n * Library version\n * @constant {string}\n */\nexport const VERSION = '0.3.0';\n\n/**\n * Library name\n * @constant {string}\n */\nexport const LIB_NAME = 'web-annotation-renderer';\n"],"names":["VERSION","LIB_NAME"],"mappings":"+kBAwIaA,EAAU,QAMVC,EAAW"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/index.js"],"sourcesContent":["/**\n * @ai-annotator/renderer - Public API\n *\n * Single entry point for the Dynamic PDF Annotation Renderer library.\n * Exports all core subsystems, utilities, and types.\n *\n * @module @ai-annotator/renderer\n */\n\n// ============================================================================\n// Core Rendering Engine\n// ============================================================================\n\nimport { AnnotationRenderer } from './core/AnnotationRenderer.js';\nimport { PDFRenderer } from './core/PDFRenderer.js';\nimport { TimelineSync } from './core/TimelineSync.js';\n\nexport { AnnotationRenderer };\nexport { PDFRenderer };\nexport { TimelineSync };\n\n// ============================================================================\n// Stroke Renderer - Unified Canvas-Based Annotation Rendering\n// ============================================================================\n\nimport { StrokeRenderer } from './renderer/StrokeRenderer.js';\n\nexport { StrokeRenderer };\n\n// ============================================================================\n// Converters - Annotation to Stroke Conversion\n// ============================================================================\n\nimport { highlightToStrokes, textToStrokes } from './converters/index.js';\n\nexport { highlightToStrokes };\nexport { textToStrokes };\n\n// ============================================================================\n// Pen Effects - Hand-Drawn Feel Utilities\n// ============================================================================\n\nimport {\n applyJitter,\n applyPressure,\n applyWobble,\n deepMerge,\n seededRandom\n} from './pen/effects.js';\n\nexport { applyJitter };\nexport { applyPressure };\nexport { applyWobble };\nexport { deepMerge };\nexport { seededRandom };\n\n// ============================================================================\n// Pen Module - Legacy Stroke Rendering (Retained for Compatibility)\n// ============================================================================\n\nimport { GradualRenderer, StrokeDrawer, getPreset, getPresetNames } from './pen/index.js';\n\nexport { GradualRenderer };\nexport { StrokeDrawer };\nexport { getPreset as getPenPreset };\nexport { getPresetNames as getPenPresetNames };\n\n// ============================================================================\n// Utilities\n// ============================================================================\n\nimport * as coordinateUtils from './utils/coordinateUtils.js';\nimport * as viewportUtils from './utils/viewportUtils.js';\n\nexport { coordinateUtils };\nexport { viewportUtils };\n\n// ============================================================================\n// PDF Extraction Utilities\n// ============================================================================\n\nimport { extractAllBlocks, extractMultiplePages } from './utils/pdfExtractor.js';\n\nexport { extractAllBlocks };\nexport { extractMultiplePages };\nexport { extractAllBlocks as extractPDFBlocks };\n\n// ============================================================================\n// Type Definitions & Validators\n// ============================================================================\n\nexport { normalizeAnnotationArray } from './types/validators.js';\nexport * as TypeValidators from './types/index.js';\n\n// ============================================================================\n// Framework Adapters\n// ============================================================================\n\nexport { AnnotPdf } from './adapters/index.js';\n\n// ============================================================================\n// AI Tools for Annotation Generation\n// ============================================================================\n\nexport {\n annotationTools,\n getAnnotationTools,\n handleToolCall,\n handleToolCalls,\n createHighlight,\n createText\n} from './ai-tools/index.js';\n\n// ============================================================================\n// Package Metadata\n// ============================================================================\n\nexport const VERSION = '1.0.0';\nexport const LIB_NAME = 'web-annotation-renderer';\n"],"names":["VERSION","LIB_NAME"],"mappings":"0mBAqHaA,EAAU,QACVC,EAAW"}
package/dist/index.js CHANGED
@@ -1,48 +1,55 @@
1
- import { AnnotationRenderer as x } from "./index2.js";
2
- import { PDFRenderer as f } from "./index3.js";
3
- import { LayerManager as i } from "./index4.js";
4
- import { TimelineSync as c } from "./index5.js";
5
- import { default as g } from "./index6.js";
6
- import { default as A } from "./index7.js";
7
- import { default as h } from "./index8.js";
8
- import { default as L } from "./index9.js";
9
- import * as o from "./index10.js";
10
- import * as r from "./index11.js";
11
- import { extractAllBlocks as k, extractMultiplePages as P, extractAllBlocks as w } from "./index12.js";
12
- import { normalizeAnnotationArray as I } from "./index13.js";
13
- import * as e from "./index14.js";
14
- import { default as R } from "./index15.js";
15
- import { annotationTools as E, getAnnotationTools as F } from "./index16.js";
16
- import { handleToolCall as N, handleToolCalls as S } from "./index17.js";
17
- import { createHighlight as V } from "./index18.js";
18
- import { createText as v } from "./index19.js";
19
- import { createInk as O } from "./index20.js";
20
- const t = "0.3.0", a = "web-annotation-renderer";
1
+ import { AnnotationRenderer as p } from "./index2.js";
2
+ import { PDFRenderer as m } from "./index3.js";
3
+ import { TimelineSync as f } from "./index4.js";
4
+ import { StrokeRenderer as d } from "./index5.js";
5
+ import { applyJitter as g, applyPressure as P, applyWobble as T, deepMerge as A, seededRandom as h } from "./index6.js";
6
+ import * as e from "./index7.js";
7
+ import * as r from "./index8.js";
8
+ import { extractAllBlocks as u, extractMultiplePages as y, extractAllBlocks as R } from "./index9.js";
9
+ import { normalizeAnnotationArray as B } from "./index10.js";
10
+ import * as o from "./index11.js";
11
+ import { default as b } from "./index12.js";
12
+ import { highlightToStrokes as D } from "./index13.js";
13
+ import { textToStrokes as C } from "./index14.js";
14
+ import { default as F } from "./index15.js";
15
+ import { default as U } from "./index16.js";
16
+ import { getPreset as v, getPresetNames as z } from "./index17.js";
17
+ import { annotationTools as H, getAnnotationTools as J } from "./index18.js";
18
+ import { handleToolCall as O, handleToolCalls as W } from "./index19.js";
19
+ import { createHighlight as j } from "./index20.js";
20
+ import { createText as K } from "./index21.js";
21
+ const t = "1.0.0", a = "web-annotation-renderer";
21
22
  export {
22
- R as AnnotPdf,
23
- x as AnnotationRenderer,
24
- g as BaseLayer,
25
- L as DrawingLayer,
26
- A as HighlightLayer,
23
+ b as AnnotPdf,
24
+ p as AnnotationRenderer,
25
+ F as GradualRenderer,
27
26
  a as LIB_NAME,
28
- i as LayerManager,
29
- f as PDFRenderer,
30
- h as TextLayer,
31
- c as TimelineSync,
32
- e as TypeValidators,
27
+ m as PDFRenderer,
28
+ U as StrokeDrawer,
29
+ d as StrokeRenderer,
30
+ f as TimelineSync,
31
+ o as TypeValidators,
33
32
  t as VERSION,
34
- E as annotationTools,
35
- o as coordinateUtils,
36
- V as createHighlight,
37
- O as createInk,
38
- v as createText,
39
- k as extractAllBlocks,
40
- P as extractMultiplePages,
41
- w as extractPDFBlocks,
42
- F as getAnnotationTools,
43
- N as handleToolCall,
44
- S as handleToolCalls,
45
- I as normalizeAnnotationArray,
33
+ H as annotationTools,
34
+ g as applyJitter,
35
+ P as applyPressure,
36
+ T as applyWobble,
37
+ e as coordinateUtils,
38
+ j as createHighlight,
39
+ K as createText,
40
+ A as deepMerge,
41
+ u as extractAllBlocks,
42
+ y as extractMultiplePages,
43
+ R as extractPDFBlocks,
44
+ J as getAnnotationTools,
45
+ v as getPenPreset,
46
+ z as getPenPresetNames,
47
+ O as handleToolCall,
48
+ W as handleToolCalls,
49
+ D as highlightToStrokes,
50
+ B as normalizeAnnotationArray,
51
+ h as seededRandom,
52
+ C as textToStrokes,
46
53
  r as viewportUtils
47
54
  };
48
55
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/index.js"],"sourcesContent":["/**\n * @ai-annotator/renderer - Public API\n *\n * Single entry point for the Dynamic PDF Annotation Renderer library.\n * Exports all core subsystems, layers, utilities, and types.\n *\n * @module @ai-annotator/renderer\n */\n\n// ============================================================================\n// Core Rendering Engine\n// ============================================================================\n\n// Import statements\nimport { AnnotationRenderer } from './core/AnnotationRenderer.js';\nimport { PDFRenderer } from './core/PDFRenderer.js';\nimport { LayerManager } from './core/LayerManager.js';\nimport { TimelineSync } from './core/TimelineSync.js';\n\n// Export statements\nexport { AnnotationRenderer };\nexport { PDFRenderer };\nexport { LayerManager };\nexport { TimelineSync };\n\n// ============================================================================\n// Annotation Layers\n// ============================================================================\n\n// Framework-agnostic layer classes\n// BaseLayer: Abstract base class for creating custom layers\n// HighlightLayer, TextLayer, DrawingLayer: Built-in layer implementations\n\nimport BaseLayer from './layers/BaseLayer.js';\nimport HighlightLayer from './layers/HighlightLayer.js';\nimport TextLayer from './layers/TextLayer.js';\nimport DrawingLayer from './layers/DrawingLayer.js';\n\nexport { BaseLayer };\nexport { HighlightLayer };\nexport { TextLayer };\nexport { DrawingLayer };\n\n// ============================================================================\n// Utilities\n// ============================================================================\n\nimport * as coordinateUtils from './utils/coordinateUtils.js';\nimport * as viewportUtils from './utils/viewportUtils.js';\n\nexport { coordinateUtils };\nexport { viewportUtils };\n\n// Future: colorUtils, validators\n// import * as colorUtils from './utils/colorUtils.js';\n// export { colorUtils };\n\n// ============================================================================\n// PDF Extraction Utilities\n// ============================================================================\n\n/**\n * PDF data extraction utilities for text and image blocks\n * Uses PDF.js getOperatorList() for efficient metadata extraction without rendering\n */\nimport { extractAllBlocks, extractMultiplePages } from './utils/pdfExtractor.js';\n\nexport { extractAllBlocks };\nexport { extractMultiplePages };\n\n// Alias for backwards compatibility and API consistency\nexport { extractAllBlocks as extractPDFBlocks };\n\n// ============================================================================\n// Type Definitions & Validators\n// ============================================================================\n\n// Type definitions in src/types/annotations.js\n\n/**\n * Type Validators - Optional data normalization\n *\n * Import separately to use defensive normalization for annotation data.\n * These validators are standalone utilities that do not modify the core system.\n */\nexport { normalizeAnnotationArray } from './types/validators.js';\n\n// Namespace export for all validator utilities\nexport * as TypeValidators from './types/index.js';\n\n// ============================================================================\n// Framework Adapters\n// ============================================================================\n// Declarative framework-specific wrappers for AnnotationRenderer\n// These provide idiomatic APIs for React, Vue, and other frameworks\n\n/**\n * React adapter component for declarative PDF annotation rendering\n * @see {@link AnnotPdf}\n */\nexport { AnnotPdf } from './adapters/index.js';\n\n// Future framework adapters will be exported here:\n// export { VuePdfViewer } from './adapters/index.js';\n// export { SveltePdfViewer } from './adapters/index.js';\n\n// ============================================================================\n// AI Tools for Annotation Generation\n// ============================================================================\n\n/**\n * AI-powered annotation generation tools\n *\n * Provides OpenAI-compatible function calling schemas and handlers\n * for generating PDF annotations with AI models.\n *\n * @see {@link module:ai-tools}\n */\nexport {\n annotationTools,\n getAnnotationTools,\n handleToolCall,\n handleToolCalls,\n createHighlight,\n createText,\n createInk\n} from './ai-tools/index.js';\n\n// ============================================================================\n// Package Metadata\n// ============================================================================\n\n/**\n * Library version\n * @constant {string}\n */\nexport const VERSION = '0.3.0';\n\n/**\n * Library name\n * @constant {string}\n */\nexport const LIB_NAME = 'web-annotation-renderer';\n"],"names":["VERSION","LIB_NAME"],"mappings":";;;;;;;;;;;;;;;;;;;AAwIY,MAACA,IAAU,SAMVC,IAAW;"}
1
+ {"version":3,"file":"index.js","sources":["../src/index.js"],"sourcesContent":["/**\n * @ai-annotator/renderer - Public API\n *\n * Single entry point for the Dynamic PDF Annotation Renderer library.\n * Exports all core subsystems, utilities, and types.\n *\n * @module @ai-annotator/renderer\n */\n\n// ============================================================================\n// Core Rendering Engine\n// ============================================================================\n\nimport { AnnotationRenderer } from './core/AnnotationRenderer.js';\nimport { PDFRenderer } from './core/PDFRenderer.js';\nimport { TimelineSync } from './core/TimelineSync.js';\n\nexport { AnnotationRenderer };\nexport { PDFRenderer };\nexport { TimelineSync };\n\n// ============================================================================\n// Stroke Renderer - Unified Canvas-Based Annotation Rendering\n// ============================================================================\n\nimport { StrokeRenderer } from './renderer/StrokeRenderer.js';\n\nexport { StrokeRenderer };\n\n// ============================================================================\n// Converters - Annotation to Stroke Conversion\n// ============================================================================\n\nimport { highlightToStrokes, textToStrokes } from './converters/index.js';\n\nexport { highlightToStrokes };\nexport { textToStrokes };\n\n// ============================================================================\n// Pen Effects - Hand-Drawn Feel Utilities\n// ============================================================================\n\nimport {\n applyJitter,\n applyPressure,\n applyWobble,\n deepMerge,\n seededRandom\n} from './pen/effects.js';\n\nexport { applyJitter };\nexport { applyPressure };\nexport { applyWobble };\nexport { deepMerge };\nexport { seededRandom };\n\n// ============================================================================\n// Pen Module - Legacy Stroke Rendering (Retained for Compatibility)\n// ============================================================================\n\nimport { GradualRenderer, StrokeDrawer, getPreset, getPresetNames } from './pen/index.js';\n\nexport { GradualRenderer };\nexport { StrokeDrawer };\nexport { getPreset as getPenPreset };\nexport { getPresetNames as getPenPresetNames };\n\n// ============================================================================\n// Utilities\n// ============================================================================\n\nimport * as coordinateUtils from './utils/coordinateUtils.js';\nimport * as viewportUtils from './utils/viewportUtils.js';\n\nexport { coordinateUtils };\nexport { viewportUtils };\n\n// ============================================================================\n// PDF Extraction Utilities\n// ============================================================================\n\nimport { extractAllBlocks, extractMultiplePages } from './utils/pdfExtractor.js';\n\nexport { extractAllBlocks };\nexport { extractMultiplePages };\nexport { extractAllBlocks as extractPDFBlocks };\n\n// ============================================================================\n// Type Definitions & Validators\n// ============================================================================\n\nexport { normalizeAnnotationArray } from './types/validators.js';\nexport * as TypeValidators from './types/index.js';\n\n// ============================================================================\n// Framework Adapters\n// ============================================================================\n\nexport { AnnotPdf } from './adapters/index.js';\n\n// ============================================================================\n// AI Tools for Annotation Generation\n// ============================================================================\n\nexport {\n annotationTools,\n getAnnotationTools,\n handleToolCall,\n handleToolCalls,\n createHighlight,\n createText\n} from './ai-tools/index.js';\n\n// ============================================================================\n// Package Metadata\n// ============================================================================\n\nexport const VERSION = '1.0.0';\nexport const LIB_NAME = 'web-annotation-renderer';\n"],"names":["VERSION","LIB_NAME"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqHY,MAACA,IAAU,SACVC,IAAW;"}
package/dist/index10.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=(t,h)=>({left:t.x*h.width,top:t.y*h.height,width:(t.w??0)*h.width,height:(t.h??0)*h.height}),i=(t,h)=>({left:t.x*h.width,top:t.y*h.height,width:(t.w??0)*h.width,height:(t.h??0)*h.height});function o(t,h){return{x:t.x*h.width,y:t.y*h.height}}exports.NormSizeToPixel=i;exports.pointNormToAbs=o;exports.rectNormToAbs=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./index22.cjs");function d(n,e,i,l,t){let o=n;return typeof n=="string"&&(o=parseFloat(n)),typeof o!="number"||isNaN(o)?(t.push(`[${i}]: Field "${l}" invalid value "${n}", using default ${e}`),e):o<0?(t.push(`[${i}]: Field "${l}" value ${o} below range [0,1], clamping to 0`),0):o>1?(t.push(`[${i}]: Field "${l}" value ${o} exceeds range [0,1], clamping to 1`),1):o}function u(n,e,i,l){if(typeof n!="string"||n.trim().length===0)return l.push(`[${i}]: Invalid color format "${n}", using default ${e}`),e;const t=n.trim(),o=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/,r=/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(,\s*[\d.]+\s*)?\)$/,a=["red","blue","green","yellow","black","white","gray","grey","orange","purple","pink","brown","transparent"],m=o.test(t),y=r.test(t),h=a.includes(t.toLowerCase());return m||y||h?t:(l.push(`[${i}]: Invalid color format "${n}", using default ${e}`),e)}function $(n,e,i,l,t){let o=n;return typeof n=="string"&&(o=parseFloat(n)),typeof o!="number"||isNaN(o)||o<=0?(t.push(`[${i}]: Field "${l}" invalid value "${n}", using default ${e}`),e):o}function f(n,e,i){const l={};if(typeof n.id!="string"||n.id.trim().length===0){const t=Date.now(),o=Math.random().toString(36).substr(2,9);l.id=`anno-${t}-${o}`,i.push(`[${l.id}]: Auto-generated ID (original was missing or invalid)`)}else l.id=n.id.trim();return l.type=n.type,typeof n.page!="number"||n.page<1?(e.push(`[${l.id}]: Field "page" invalid value "${n.page}", using default ${s.BASE_DEFAULTS.page}`),l.page=s.BASE_DEFAULTS.page):l.page=Math.floor(n.page),typeof n.start!="number"||n.start<0?(e.push(`[${l.id}]: Field "start" invalid value "${n.start}", using default ${s.BASE_DEFAULTS.start}`),l.start=s.BASE_DEFAULTS.start):l.start=n.start,typeof n.end!="number"||n.end<0?(e.push(`[${l.id}]: Field "end" invalid value "${n.end}", using start value ${l.start}`),l.end=l.start):n.end<l.start?(e.push(`[${l.id}]: Field "end" (${n.end}) less than start (${l.start}), clamping to start`),l.end=l.start):l.end=n.end,l}function A(n,e,i){return!n||typeof n!="object"?(i.push(`[${e}]: Invalid quad object, using default`),{x:.1,y:.1,w:.8,h:.05}):{x:d(n.x,.1,e,"quad.x",i),y:d(n.y,.1,e,"quad.y",i),w:d(n.w,.8,e,"quad.w",i),h:d(n.h,.05,e,"quad.h",i)}}function c(n,e,i,l){const t={...n};e.mode!=="quads"?(i.push(`[${n.id}]: Field "mode" invalid value "${e.mode}", using default "${s.HIGHLIGHT_DEFAULTS.mode}"`),t.mode=s.HIGHLIGHT_DEFAULTS.mode):t.mode=e.mode,!Array.isArray(e.quads)||e.quads.length===0?(i.push(`[${n.id}]: Field "quads" missing or empty, using default`),t.quads=s.HIGHLIGHT_DEFAULTS.quads):t.quads=e.quads.map((r,a)=>A(r,n.id,i));const o=s.HIGHLIGHT_DEFAULTS.style.color;return!e.style||typeof e.style!="object"?(i.push(`[${n.id}]: Field "style" missing or invalid, using default`),t.style={color:o}):t.style={color:u(e.style.color,o,n.id,i)},t}function p(n,e,i,l){const t={...n};typeof e.content!="string"||e.content.trim().length===0?(i.push(`[${n.id}]: Field "content" missing or empty, using default "${s.TEXT_DEFAULTS.content}"`),t.content=s.TEXT_DEFAULTS.content):t.content=e.content,t.x=d(e.x,s.TEXT_DEFAULTS.x,n.id,"x",i),t.y=d(e.y,s.TEXT_DEFAULTS.y,n.id,"y",i),t.w=d(e.w,s.TEXT_DEFAULTS.w,n.id,"w",i),t.h=d(e.h,s.TEXT_DEFAULTS.h,n.id,"h",i);const o=s.TEXT_DEFAULTS.style.bg,r=s.TEXT_DEFAULTS.style.color;return!e.style||typeof e.style!="object"?(i.push(`[${n.id}]: Field "style" missing or invalid, using defaults`),t.style={bg:o,color:r}):t.style={bg:u(e.style.bg,o,n.id,i),color:u(e.style.color,r,n.id,i)},t}function g(n,e){const i=[],l=[];if(!n||typeof n!="object")return{annotation:null,warnings:[],info:[],critical:`Annotation at index ${e}: Not a valid object`};if(typeof n.type!="string"||n.type.trim().length===0)return{annotation:null,warnings:[],info:[],critical:`Annotation at index ${e}: Missing or invalid type field`};const t=n.type.trim(),o=f(n,i,l);let r;if(t==="highlight")r=c(o,n,i);else if(t==="text")r=p(o,n,i);else return{annotation:null,warnings:[],info:[],critical:`Annotation at index ${e}: Unsupported type "${t}"`};return{annotation:r,warnings:i,info:l,critical:null}}function T(n,e={}){e.skipInvalid;const i=e.warnInConsole!==!1,l=e.onWarning||null,t={normalized:[],warnings:[],info:[],skipped:[]};if(!Array.isArray(n)){const o="normalizeAnnotationArray: Input is not an array, returning empty result";return t.warnings.push(o),i&&console.warn(`[Annotation Normalizer] ${o}`),t}return n.forEach((o,r)=>{if(o==null){t.skipped.push({index:r,annotation:o,reason:"Annotation is null or undefined"});return}const a=g(o,r);if(a.critical){t.skipped.push({index:r,annotation:o,reason:a.critical}),i&&console.error(`[Annotation Normalizer] ${a.critical}`);return}t.normalized.push(a.annotation),t.warnings.push(...a.warnings),t.info.push(...a.info)}),i&&(t.warnings.length>0||t.info.length>0||t.skipped.length>0)&&(console.group("[Annotation Normalizer] Validation Summary"),t.normalized.length>0&&console.info(`✓ Normalized ${t.normalized.length} annotation(s)`),t.skipped.length>0&&(console.error(`✗ Skipped ${t.skipped.length} annotation(s)`),t.skipped.forEach(o=>{console.error(` Index ${o.index}: ${o.reason}`)})),t.warnings.length>0&&(console.warn(`⚠ ${t.warnings.length} warning(s):`),t.warnings.forEach(o=>console.warn(` ${o}`))),t.info.length>0&&(console.info(`ℹ ${t.info.length} info message(s):`),t.info.forEach(o=>console.info(` ${o}`))),console.groupEnd()),l&&typeof l=="function"&&l(t),t}exports.normalizeAnnotation=g;exports.normalizeAnnotationArray=T;exports.normalizeBaseFields=f;exports.normalizeColor=u;exports.normalizeCoordinate=d;exports.normalizeHighlight=c;exports.normalizePositiveNumber=$;exports.normalizeText=p;
2
2
  //# sourceMappingURL=index10.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index10.cjs","sources":["../src/utils/coordinateUtils.js"],"sourcesContent":["/**\n * Coordinate Utility Functions\n *\n * This module provides utility functions for coordinate transformations\n * between normalized (0-1) coordinates and absolute pixel coordinates.\n * Used by annotation layers to position elements on the PDF canvas.\n */\n\n/**\n * Convert normalized rectangle to absolute pixel coordinates\n *\n * Transforms a rectangle with normalized coordinates (0-1 range) to\n * absolute pixel coordinates based on viewport dimensions.\n *\n * @param {{x: number, y: number, w: number, h: number}} rect - Normalized rectangle (0-1)\n * @param {{width: number, height: number}} viewport - Viewport dimensions in pixels\n * @returns {{left: number, top: number, width: number, height: number}} Absolute coordinates in pixels\n *\n * @example\n * const rect = { x: 0.1, y: 0.2, w: 0.5, h: 0.3 };\n * const viewport = { width: 1000, height: 1400 };\n * const absolute = rectNormToAbs(rect, viewport);\n * // Returns: { left: 100, top: 280, width: 500, height: 420 }\n */\nexport const rectNormToAbs = (r, vp) => ({\n left: r.x * vp.width,\n top: r.y * vp.height,\n width: (r.w ?? 0) * vp.width,\n height: (r.h ?? 0) * vp.height,\n});\n\n/**\n * Convert normalized size to pixel dimensions (Legacy)\n *\n * @deprecated Use rectNormToAbs instead. This function is kept for backward compatibility.\n *\n * Transforms normalized rectangle coordinates to absolute pixel coordinates.\n * This is an alias for rectNormToAbs maintained for backward compatibility.\n *\n * @param {{x: number, y: number, w: number, h: number}} r - Normalized rectangle (0-1)\n * @param {{width: number, height: number}} vp - Viewport dimensions in pixels\n * @returns {{left: number, top: number, width: number, height: number}} Absolute coordinates in pixels\n */\nexport const NormSizeToPixel = (r, vp) => ({\n left: r.x * vp.width,\n top: r.y * vp.height,\n width: (r.w ?? 0) * vp.width,\n height: (r.h ?? 0) * vp.height,\n});\n\n/**\n * Convert normalized point to absolute pixel coordinates\n *\n * Transforms a point with normalized coordinates (0-1 range) to\n * absolute pixel coordinates based on viewport dimensions.\n *\n * @param {{x: number, y: number}} point - Normalized point (0-1)\n * @param {{width: number, height: number}} viewport - Viewport dimensions in pixels\n * @returns {{x: number, y: number}} Absolute coordinates in pixels\n *\n * @example\n * const point = { x: 0.5, y: 0.5 };\n * const viewport = { width: 1000, height: 1400 };\n * const absolute = pointNormToAbs(point, viewport);\n * // Returns: { x: 500, y: 700 }\n */\nexport function pointNormToAbs(point, viewport) {\n return {\n x: point.x * viewport.width,\n y: point.y * viewport.height\n };\n}\n"],"names":["rectNormToAbs","r","vp","NormSizeToPixel","pointNormToAbs","point","viewport"],"mappings":"gFAwBY,MAACA,EAAgB,CAACC,EAAGC,KAAQ,CACvC,KAAMD,EAAE,EAAIC,EAAG,MACf,IAAKD,EAAE,EAAIC,EAAG,OACd,OAAQD,EAAE,GAAK,GAAKC,EAAG,MACvB,QAASD,EAAE,GAAK,GAAKC,EAAG,MAC1B,GAcaC,EAAkB,CAACF,EAAGC,KAAQ,CACzC,KAAMD,EAAE,EAAIC,EAAG,MACf,IAAKD,EAAE,EAAIC,EAAG,OACd,OAAQD,EAAE,GAAK,GAAKC,EAAG,MACvB,QAASD,EAAE,GAAK,GAAKC,EAAG,MAC1B,GAkBO,SAASE,EAAeC,EAAOC,EAAU,CAC9C,MAAO,CACL,EAAGD,EAAM,EAAIC,EAAS,MACtB,EAAGD,EAAM,EAAIC,EAAS,MAC1B,CACA"}
1
+ {"version":3,"file":"index10.cjs","sources":["../src/types/validators.js"],"sourcesContent":["/**\n * Annotation Data Normalization Utilities\n *\n * This module provides defensive normalization functions that validate and fix\n * annotation data. Invalid values are replaced with safe defaults and warnings\n * are collected for user feedback.\n *\n * @module types/validators\n */\n\nimport {\n BASE_DEFAULTS,\n HIGHLIGHT_DEFAULTS,\n TEXT_DEFAULTS\n} from './defaults.js';\n\n// ============================================================================\n// FIELD-LEVEL NORMALIZERS\n// ============================================================================\n\n/**\n * Normalize coordinate value to 0-1 range\n *\n * Validates that a value is a number in the 0-1 range. Out-of-range values\n * are clamped. Invalid values use the provided default.\n *\n * @param {*} value - Value to normalize\n * @param {number} defaultValue - Fallback value if invalid\n * @param {string} id - Annotation ID for warning messages\n * @param {string} fieldName - Field name for warning messages\n * @param {Array<string>} warnings - Array to collect warning messages\n * @returns {number} Normalized coordinate value in range [0, 1]\n *\n * @example\n * normalizeCoordinate(0.5, 0.1, 'txt-1', 'x', warnings) // Returns: 0.5\n * normalizeCoordinate(5, 0.1, 'txt-1', 'x', warnings) // Returns: 1, adds warning\n * normalizeCoordinate('abc', 0.1, 'txt-1', 'x', warnings) // Returns: 0.1, adds warning\n */\nexport function normalizeCoordinate(value, defaultValue, id, fieldName, warnings) {\n // Type coercion: parse string to number if needed\n let numValue = value;\n if (typeof value === 'string') {\n numValue = parseFloat(value);\n if (!isNaN(numValue) && numValue === value) {\n // Successfully parsed - no warning needed\n }\n }\n\n // Validate is valid number\n if (typeof numValue !== 'number' || isNaN(numValue)) {\n warnings.push(\n `[${id}]: Field \"${fieldName}\" invalid value \"${value}\", using default ${defaultValue}`\n );\n return defaultValue;\n }\n\n // Range check: clamp to [0, 1]\n if (numValue < 0) {\n warnings.push(\n `[${id}]: Field \"${fieldName}\" value ${numValue} below range [0,1], clamping to 0`\n );\n return 0;\n }\n\n if (numValue > 1) {\n warnings.push(\n `[${id}]: Field \"${fieldName}\" value ${numValue} exceeds range [0,1], clamping to 1`\n );\n return 1;\n }\n\n // Valid value\n return numValue;\n}\n\n/**\n * Normalize color string\n *\n * Validates that a value is a valid color string. Supports hex, rgb/rgba,\n * and named colors. Invalid colors use the provided default.\n *\n * @param {*} value - Color value to normalize\n * @param {string} defaultValue - Fallback color if invalid\n * @param {string} id - Annotation ID for warning messages\n * @param {Array<string>} warnings - Array to collect warning messages\n * @returns {string} Valid color string\n *\n * @example\n * normalizeColor('#fff', '#000', 'txt-1', warnings) // Returns: '#fff'\n * normalizeColor('rgba(255,0,0,0.5)', '#000', 'txt-1', warnings) // Returns: 'rgba(255,0,0,0.5)'\n * normalizeColor('notacolor', '#000', 'txt-1', warnings) // Returns: '#000', adds warning\n */\nexport function normalizeColor(value, defaultValue, id, warnings) {\n // Type check: must be non-empty string\n if (typeof value !== 'string' || value.trim().length === 0) {\n warnings.push(\n `[${id}]: Invalid color format \"${value}\", using default ${defaultValue}`\n );\n return defaultValue;\n }\n\n const trimmed = value.trim();\n\n // Regex patterns for color validation (cached at module level)\n const hexPattern = /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;\n const rgbPattern = /^rgba?\\(\\s*\\d+\\s*,\\s*\\d+\\s*,\\s*\\d+\\s*(,\\s*[\\d.]+\\s*)?\\)$/;\n\n // Named colors (basic set)\n const namedColors = [\n 'red', 'blue', 'green', 'yellow', 'black', 'white', 'gray',\n 'grey', 'orange', 'purple', 'pink', 'brown', 'transparent'\n ];\n\n // Validate format\n const isHex = hexPattern.test(trimmed);\n const isRgb = rgbPattern.test(trimmed);\n const isNamed = namedColors.includes(trimmed.toLowerCase());\n\n if (isHex || isRgb || isNamed) {\n return trimmed;\n }\n\n // Invalid format\n warnings.push(\n `[${id}]: Invalid color format \"${value}\", using default ${defaultValue}`\n );\n return defaultValue;\n}\n\n/**\n * Normalize positive number\n *\n * Validates that a value is a positive number. Invalid values use the\n * provided default.\n *\n * @param {*} value - Value to normalize\n * @param {number} defaultValue - Fallback value if invalid\n * @param {string} id - Annotation ID for warning messages\n * @param {string} fieldName - Field name for warning messages\n * @param {Array<string>} warnings - Array to collect warning messages\n * @returns {number} Positive number\n *\n * @example\n * normalizePositiveNumber(5, 3, 'ink-1', 'size', warnings) // Returns: 5\n * normalizePositiveNumber(-1, 3, 'ink-1', 'size', warnings) // Returns: 3, adds warning\n * normalizePositiveNumber('abc', 3, 'ink-1', 'size', warnings) // Returns: 3, adds warning\n */\nexport function normalizePositiveNumber(value, defaultValue, id, fieldName, warnings) {\n // Type coercion: parse string to number if needed\n let numValue = value;\n if (typeof value === 'string') {\n numValue = parseFloat(value);\n }\n\n // Validate is valid number and positive\n if (typeof numValue !== 'number' || isNaN(numValue) || numValue <= 0) {\n warnings.push(\n `[${id}]: Field \"${fieldName}\" invalid value \"${value}\", using default ${defaultValue}`\n );\n return defaultValue;\n }\n\n return numValue;\n}\n\n// ============================================================================\n// BASE FIELDS NORMALIZER\n// ============================================================================\n\n/**\n * Normalize common base annotation fields\n *\n * Validates and normalizes fields common to all annotation types: id, type,\n * page, start, and end. Auto-generates ID if missing. Applies safe defaults\n * for invalid values.\n *\n * @param {Object} raw - Raw annotation object\n * @param {Array<string>} warnings - Array to collect warning messages\n * @param {Array<string>} info - Array to collect info messages\n * @returns {Object} Object with normalized base fields\n *\n * @example\n * normalizeBaseFields({ type: 'text', page: 2 }, warnings, info)\n * // Returns: { id: 'anno-1234...', type: 'text', page: 2, start: 0, end: 0 }\n */\nexport function normalizeBaseFields(raw, warnings, info) {\n const base = {};\n\n // ===== ID Field =====\n // Check: non-empty string\n // Invalid: auto-generate unique ID\n if (typeof raw.id !== 'string' || raw.id.trim().length === 0) {\n const timestamp = Date.now();\n const random = Math.random().toString(36).substr(2, 9);\n base.id = `anno-${timestamp}-${random}`;\n info.push(`[${base.id}]: Auto-generated ID (original was missing or invalid)`);\n } else {\n base.id = raw.id.trim();\n }\n\n // ===== Type Field =====\n // Pass through as-is (validated in parent function)\n base.type = raw.type;\n\n // ===== Page Field =====\n // Check: positive integer\n // Invalid: default to 1\n if (typeof raw.page !== 'number' || raw.page < 1) {\n warnings.push(\n `[${base.id}]: Field \"page\" invalid value \"${raw.page}\", using default ${BASE_DEFAULTS.page}`\n );\n base.page = BASE_DEFAULTS.page;\n } else {\n // Floor to ensure integer\n base.page = Math.floor(raw.page);\n }\n\n // ===== Start Field =====\n // Check: non-negative number\n // Invalid: default to 0\n if (typeof raw.start !== 'number' || raw.start < 0) {\n warnings.push(\n `[${base.id}]: Field \"start\" invalid value \"${raw.start}\", using default ${BASE_DEFAULTS.start}`\n );\n base.start = BASE_DEFAULTS.start;\n } else {\n base.start = raw.start;\n }\n\n // ===== End Field =====\n // Check: non-negative number >= start\n // Invalid: clamp to start value\n if (typeof raw.end !== 'number' || raw.end < 0) {\n warnings.push(\n `[${base.id}]: Field \"end\" invalid value \"${raw.end}\", using start value ${base.start}`\n );\n base.end = base.start;\n } else if (raw.end < base.start) {\n warnings.push(\n `[${base.id}]: Field \"end\" (${raw.end}) less than start (${base.start}), clamping to start`\n );\n base.end = base.start;\n } else {\n base.end = raw.end;\n }\n\n return base;\n}\n\n// ============================================================================\n// TYPE-SPECIFIC NORMALIZERS\n// ============================================================================\n\n/**\n * Normalize a single quad (rectangular region)\n *\n * @private\n * @param {Object} quad - Quad object with x, y, w, h\n * @param {string} id - Annotation ID\n * @param {Array<string>} warnings - Warnings array\n * @returns {Object} Normalized quad\n */\nfunction normalizeQuad(quad, id, warnings) {\n if (!quad || typeof quad !== 'object') {\n warnings.push(`[${id}]: Invalid quad object, using default`);\n return { x: 0.1, y: 0.1, w: 0.8, h: 0.05 };\n }\n\n return {\n x: normalizeCoordinate(quad.x, 0.1, id, 'quad.x', warnings),\n y: normalizeCoordinate(quad.y, 0.1, id, 'quad.y', warnings),\n w: normalizeCoordinate(quad.w, 0.8, id, 'quad.w', warnings),\n h: normalizeCoordinate(quad.h, 0.05, id, 'quad.h', warnings)\n };\n}\n\n/**\n * Normalize highlight annotation\n *\n * Validates and normalizes highlight-specific fields: mode, quads array,\n * and style.color. Applies defaults for invalid fields.\n *\n * @param {Object} base - Object with normalized base fields\n * @param {Object} raw - Raw annotation object\n * @param {Array<string>} warnings - Warnings array\n * @param {Array<string>} info - Info array\n * @returns {Object} Fully normalized highlight annotation\n *\n * @example\n * normalizeHighlight(base, raw, warnings, info)\n * // Returns: { ...base, mode: 'quads', quads: [...], style: {...} }\n */\nexport function normalizeHighlight(base, raw, warnings, info) {\n const annotation = { ...base };\n\n // ===== Mode Field =====\n // Check: value equals \"quads\"\n // Invalid: default to \"quads\"\n if (raw.mode !== 'quads') {\n warnings.push(\n `[${base.id}]: Field \"mode\" invalid value \"${raw.mode}\", using default \"${HIGHLIGHT_DEFAULTS.mode}\"`\n );\n annotation.mode = HIGHLIGHT_DEFAULTS.mode;\n } else {\n annotation.mode = raw.mode;\n }\n\n // ===== Quads Array =====\n // Check: non-empty array\n // Invalid: use default quads\n if (!Array.isArray(raw.quads) || raw.quads.length === 0) {\n warnings.push(\n `[${base.id}]: Field \"quads\" missing or empty, using default`\n );\n annotation.quads = HIGHLIGHT_DEFAULTS.quads;\n } else {\n // Normalize each quad\n annotation.quads = raw.quads.map((quad, idx) => normalizeQuad(quad, base.id, warnings));\n }\n\n // ===== Style Object =====\n // Check: object with color property\n const defaultColor = HIGHLIGHT_DEFAULTS.style.color;\n if (!raw.style || typeof raw.style !== 'object') {\n warnings.push(\n `[${base.id}]: Field \"style\" missing or invalid, using default`\n );\n annotation.style = { color: defaultColor };\n } else {\n annotation.style = {\n color: normalizeColor(raw.style.color, defaultColor, base.id, warnings)\n };\n }\n\n return annotation;\n}\n\n/**\n * Normalize text annotation\n *\n * Validates and normalizes text-specific fields: content, position (x, y),\n * dimensions (w, h), and style (bg, color). Applies defaults for invalid fields.\n *\n * @param {Object} base - Object with normalized base fields\n * @param {Object} raw - Raw annotation object\n * @param {Array<string>} warnings - Warnings array\n * @param {Array<string>} info - Info array\n * @returns {Object} Fully normalized text annotation\n *\n * @example\n * normalizeText(base, raw, warnings, info)\n * // Returns: { ...base, content: '...', x: 0.1, y: 0.1, w: 0.3, h: 0.1, style: {...} }\n */\nexport function normalizeText(base, raw, warnings, info) {\n const annotation = { ...base };\n\n // ===== Content Field =====\n // Check: non-empty string\n // Invalid: default to placeholder\n if (typeof raw.content !== 'string' || raw.content.trim().length === 0) {\n warnings.push(\n `[${base.id}]: Field \"content\" missing or empty, using default \"${TEXT_DEFAULTS.content}\"`\n );\n annotation.content = TEXT_DEFAULTS.content;\n } else {\n annotation.content = raw.content;\n }\n\n // ===== Position Fields (x, y) =====\n annotation.x = normalizeCoordinate(raw.x, TEXT_DEFAULTS.x, base.id, 'x', warnings);\n annotation.y = normalizeCoordinate(raw.y, TEXT_DEFAULTS.y, base.id, 'y', warnings);\n\n // ===== Dimension Fields (w, h) =====\n annotation.w = normalizeCoordinate(raw.w, TEXT_DEFAULTS.w, base.id, 'w', warnings);\n annotation.h = normalizeCoordinate(raw.h, TEXT_DEFAULTS.h, base.id, 'h', warnings);\n\n // ===== Style Object =====\n const defaultBg = TEXT_DEFAULTS.style.bg;\n const defaultColor = TEXT_DEFAULTS.style.color;\n\n if (!raw.style || typeof raw.style !== 'object') {\n warnings.push(\n `[${base.id}]: Field \"style\" missing or invalid, using defaults`\n );\n annotation.style = {\n bg: defaultBg,\n color: defaultColor\n };\n } else {\n annotation.style = {\n bg: normalizeColor(raw.style.bg, defaultBg, base.id, warnings),\n color: normalizeColor(raw.style.color, defaultColor, base.id, warnings)\n };\n }\n\n return annotation;\n}\n\n// ============================================================================\n// ORCHESTRATION - SINGLE ANNOTATION & ARRAY\n// ============================================================================\n\n/**\n * Normalize a single annotation\n *\n * Routes annotation to appropriate type-specific normalizer based on type field.\n * Handles critical validation errors (missing/invalid type).\n *\n * @param {Object} raw - Raw annotation object\n * @param {number} index - Position in original array (for error context)\n * @returns {Object} Result object with annotation, warnings, info, and critical error\n * @returns {Object|null} return.annotation - Normalized annotation or null if critical error\n * @returns {Array<string>} return.warnings - Warning messages\n * @returns {Array<string>} return.info - Info messages\n * @returns {string|null} return.critical - Critical error message or null\n *\n * @example\n * normalizeAnnotation({ type: 'text', content: 'Hello' }, 0)\n * // Returns: { annotation: {...}, warnings: [], info: [], critical: null }\n */\nexport function normalizeAnnotation(raw, index) {\n const warnings = [];\n const info = [];\n\n // Validate input is object\n if (!raw || typeof raw !== 'object') {\n return {\n annotation: null,\n warnings: [],\n info: [],\n critical: `Annotation at index ${index}: Not a valid object`\n };\n }\n\n // Check type field (critical - cannot route without type)\n if (typeof raw.type !== 'string' || raw.type.trim().length === 0) {\n return {\n annotation: null,\n warnings: [],\n info: [],\n critical: `Annotation at index ${index}: Missing or invalid type field`\n };\n }\n\n const type = raw.type.trim();\n\n // Normalize base fields first\n const base = normalizeBaseFields(raw, warnings, info);\n\n // Route to type-specific normalizer\n let annotation;\n\n if (type === 'highlight') {\n annotation = normalizeHighlight(base, raw, warnings, info);\n } else if (type === 'text') {\n annotation = normalizeText(base, raw, warnings, info);\n } else {\n return {\n annotation: null,\n warnings: [],\n info: [],\n critical: `Annotation at index ${index}: Unsupported type \"${type}\"`\n };\n }\n\n return {\n annotation,\n warnings,\n info,\n critical: null\n };\n}\n\n/**\n * Normalize array of annotations\n *\n * MAIN ENTRY POINT for annotation normalization. Processes each annotation,\n * collects warnings, and returns normalized data ready for rendering.\n *\n * @param {Array} rawAnnotations - Array of raw annotation objects\n * @param {Object} [options] - Configuration options\n * @param {boolean} [options.skipInvalid=true] - Skip critically invalid annotations\n * @param {boolean} [options.warnInConsole=true] - Log warnings to console\n * @param {Function} [options.onWarning] - Custom warning callback\n * @returns {Object} ValidationResult with normalized annotations and messages\n * @returns {Array} return.normalized - Successfully normalized annotations\n * @returns {Array<string>} return.warnings - Warning messages\n * @returns {Array<string>} return.info - Informational messages\n * @returns {Array<Object>} return.skipped - Skipped annotations with reasons\n *\n * @example\n * const result = normalizeAnnotationArray(rawAnnotations, {\n * skipInvalid: true,\n * warnInConsole: true\n * });\n *\n * renderer.setAnnotations(result.normalized);\n */\nexport function normalizeAnnotationArray(rawAnnotations, options = {}) {\n // Default options\n const skipInvalid = options.skipInvalid !== false; // Default: true\n const warnInConsole = options.warnInConsole !== false; // Default: true\n const onWarning = options.onWarning || null;\n\n // Initialize result structure\n const result = {\n normalized: [],\n warnings: [],\n info: [],\n skipped: []\n };\n\n // Validate input is array\n if (!Array.isArray(rawAnnotations)) {\n const warning = 'normalizeAnnotationArray: Input is not an array, returning empty result';\n result.warnings.push(warning);\n\n if (warnInConsole) {\n console.warn(`[Annotation Normalizer] ${warning}`);\n }\n\n return result;\n }\n\n // Process each annotation\n rawAnnotations.forEach((raw, index) => {\n // Skip null/undefined\n if (raw == null) {\n result.skipped.push({\n index,\n annotation: raw,\n reason: 'Annotation is null or undefined'\n });\n return;\n }\n\n // Normalize annotation\n const normalized = normalizeAnnotation(raw, index);\n\n // Check for critical error\n if (normalized.critical) {\n result.skipped.push({\n index,\n annotation: raw,\n reason: normalized.critical\n });\n\n if (warnInConsole) {\n console.error(`[Annotation Normalizer] ${normalized.critical}`);\n }\n\n return;\n }\n\n // Add to normalized array\n result.normalized.push(normalized.annotation);\n\n // Collect warnings and info\n result.warnings.push(...normalized.warnings);\n result.info.push(...normalized.info);\n });\n\n // Console output\n if (warnInConsole) {\n if (result.warnings.length > 0 || result.info.length > 0 || result.skipped.length > 0) {\n console.group('[Annotation Normalizer] Validation Summary');\n\n if (result.normalized.length > 0) {\n console.info(`✓ Normalized ${result.normalized.length} annotation(s)`);\n }\n\n if (result.skipped.length > 0) {\n console.error(`✗ Skipped ${result.skipped.length} annotation(s)`);\n result.skipped.forEach(s => {\n console.error(` Index ${s.index}: ${s.reason}`);\n });\n }\n\n if (result.warnings.length > 0) {\n console.warn(`⚠ ${result.warnings.length} warning(s):`);\n result.warnings.forEach(w => console.warn(` ${w}`));\n }\n\n if (result.info.length > 0) {\n console.info(`ℹ ${result.info.length} info message(s):`);\n result.info.forEach(i => console.info(` ${i}`));\n }\n\n console.groupEnd();\n }\n }\n\n // Call custom warning handler\n if (onWarning && typeof onWarning === 'function') {\n onWarning(result);\n }\n\n return result;\n}\n"],"names":["normalizeCoordinate","value","defaultValue","id","fieldName","warnings","numValue","normalizeColor","trimmed","hexPattern","rgbPattern","namedColors","isHex","isRgb","isNamed","normalizePositiveNumber","normalizeBaseFields","raw","info","base","timestamp","random","BASE_DEFAULTS","normalizeQuad","quad","normalizeHighlight","annotation","HIGHLIGHT_DEFAULTS","idx","defaultColor","normalizeText","TEXT_DEFAULTS","defaultBg","normalizeAnnotation","index","type","normalizeAnnotationArray","rawAnnotations","options","warnInConsole","onWarning","result","warning","normalized","s","w","i"],"mappings":"iHAsCO,SAASA,EAAoBC,EAAOC,EAAcC,EAAIC,EAAWC,EAAU,CAEhF,IAAIC,EAAWL,EASf,OARI,OAAOA,GAAU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AW,QAAQ,EAAE,EAGhE,MACF,CAGAF,EAAO,WAAW,KAAKE,EAAW,UAAU,EAG5CF,EAAO,SAAS,KAAK,GAAGE,EAAW,QAAQ,EAC3CF,EAAO,KAAK,KAAK,GAAGE,EAAW,IAAI,CACrC,CAAC,EAGGJ,IACEE,EAAO,SAAS,OAAS,GAAKA,EAAO,KAAK,OAAS,GAAKA,EAAO,QAAQ,OAAS,KAClF,QAAQ,MAAM,4CAA4C,EAEtDA,EAAO,WAAW,OAAS,GAC7B,QAAQ,KAAK,gBAAgBA,EAAO,WAAW,MAAM,gBAAgB,EAGnEA,EAAO,QAAQ,OAAS,IAC1B,QAAQ,MAAM,aAAaA,EAAO,QAAQ,MAAM,gBAAgB,EAChEA,EAAO,QAAQ,QAAQG,GAAK,CAC1B,QAAQ,MAAM,WAAWA,EAAE,KAAK,KAAKA,EAAE,MAAM,EAAE,CACjD,CAAC,GAGCH,EAAO,SAAS,OAAS,IAC3B,QAAQ,KAAK,KAAKA,EAAO,SAAS,MAAM,cAAc,EACtDA,EAAO,SAAS,QAAQI,GAAK,QAAQ,KAAK,KAAKA,CAAC,EAAE,CAAC,GAGjDJ,EAAO,KAAK,OAAS,IACvB,QAAQ,KAAK,KAAKA,EAAO,KAAK,MAAM,mBAAmB,EACvDA,EAAO,KAAK,QAAQK,GAAK,QAAQ,KAAK,KAAKA,CAAC,EAAE,CAAC,GAGjD,QAAQ,SAAQ,GAKhBN,GAAa,OAAOA,GAAc,YACpCA,EAAUC,CAAM,EAGXA,CACT"}
package/dist/index10.js CHANGED
@@ -1,23 +1,178 @@
1
- const i = (h, t) => ({
2
- left: h.x * t.width,
3
- top: h.y * t.height,
4
- width: (h.w ?? 0) * t.width,
5
- height: (h.h ?? 0) * t.height
6
- }), e = (h, t) => ({
7
- left: h.x * t.width,
8
- top: h.y * t.height,
9
- width: (h.w ?? 0) * t.width,
10
- height: (h.h ?? 0) * t.height
11
- });
12
- function o(h, t) {
1
+ import { HIGHLIGHT_DEFAULTS as u, TEXT_DEFAULTS as a, BASE_DEFAULTS as f } from "./index22.js";
2
+ function d(n, e, i, s, t) {
3
+ let o = n;
4
+ return typeof n == "string" && (o = parseFloat(n)), typeof o != "number" || isNaN(o) ? (t.push(
5
+ `[${i}]: Field "${s}" invalid value "${n}", using default ${e}`
6
+ ), e) : o < 0 ? (t.push(
7
+ `[${i}]: Field "${s}" value ${o} below range [0,1], clamping to 0`
8
+ ), 0) : o > 1 ? (t.push(
9
+ `[${i}]: Field "${s}" value ${o} exceeds range [0,1], clamping to 1`
10
+ ), 1) : o;
11
+ }
12
+ function c(n, e, i, s) {
13
+ if (typeof n != "string" || n.trim().length === 0)
14
+ return s.push(
15
+ `[${i}]: Invalid color format "${n}", using default ${e}`
16
+ ), e;
17
+ const t = n.trim(), o = /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/, l = /^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(,\s*[\d.]+\s*)?\)$/, r = [
18
+ "red",
19
+ "blue",
20
+ "green",
21
+ "yellow",
22
+ "black",
23
+ "white",
24
+ "gray",
25
+ "grey",
26
+ "orange",
27
+ "purple",
28
+ "pink",
29
+ "brown",
30
+ "transparent"
31
+ ], p = o.test(t), g = l.test(t), m = r.includes(t.toLowerCase());
32
+ return p || g || m ? t : (s.push(
33
+ `[${i}]: Invalid color format "${n}", using default ${e}`
34
+ ), e);
35
+ }
36
+ function x(n, e, i, s, t) {
37
+ let o = n;
38
+ return typeof n == "string" && (o = parseFloat(n)), typeof o != "number" || isNaN(o) || o <= 0 ? (t.push(
39
+ `[${i}]: Field "${s}" invalid value "${n}", using default ${e}`
40
+ ), e) : o;
41
+ }
42
+ function y(n, e, i) {
43
+ const s = {};
44
+ if (typeof n.id != "string" || n.id.trim().length === 0) {
45
+ const t = Date.now(), o = Math.random().toString(36).substr(2, 9);
46
+ s.id = `anno-${t}-${o}`, i.push(`[${s.id}]: Auto-generated ID (original was missing or invalid)`);
47
+ } else
48
+ s.id = n.id.trim();
49
+ return s.type = n.type, typeof n.page != "number" || n.page < 1 ? (e.push(
50
+ `[${s.id}]: Field "page" invalid value "${n.page}", using default ${f.page}`
51
+ ), s.page = f.page) : s.page = Math.floor(n.page), typeof n.start != "number" || n.start < 0 ? (e.push(
52
+ `[${s.id}]: Field "start" invalid value "${n.start}", using default ${f.start}`
53
+ ), s.start = f.start) : s.start = n.start, typeof n.end != "number" || n.end < 0 ? (e.push(
54
+ `[${s.id}]: Field "end" invalid value "${n.end}", using start value ${s.start}`
55
+ ), s.end = s.start) : n.end < s.start ? (e.push(
56
+ `[${s.id}]: Field "end" (${n.end}) less than start (${s.start}), clamping to start`
57
+ ), s.end = s.start) : s.end = n.end, s;
58
+ }
59
+ function h(n, e, i) {
60
+ return !n || typeof n != "object" ? (i.push(`[${e}]: Invalid quad object, using default`), { x: 0.1, y: 0.1, w: 0.8, h: 0.05 }) : {
61
+ x: d(n.x, 0.1, e, "quad.x", i),
62
+ y: d(n.y, 0.1, e, "quad.y", i),
63
+ w: d(n.w, 0.8, e, "quad.w", i),
64
+ h: d(n.h, 0.05, e, "quad.h", i)
65
+ };
66
+ }
67
+ function $(n, e, i, s) {
68
+ const t = { ...n };
69
+ e.mode !== "quads" ? (i.push(
70
+ `[${n.id}]: Field "mode" invalid value "${e.mode}", using default "${u.mode}"`
71
+ ), t.mode = u.mode) : t.mode = e.mode, !Array.isArray(e.quads) || e.quads.length === 0 ? (i.push(
72
+ `[${n.id}]: Field "quads" missing or empty, using default`
73
+ ), t.quads = u.quads) : t.quads = e.quads.map((l, r) => h(l, n.id, i));
74
+ const o = u.style.color;
75
+ return !e.style || typeof e.style != "object" ? (i.push(
76
+ `[${n.id}]: Field "style" missing or invalid, using default`
77
+ ), t.style = { color: o }) : t.style = {
78
+ color: c(e.style.color, o, n.id, i)
79
+ }, t;
80
+ }
81
+ function A(n, e, i, s) {
82
+ const t = { ...n };
83
+ typeof e.content != "string" || e.content.trim().length === 0 ? (i.push(
84
+ `[${n.id}]: Field "content" missing or empty, using default "${a.content}"`
85
+ ), t.content = a.content) : t.content = e.content, t.x = d(e.x, a.x, n.id, "x", i), t.y = d(e.y, a.y, n.id, "y", i), t.w = d(e.w, a.w, n.id, "w", i), t.h = d(e.h, a.h, n.id, "h", i);
86
+ const o = a.style.bg, l = a.style.color;
87
+ return !e.style || typeof e.style != "object" ? (i.push(
88
+ `[${n.id}]: Field "style" missing or invalid, using defaults`
89
+ ), t.style = {
90
+ bg: o,
91
+ color: l
92
+ }) : t.style = {
93
+ bg: c(e.style.bg, o, n.id, i),
94
+ color: c(e.style.color, l, n.id, i)
95
+ }, t;
96
+ }
97
+ function F(n, e) {
98
+ const i = [], s = [];
99
+ if (!n || typeof n != "object")
100
+ return {
101
+ annotation: null,
102
+ warnings: [],
103
+ info: [],
104
+ critical: `Annotation at index ${e}: Not a valid object`
105
+ };
106
+ if (typeof n.type != "string" || n.type.trim().length === 0)
107
+ return {
108
+ annotation: null,
109
+ warnings: [],
110
+ info: [],
111
+ critical: `Annotation at index ${e}: Missing or invalid type field`
112
+ };
113
+ const t = n.type.trim(), o = y(n, i, s);
114
+ let l;
115
+ if (t === "highlight")
116
+ l = $(o, n, i);
117
+ else if (t === "text")
118
+ l = A(o, n, i);
119
+ else
120
+ return {
121
+ annotation: null,
122
+ warnings: [],
123
+ info: [],
124
+ critical: `Annotation at index ${e}: Unsupported type "${t}"`
125
+ };
13
126
  return {
14
- x: h.x * t.width,
15
- y: h.y * t.height
127
+ annotation: l,
128
+ warnings: i,
129
+ info: s,
130
+ critical: null
131
+ };
132
+ }
133
+ function v(n, e = {}) {
134
+ e.skipInvalid;
135
+ const i = e.warnInConsole !== !1, s = e.onWarning || null, t = {
136
+ normalized: [],
137
+ warnings: [],
138
+ info: [],
139
+ skipped: []
16
140
  };
141
+ if (!Array.isArray(n)) {
142
+ const o = "normalizeAnnotationArray: Input is not an array, returning empty result";
143
+ return t.warnings.push(o), i && console.warn(`[Annotation Normalizer] ${o}`), t;
144
+ }
145
+ return n.forEach((o, l) => {
146
+ if (o == null) {
147
+ t.skipped.push({
148
+ index: l,
149
+ annotation: o,
150
+ reason: "Annotation is null or undefined"
151
+ });
152
+ return;
153
+ }
154
+ const r = F(o, l);
155
+ if (r.critical) {
156
+ t.skipped.push({
157
+ index: l,
158
+ annotation: o,
159
+ reason: r.critical
160
+ }), i && console.error(`[Annotation Normalizer] ${r.critical}`);
161
+ return;
162
+ }
163
+ t.normalized.push(r.annotation), t.warnings.push(...r.warnings), t.info.push(...r.info);
164
+ }), i && (t.warnings.length > 0 || t.info.length > 0 || t.skipped.length > 0) && (console.group("[Annotation Normalizer] Validation Summary"), t.normalized.length > 0 && console.info(`✓ Normalized ${t.normalized.length} annotation(s)`), t.skipped.length > 0 && (console.error(`✗ Skipped ${t.skipped.length} annotation(s)`), t.skipped.forEach((o) => {
165
+ console.error(` Index ${o.index}: ${o.reason}`);
166
+ })), t.warnings.length > 0 && (console.warn(`⚠ ${t.warnings.length} warning(s):`), t.warnings.forEach((o) => console.warn(` ${o}`))), t.info.length > 0 && (console.info(`ℹ ${t.info.length} info message(s):`), t.info.forEach((o) => console.info(` ${o}`))), console.groupEnd()), s && typeof s == "function" && s(t), t;
17
167
  }
18
168
  export {
19
- e as NormSizeToPixel,
20
- o as pointNormToAbs,
21
- i as rectNormToAbs
169
+ F as normalizeAnnotation,
170
+ v as normalizeAnnotationArray,
171
+ y as normalizeBaseFields,
172
+ c as normalizeColor,
173
+ d as normalizeCoordinate,
174
+ $ as normalizeHighlight,
175
+ x as normalizePositiveNumber,
176
+ A as normalizeText
22
177
  };
23
178
  //# sourceMappingURL=index10.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index10.js","sources":["../src/utils/coordinateUtils.js"],"sourcesContent":["/**\n * Coordinate Utility Functions\n *\n * This module provides utility functions for coordinate transformations\n * between normalized (0-1) coordinates and absolute pixel coordinates.\n * Used by annotation layers to position elements on the PDF canvas.\n */\n\n/**\n * Convert normalized rectangle to absolute pixel coordinates\n *\n * Transforms a rectangle with normalized coordinates (0-1 range) to\n * absolute pixel coordinates based on viewport dimensions.\n *\n * @param {{x: number, y: number, w: number, h: number}} rect - Normalized rectangle (0-1)\n * @param {{width: number, height: number}} viewport - Viewport dimensions in pixels\n * @returns {{left: number, top: number, width: number, height: number}} Absolute coordinates in pixels\n *\n * @example\n * const rect = { x: 0.1, y: 0.2, w: 0.5, h: 0.3 };\n * const viewport = { width: 1000, height: 1400 };\n * const absolute = rectNormToAbs(rect, viewport);\n * // Returns: { left: 100, top: 280, width: 500, height: 420 }\n */\nexport const rectNormToAbs = (r, vp) => ({\n left: r.x * vp.width,\n top: r.y * vp.height,\n width: (r.w ?? 0) * vp.width,\n height: (r.h ?? 0) * vp.height,\n});\n\n/**\n * Convert normalized size to pixel dimensions (Legacy)\n *\n * @deprecated Use rectNormToAbs instead. This function is kept for backward compatibility.\n *\n * Transforms normalized rectangle coordinates to absolute pixel coordinates.\n * This is an alias for rectNormToAbs maintained for backward compatibility.\n *\n * @param {{x: number, y: number, w: number, h: number}} r - Normalized rectangle (0-1)\n * @param {{width: number, height: number}} vp - Viewport dimensions in pixels\n * @returns {{left: number, top: number, width: number, height: number}} Absolute coordinates in pixels\n */\nexport const NormSizeToPixel = (r, vp) => ({\n left: r.x * vp.width,\n top: r.y * vp.height,\n width: (r.w ?? 0) * vp.width,\n height: (r.h ?? 0) * vp.height,\n});\n\n/**\n * Convert normalized point to absolute pixel coordinates\n *\n * Transforms a point with normalized coordinates (0-1 range) to\n * absolute pixel coordinates based on viewport dimensions.\n *\n * @param {{x: number, y: number}} point - Normalized point (0-1)\n * @param {{width: number, height: number}} viewport - Viewport dimensions in pixels\n * @returns {{x: number, y: number}} Absolute coordinates in pixels\n *\n * @example\n * const point = { x: 0.5, y: 0.5 };\n * const viewport = { width: 1000, height: 1400 };\n * const absolute = pointNormToAbs(point, viewport);\n * // Returns: { x: 500, y: 700 }\n */\nexport function pointNormToAbs(point, viewport) {\n return {\n x: point.x * viewport.width,\n y: point.y * viewport.height\n };\n}\n"],"names":["rectNormToAbs","r","vp","NormSizeToPixel","pointNormToAbs","point","viewport"],"mappings":"AAwBY,MAACA,IAAgB,CAACC,GAAGC,OAAQ;AAAA,EACvC,MAAMD,EAAE,IAAIC,EAAG;AAAA,EACf,KAAKD,EAAE,IAAIC,EAAG;AAAA,EACd,QAAQD,EAAE,KAAK,KAAKC,EAAG;AAAA,EACvB,SAASD,EAAE,KAAK,KAAKC,EAAG;AAC1B,IAcaC,IAAkB,CAACF,GAAGC,OAAQ;AAAA,EACzC,MAAMD,EAAE,IAAIC,EAAG;AAAA,EACf,KAAKD,EAAE,IAAIC,EAAG;AAAA,EACd,QAAQD,EAAE,KAAK,KAAKC,EAAG;AAAA,EACvB,SAASD,EAAE,KAAK,KAAKC,EAAG;AAC1B;AAkBO,SAASE,EAAeC,GAAOC,GAAU;AAC9C,SAAO;AAAA,IACL,GAAGD,EAAM,IAAIC,EAAS;AAAA,IACtB,GAAGD,EAAM,IAAIC,EAAS;AAAA,EAC1B;AACA;"}
1
+ {"version":3,"file":"index10.js","sources":["../src/types/validators.js"],"sourcesContent":["/**\n * Annotation Data Normalization Utilities\n *\n * This module provides defensive normalization functions that validate and fix\n * annotation data. Invalid values are replaced with safe defaults and warnings\n * are collected for user feedback.\n *\n * @module types/validators\n */\n\nimport {\n BASE_DEFAULTS,\n HIGHLIGHT_DEFAULTS,\n TEXT_DEFAULTS\n} from './defaults.js';\n\n// ============================================================================\n// FIELD-LEVEL NORMALIZERS\n// ============================================================================\n\n/**\n * Normalize coordinate value to 0-1 range\n *\n * Validates that a value is a number in the 0-1 range. Out-of-range values\n * are clamped. Invalid values use the provided default.\n *\n * @param {*} value - Value to normalize\n * @param {number} defaultValue - Fallback value if invalid\n * @param {string} id - Annotation ID for warning messages\n * @param {string} fieldName - Field name for warning messages\n * @param {Array<string>} warnings - Array to collect warning messages\n * @returns {number} Normalized coordinate value in range [0, 1]\n *\n * @example\n * normalizeCoordinate(0.5, 0.1, 'txt-1', 'x', warnings) // Returns: 0.5\n * normalizeCoordinate(5, 0.1, 'txt-1', 'x', warnings) // Returns: 1, adds warning\n * normalizeCoordinate('abc', 0.1, 'txt-1', 'x', warnings) // Returns: 0.1, adds warning\n */\nexport function normalizeCoordinate(value, defaultValue, id, fieldName, warnings) {\n // Type coercion: parse string to number if needed\n let numValue = value;\n if (typeof value === 'string') {\n numValue = parseFloat(value);\n if (!isNaN(numValue) && numValue === value) {\n // Successfully parsed - no warning needed\n }\n }\n\n // Validate is valid number\n if (typeof numValue !== 'number' || isNaN(numValue)) {\n warnings.push(\n `[${id}]: Field \"${fieldName}\" invalid value \"${value}\", using default ${defaultValue}`\n );\n return defaultValue;\n }\n\n // Range check: clamp to [0, 1]\n if (numValue < 0) {\n warnings.push(\n `[${id}]: Field \"${fieldName}\" value ${numValue} below range [0,1], clamping to 0`\n );\n return 0;\n }\n\n if (numValue > 1) {\n warnings.push(\n `[${id}]: Field \"${fieldName}\" value ${numValue} exceeds range [0,1], clamping to 1`\n );\n return 1;\n }\n\n // Valid value\n return numValue;\n}\n\n/**\n * Normalize color string\n *\n * Validates that a value is a valid color string. Supports hex, rgb/rgba,\n * and named colors. Invalid colors use the provided default.\n *\n * @param {*} value - Color value to normalize\n * @param {string} defaultValue - Fallback color if invalid\n * @param {string} id - Annotation ID for warning messages\n * @param {Array<string>} warnings - Array to collect warning messages\n * @returns {string} Valid color string\n *\n * @example\n * normalizeColor('#fff', '#000', 'txt-1', warnings) // Returns: '#fff'\n * normalizeColor('rgba(255,0,0,0.5)', '#000', 'txt-1', warnings) // Returns: 'rgba(255,0,0,0.5)'\n * normalizeColor('notacolor', '#000', 'txt-1', warnings) // Returns: '#000', adds warning\n */\nexport function normalizeColor(value, defaultValue, id, warnings) {\n // Type check: must be non-empty string\n if (typeof value !== 'string' || value.trim().length === 0) {\n warnings.push(\n `[${id}]: Invalid color format \"${value}\", using default ${defaultValue}`\n );\n return defaultValue;\n }\n\n const trimmed = value.trim();\n\n // Regex patterns for color validation (cached at module level)\n const hexPattern = /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;\n const rgbPattern = /^rgba?\\(\\s*\\d+\\s*,\\s*\\d+\\s*,\\s*\\d+\\s*(,\\s*[\\d.]+\\s*)?\\)$/;\n\n // Named colors (basic set)\n const namedColors = [\n 'red', 'blue', 'green', 'yellow', 'black', 'white', 'gray',\n 'grey', 'orange', 'purple', 'pink', 'brown', 'transparent'\n ];\n\n // Validate format\n const isHex = hexPattern.test(trimmed);\n const isRgb = rgbPattern.test(trimmed);\n const isNamed = namedColors.includes(trimmed.toLowerCase());\n\n if (isHex || isRgb || isNamed) {\n return trimmed;\n }\n\n // Invalid format\n warnings.push(\n `[${id}]: Invalid color format \"${value}\", using default ${defaultValue}`\n );\n return defaultValue;\n}\n\n/**\n * Normalize positive number\n *\n * Validates that a value is a positive number. Invalid values use the\n * provided default.\n *\n * @param {*} value - Value to normalize\n * @param {number} defaultValue - Fallback value if invalid\n * @param {string} id - Annotation ID for warning messages\n * @param {string} fieldName - Field name for warning messages\n * @param {Array<string>} warnings - Array to collect warning messages\n * @returns {number} Positive number\n *\n * @example\n * normalizePositiveNumber(5, 3, 'ink-1', 'size', warnings) // Returns: 5\n * normalizePositiveNumber(-1, 3, 'ink-1', 'size', warnings) // Returns: 3, adds warning\n * normalizePositiveNumber('abc', 3, 'ink-1', 'size', warnings) // Returns: 3, adds warning\n */\nexport function normalizePositiveNumber(value, defaultValue, id, fieldName, warnings) {\n // Type coercion: parse string to number if needed\n let numValue = value;\n if (typeof value === 'string') {\n numValue = parseFloat(value);\n }\n\n // Validate is valid number and positive\n if (typeof numValue !== 'number' || isNaN(numValue) || numValue <= 0) {\n warnings.push(\n `[${id}]: Field \"${fieldName}\" invalid value \"${value}\", using default ${defaultValue}`\n );\n return defaultValue;\n }\n\n return numValue;\n}\n\n// ============================================================================\n// BASE FIELDS NORMALIZER\n// ============================================================================\n\n/**\n * Normalize common base annotation fields\n *\n * Validates and normalizes fields common to all annotation types: id, type,\n * page, start, and end. Auto-generates ID if missing. Applies safe defaults\n * for invalid values.\n *\n * @param {Object} raw - Raw annotation object\n * @param {Array<string>} warnings - Array to collect warning messages\n * @param {Array<string>} info - Array to collect info messages\n * @returns {Object} Object with normalized base fields\n *\n * @example\n * normalizeBaseFields({ type: 'text', page: 2 }, warnings, info)\n * // Returns: { id: 'anno-1234...', type: 'text', page: 2, start: 0, end: 0 }\n */\nexport function normalizeBaseFields(raw, warnings, info) {\n const base = {};\n\n // ===== ID Field =====\n // Check: non-empty string\n // Invalid: auto-generate unique ID\n if (typeof raw.id !== 'string' || raw.id.trim().length === 0) {\n const timestamp = Date.now();\n const random = Math.random().toString(36).substr(2, 9);\n base.id = `anno-${timestamp}-${random}`;\n info.push(`[${base.id}]: Auto-generated ID (original was missing or invalid)`);\n } else {\n base.id = raw.id.trim();\n }\n\n // ===== Type Field =====\n // Pass through as-is (validated in parent function)\n base.type = raw.type;\n\n // ===== Page Field =====\n // Check: positive integer\n // Invalid: default to 1\n if (typeof raw.page !== 'number' || raw.page < 1) {\n warnings.push(\n `[${base.id}]: Field \"page\" invalid value \"${raw.page}\", using default ${BASE_DEFAULTS.page}`\n );\n base.page = BASE_DEFAULTS.page;\n } else {\n // Floor to ensure integer\n base.page = Math.floor(raw.page);\n }\n\n // ===== Start Field =====\n // Check: non-negative number\n // Invalid: default to 0\n if (typeof raw.start !== 'number' || raw.start < 0) {\n warnings.push(\n `[${base.id}]: Field \"start\" invalid value \"${raw.start}\", using default ${BASE_DEFAULTS.start}`\n );\n base.start = BASE_DEFAULTS.start;\n } else {\n base.start = raw.start;\n }\n\n // ===== End Field =====\n // Check: non-negative number >= start\n // Invalid: clamp to start value\n if (typeof raw.end !== 'number' || raw.end < 0) {\n warnings.push(\n `[${base.id}]: Field \"end\" invalid value \"${raw.end}\", using start value ${base.start}`\n );\n base.end = base.start;\n } else if (raw.end < base.start) {\n warnings.push(\n `[${base.id}]: Field \"end\" (${raw.end}) less than start (${base.start}), clamping to start`\n );\n base.end = base.start;\n } else {\n base.end = raw.end;\n }\n\n return base;\n}\n\n// ============================================================================\n// TYPE-SPECIFIC NORMALIZERS\n// ============================================================================\n\n/**\n * Normalize a single quad (rectangular region)\n *\n * @private\n * @param {Object} quad - Quad object with x, y, w, h\n * @param {string} id - Annotation ID\n * @param {Array<string>} warnings - Warnings array\n * @returns {Object} Normalized quad\n */\nfunction normalizeQuad(quad, id, warnings) {\n if (!quad || typeof quad !== 'object') {\n warnings.push(`[${id}]: Invalid quad object, using default`);\n return { x: 0.1, y: 0.1, w: 0.8, h: 0.05 };\n }\n\n return {\n x: normalizeCoordinate(quad.x, 0.1, id, 'quad.x', warnings),\n y: normalizeCoordinate(quad.y, 0.1, id, 'quad.y', warnings),\n w: normalizeCoordinate(quad.w, 0.8, id, 'quad.w', warnings),\n h: normalizeCoordinate(quad.h, 0.05, id, 'quad.h', warnings)\n };\n}\n\n/**\n * Normalize highlight annotation\n *\n * Validates and normalizes highlight-specific fields: mode, quads array,\n * and style.color. Applies defaults for invalid fields.\n *\n * @param {Object} base - Object with normalized base fields\n * @param {Object} raw - Raw annotation object\n * @param {Array<string>} warnings - Warnings array\n * @param {Array<string>} info - Info array\n * @returns {Object} Fully normalized highlight annotation\n *\n * @example\n * normalizeHighlight(base, raw, warnings, info)\n * // Returns: { ...base, mode: 'quads', quads: [...], style: {...} }\n */\nexport function normalizeHighlight(base, raw, warnings, info) {\n const annotation = { ...base };\n\n // ===== Mode Field =====\n // Check: value equals \"quads\"\n // Invalid: default to \"quads\"\n if (raw.mode !== 'quads') {\n warnings.push(\n `[${base.id}]: Field \"mode\" invalid value \"${raw.mode}\", using default \"${HIGHLIGHT_DEFAULTS.mode}\"`\n );\n annotation.mode = HIGHLIGHT_DEFAULTS.mode;\n } else {\n annotation.mode = raw.mode;\n }\n\n // ===== Quads Array =====\n // Check: non-empty array\n // Invalid: use default quads\n if (!Array.isArray(raw.quads) || raw.quads.length === 0) {\n warnings.push(\n `[${base.id}]: Field \"quads\" missing or empty, using default`\n );\n annotation.quads = HIGHLIGHT_DEFAULTS.quads;\n } else {\n // Normalize each quad\n annotation.quads = raw.quads.map((quad, idx) => normalizeQuad(quad, base.id, warnings));\n }\n\n // ===== Style Object =====\n // Check: object with color property\n const defaultColor = HIGHLIGHT_DEFAULTS.style.color;\n if (!raw.style || typeof raw.style !== 'object') {\n warnings.push(\n `[${base.id}]: Field \"style\" missing or invalid, using default`\n );\n annotation.style = { color: defaultColor };\n } else {\n annotation.style = {\n color: normalizeColor(raw.style.color, defaultColor, base.id, warnings)\n };\n }\n\n return annotation;\n}\n\n/**\n * Normalize text annotation\n *\n * Validates and normalizes text-specific fields: content, position (x, y),\n * dimensions (w, h), and style (bg, color). Applies defaults for invalid fields.\n *\n * @param {Object} base - Object with normalized base fields\n * @param {Object} raw - Raw annotation object\n * @param {Array<string>} warnings - Warnings array\n * @param {Array<string>} info - Info array\n * @returns {Object} Fully normalized text annotation\n *\n * @example\n * normalizeText(base, raw, warnings, info)\n * // Returns: { ...base, content: '...', x: 0.1, y: 0.1, w: 0.3, h: 0.1, style: {...} }\n */\nexport function normalizeText(base, raw, warnings, info) {\n const annotation = { ...base };\n\n // ===== Content Field =====\n // Check: non-empty string\n // Invalid: default to placeholder\n if (typeof raw.content !== 'string' || raw.content.trim().length === 0) {\n warnings.push(\n `[${base.id}]: Field \"content\" missing or empty, using default \"${TEXT_DEFAULTS.content}\"`\n );\n annotation.content = TEXT_DEFAULTS.content;\n } else {\n annotation.content = raw.content;\n }\n\n // ===== Position Fields (x, y) =====\n annotation.x = normalizeCoordinate(raw.x, TEXT_DEFAULTS.x, base.id, 'x', warnings);\n annotation.y = normalizeCoordinate(raw.y, TEXT_DEFAULTS.y, base.id, 'y', warnings);\n\n // ===== Dimension Fields (w, h) =====\n annotation.w = normalizeCoordinate(raw.w, TEXT_DEFAULTS.w, base.id, 'w', warnings);\n annotation.h = normalizeCoordinate(raw.h, TEXT_DEFAULTS.h, base.id, 'h', warnings);\n\n // ===== Style Object =====\n const defaultBg = TEXT_DEFAULTS.style.bg;\n const defaultColor = TEXT_DEFAULTS.style.color;\n\n if (!raw.style || typeof raw.style !== 'object') {\n warnings.push(\n `[${base.id}]: Field \"style\" missing or invalid, using defaults`\n );\n annotation.style = {\n bg: defaultBg,\n color: defaultColor\n };\n } else {\n annotation.style = {\n bg: normalizeColor(raw.style.bg, defaultBg, base.id, warnings),\n color: normalizeColor(raw.style.color, defaultColor, base.id, warnings)\n };\n }\n\n return annotation;\n}\n\n// ============================================================================\n// ORCHESTRATION - SINGLE ANNOTATION & ARRAY\n// ============================================================================\n\n/**\n * Normalize a single annotation\n *\n * Routes annotation to appropriate type-specific normalizer based on type field.\n * Handles critical validation errors (missing/invalid type).\n *\n * @param {Object} raw - Raw annotation object\n * @param {number} index - Position in original array (for error context)\n * @returns {Object} Result object with annotation, warnings, info, and critical error\n * @returns {Object|null} return.annotation - Normalized annotation or null if critical error\n * @returns {Array<string>} return.warnings - Warning messages\n * @returns {Array<string>} return.info - Info messages\n * @returns {string|null} return.critical - Critical error message or null\n *\n * @example\n * normalizeAnnotation({ type: 'text', content: 'Hello' }, 0)\n * // Returns: { annotation: {...}, warnings: [], info: [], critical: null }\n */\nexport function normalizeAnnotation(raw, index) {\n const warnings = [];\n const info = [];\n\n // Validate input is object\n if (!raw || typeof raw !== 'object') {\n return {\n annotation: null,\n warnings: [],\n info: [],\n critical: `Annotation at index ${index}: Not a valid object`\n };\n }\n\n // Check type field (critical - cannot route without type)\n if (typeof raw.type !== 'string' || raw.type.trim().length === 0) {\n return {\n annotation: null,\n warnings: [],\n info: [],\n critical: `Annotation at index ${index}: Missing or invalid type field`\n };\n }\n\n const type = raw.type.trim();\n\n // Normalize base fields first\n const base = normalizeBaseFields(raw, warnings, info);\n\n // Route to type-specific normalizer\n let annotation;\n\n if (type === 'highlight') {\n annotation = normalizeHighlight(base, raw, warnings, info);\n } else if (type === 'text') {\n annotation = normalizeText(base, raw, warnings, info);\n } else {\n return {\n annotation: null,\n warnings: [],\n info: [],\n critical: `Annotation at index ${index}: Unsupported type \"${type}\"`\n };\n }\n\n return {\n annotation,\n warnings,\n info,\n critical: null\n };\n}\n\n/**\n * Normalize array of annotations\n *\n * MAIN ENTRY POINT for annotation normalization. Processes each annotation,\n * collects warnings, and returns normalized data ready for rendering.\n *\n * @param {Array} rawAnnotations - Array of raw annotation objects\n * @param {Object} [options] - Configuration options\n * @param {boolean} [options.skipInvalid=true] - Skip critically invalid annotations\n * @param {boolean} [options.warnInConsole=true] - Log warnings to console\n * @param {Function} [options.onWarning] - Custom warning callback\n * @returns {Object} ValidationResult with normalized annotations and messages\n * @returns {Array} return.normalized - Successfully normalized annotations\n * @returns {Array<string>} return.warnings - Warning messages\n * @returns {Array<string>} return.info - Informational messages\n * @returns {Array<Object>} return.skipped - Skipped annotations with reasons\n *\n * @example\n * const result = normalizeAnnotationArray(rawAnnotations, {\n * skipInvalid: true,\n * warnInConsole: true\n * });\n *\n * renderer.setAnnotations(result.normalized);\n */\nexport function normalizeAnnotationArray(rawAnnotations, options = {}) {\n // Default options\n const skipInvalid = options.skipInvalid !== false; // Default: true\n const warnInConsole = options.warnInConsole !== false; // Default: true\n const onWarning = options.onWarning || null;\n\n // Initialize result structure\n const result = {\n normalized: [],\n warnings: [],\n info: [],\n skipped: []\n };\n\n // Validate input is array\n if (!Array.isArray(rawAnnotations)) {\n const warning = 'normalizeAnnotationArray: Input is not an array, returning empty result';\n result.warnings.push(warning);\n\n if (warnInConsole) {\n console.warn(`[Annotation Normalizer] ${warning}`);\n }\n\n return result;\n }\n\n // Process each annotation\n rawAnnotations.forEach((raw, index) => {\n // Skip null/undefined\n if (raw == null) {\n result.skipped.push({\n index,\n annotation: raw,\n reason: 'Annotation is null or undefined'\n });\n return;\n }\n\n // Normalize annotation\n const normalized = normalizeAnnotation(raw, index);\n\n // Check for critical error\n if (normalized.critical) {\n result.skipped.push({\n index,\n annotation: raw,\n reason: normalized.critical\n });\n\n if (warnInConsole) {\n console.error(`[Annotation Normalizer] ${normalized.critical}`);\n }\n\n return;\n }\n\n // Add to normalized array\n result.normalized.push(normalized.annotation);\n\n // Collect warnings and info\n result.warnings.push(...normalized.warnings);\n result.info.push(...normalized.info);\n });\n\n // Console output\n if (warnInConsole) {\n if (result.warnings.length > 0 || result.info.length > 0 || result.skipped.length > 0) {\n console.group('[Annotation Normalizer] Validation Summary');\n\n if (result.normalized.length > 0) {\n console.info(`✓ Normalized ${result.normalized.length} annotation(s)`);\n }\n\n if (result.skipped.length > 0) {\n console.error(`✗ Skipped ${result.skipped.length} annotation(s)`);\n result.skipped.forEach(s => {\n console.error(` Index ${s.index}: ${s.reason}`);\n });\n }\n\n if (result.warnings.length > 0) {\n console.warn(`⚠ ${result.warnings.length} warning(s):`);\n result.warnings.forEach(w => console.warn(` ${w}`));\n }\n\n if (result.info.length > 0) {\n console.info(`ℹ ${result.info.length} info message(s):`);\n result.info.forEach(i => console.info(` ${i}`));\n }\n\n console.groupEnd();\n }\n }\n\n // Call custom warning handler\n if (onWarning && typeof onWarning === 'function') {\n onWarning(result);\n }\n\n return result;\n}\n"],"names":["normalizeCoordinate","value","defaultValue","id","fieldName","warnings","numValue","normalizeColor","trimmed","hexPattern","rgbPattern","namedColors","isHex","isRgb","isNamed","normalizePositiveNumber","normalizeBaseFields","raw","info","base","timestamp","random","BASE_DEFAULTS","normalizeQuad","quad","normalizeHighlight","annotation","HIGHLIGHT_DEFAULTS","idx","defaultColor","normalizeText","TEXT_DEFAULTS","defaultBg","normalizeAnnotation","index","type","normalizeAnnotationArray","rawAnnotations","options","warnInConsole","onWarning","result","warning","normalized","s","w","i"],"mappings":";AAsCO,SAASA,EAAoBC,GAAOC,GAAcC,GAAIC,GAAWC,GAAU;AAEhF,MAAIC,IAAWL;AASf,SARI,OAAOA,KAAU,aACnBK,IAAW,WAAWL,CAAK,IAOzB,OAAOK,KAAa,YAAY,MAAMA,CAAQ,KAChDD,EAAS;AAAA,IACP,IAAIF,CAAE,a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AAKA,EAAO,KAAK,MAAM,mBAAmB,GACvDA,EAAO,KAAK,QAAQ,CAAAK,MAAK,QAAQ,KAAK,KAAKA,CAAC,EAAE,CAAC,IAGjD,QAAQ,SAAQ,IAKhBN,KAAa,OAAOA,KAAc,cACpCA,EAAUC,CAAM,GAGXA;AACT;"}
package/dist/index11.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function n(e,t){if(!e)throw new Error("Page object is required");return e.getViewport({scale:t})}function r(e){return e?{width:e.width,height:e.height}:{width:0,height:0}}function o(e,t,i){return{width:e*i,height:t*i}}exports.calculateScaledDimensions=o;exports.calculateViewport=n;exports.getViewportDimensions=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index10.cjs"),e=require("./index22.cjs");exports.normalizeAnnotation=o.normalizeAnnotation;exports.normalizeAnnotationArray=o.normalizeAnnotationArray;exports.normalizeBaseFields=o.normalizeBaseFields;exports.normalizeColor=o.normalizeColor;exports.normalizeCoordinate=o.normalizeCoordinate;exports.normalizeHighlight=o.normalizeHighlight;exports.normalizePositiveNumber=o.normalizePositiveNumber;exports.normalizeText=o.normalizeText;exports.BASE_DEFAULTS=e.BASE_DEFAULTS;exports.HIGHLIGHT_DEFAULTS=e.HIGHLIGHT_DEFAULTS;exports.TEXT_DEFAULTS=e.TEXT_DEFAULTS;
2
2
  //# sourceMappingURL=index11.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index11.cjs","sources":["../src/utils/viewportUtils.js"],"sourcesContent":["/**\n * Viewport Utility Functions\n *\n * This module provides utility functions for PDF viewport calculations\n * and transformations. These functions are used by the PDF viewer to\n * calculate viewport dimensions and manage scaling.\n */\n\n/**\n * Calculate viewport from PDF page\n *\n * Creates a viewport object from a PDF.js page with the specified scale.\n * The viewport contains dimensions and transformation matrix for rendering.\n *\n * @param {Object} page - PDF.js page object\n * @param {number} scale - Scale factor for rendering\n * @returns {Object} Viewport object with width, height, and transform matrix\n *\n * @example\n * const viewport = calculateViewport(pdfPage, 1.5);\n * // Returns: { width: 1200, height: 1600, scale: 1.5, ... }\n */\nexport function calculateViewport(page, scale) {\n if (!page) {\n throw new Error('Page object is required');\n }\n\n return page.getViewport({ scale });\n}\n\n/**\n * Get viewport dimensions\n *\n * Extracts width and height from a viewport object.\n * Useful for coordinate transformations and layout calculations.\n *\n * @param {Object} viewport - Viewport object from PDF.js\n * @returns {{width: number, height: number}} Dimensions object\n *\n * @example\n * const { width, height } = getViewportDimensions(viewport);\n * // Returns: { width: 1200, height: 1600 }\n */\nexport function getViewportDimensions(viewport) {\n if (!viewport) {\n return { width: 0, height: 0 };\n }\n\n return {\n width: viewport.width,\n height: viewport.height\n };\n}\n\n/**\n * Calculate scaled dimensions\n *\n * Calculates dimensions for a given scale factor.\n * Used when zoom level changes to determine new canvas size.\n *\n * @param {number} baseWidth - Original width\n * @param {number} baseHeight - Original height\n * @param {number} scale - Scale factor\n * @returns {{width: number, height: number}} Scaled dimensions\n *\n * @example\n * const scaled = calculateScaledDimensions(800, 1000, 1.5);\n * // Returns: { width: 1200, height: 1500 }\n */\nexport function calculateScaledDimensions(baseWidth, baseHeight, scale) {\n return {\n width: baseWidth * scale,\n height: baseHeight * scale\n };\n}\n"],"names":["calculateViewport","page","scale","getViewportDimensions","viewport","calculateScaledDimensions","baseWidth","baseHeight"],"mappings":"gFAsBO,SAASA,EAAkBC,EAAMC,EAAO,CAC7C,GAAI,CAACD,EACH,MAAM,IAAI,MAAM,yBAAyB,EAG3C,OAAOA,EAAK,YAAY,CAAE,MAAAC,EAAO,CACnC,CAeO,SAASC,EAAsBC,EAAU,CAC9C,OAAKA,EAIE,CACL,MAAOA,EAAS,MAChB,OAAQA,EAAS,MACrB,EANW,CAAE,MAAO,EAAG,OAAQ,CAAC,CAOhC,CAiBO,SAASC,EAA0BC,EAAWC,EAAYL,EAAO,CACtE,MAAO,CACL,MAAOI,EAAYJ,EACnB,OAAQK,EAAaL,CACzB,CACA"}
1
+ {"version":3,"file":"index11.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/dist/index11.js CHANGED
@@ -1,23 +1,16 @@
1
- function r(t, e) {
2
- if (!t)
3
- throw new Error("Page object is required");
4
- return t.getViewport({ scale: e });
5
- }
6
- function n(t) {
7
- return t ? {
8
- width: t.width,
9
- height: t.height
10
- } : { width: 0, height: 0 };
11
- }
12
- function h(t, e, i) {
13
- return {
14
- width: t * i,
15
- height: e * i
16
- };
17
- }
1
+ import { normalizeAnnotation as e, normalizeAnnotationArray as i, normalizeBaseFields as n, normalizeColor as a, normalizeCoordinate as l, normalizeHighlight as m, normalizePositiveNumber as t, normalizeText as z } from "./index10.js";
2
+ import { BASE_DEFAULTS as T, HIGHLIGHT_DEFAULTS as E, TEXT_DEFAULTS as F } from "./index22.js";
18
3
  export {
19
- h as calculateScaledDimensions,
20
- r as calculateViewport,
21
- n as getViewportDimensions
4
+ T as BASE_DEFAULTS,
5
+ E as HIGHLIGHT_DEFAULTS,
6
+ F as TEXT_DEFAULTS,
7
+ e as normalizeAnnotation,
8
+ i as normalizeAnnotationArray,
9
+ n as normalizeBaseFields,
10
+ a as normalizeColor,
11
+ l as normalizeCoordinate,
12
+ m as normalizeHighlight,
13
+ t as normalizePositiveNumber,
14
+ z as normalizeText
22
15
  };
23
16
  //# sourceMappingURL=index11.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index11.js","sources":["../src/utils/viewportUtils.js"],"sourcesContent":["/**\n * Viewport Utility Functions\n *\n * This module provides utility functions for PDF viewport calculations\n * and transformations. These functions are used by the PDF viewer to\n * calculate viewport dimensions and manage scaling.\n */\n\n/**\n * Calculate viewport from PDF page\n *\n * Creates a viewport object from a PDF.js page with the specified scale.\n * The viewport contains dimensions and transformation matrix for rendering.\n *\n * @param {Object} page - PDF.js page object\n * @param {number} scale - Scale factor for rendering\n * @returns {Object} Viewport object with width, height, and transform matrix\n *\n * @example\n * const viewport = calculateViewport(pdfPage, 1.5);\n * // Returns: { width: 1200, height: 1600, scale: 1.5, ... }\n */\nexport function calculateViewport(page, scale) {\n if (!page) {\n throw new Error('Page object is required');\n }\n\n return page.getViewport({ scale });\n}\n\n/**\n * Get viewport dimensions\n *\n * Extracts width and height from a viewport object.\n * Useful for coordinate transformations and layout calculations.\n *\n * @param {Object} viewport - Viewport object from PDF.js\n * @returns {{width: number, height: number}} Dimensions object\n *\n * @example\n * const { width, height } = getViewportDimensions(viewport);\n * // Returns: { width: 1200, height: 1600 }\n */\nexport function getViewportDimensions(viewport) {\n if (!viewport) {\n return { width: 0, height: 0 };\n }\n\n return {\n width: viewport.width,\n height: viewport.height\n };\n}\n\n/**\n * Calculate scaled dimensions\n *\n * Calculates dimensions for a given scale factor.\n * Used when zoom level changes to determine new canvas size.\n *\n * @param {number} baseWidth - Original width\n * @param {number} baseHeight - Original height\n * @param {number} scale - Scale factor\n * @returns {{width: number, height: number}} Scaled dimensions\n *\n * @example\n * const scaled = calculateScaledDimensions(800, 1000, 1.5);\n * // Returns: { width: 1200, height: 1500 }\n */\nexport function calculateScaledDimensions(baseWidth, baseHeight, scale) {\n return {\n width: baseWidth * scale,\n height: baseHeight * scale\n };\n}\n"],"names":["calculateViewport","page","scale","getViewportDimensions","viewport","calculateScaledDimensions","baseWidth","baseHeight"],"mappings":"AAsBO,SAASA,EAAkBC,GAAMC,GAAO;AAC7C,MAAI,CAACD;AACH,UAAM,IAAI,MAAM,yBAAyB;AAG3C,SAAOA,EAAK,YAAY,EAAE,OAAAC,GAAO;AACnC;AAeO,SAASC,EAAsBC,GAAU;AAC9C,SAAKA,IAIE;AAAA,IACL,OAAOA,EAAS;AAAA,IAChB,QAAQA,EAAS;AAAA,EACrB,IANW,EAAE,OAAO,GAAG,QAAQ,EAAC;AAOhC;AAiBO,SAASC,EAA0BC,GAAWC,GAAYL,GAAO;AACtE,SAAO;AAAA,IACL,OAAOI,IAAYJ;AAAA,IACnB,QAAQK,IAAaL;AAAA,EACzB;AACA;"}
1
+ {"version":3,"file":"index11.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}