@ingcreators/annot-annotator 0.3.0 → 0.6.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.
@@ -16,10 +16,10 @@ import { EncodeResult } from './options.js';
16
16
  * - Sample unique-colour count via {@link isPhotoHeavy}.
17
17
  * If photo-heavy, emit `smartFallback` (PNG-32 or
18
18
  * JPEG) with reason `"photo-fallback-*"`.
19
- * - Otherwise quantize to ≤256 colours via libimagequant
20
- * (if installed) and emit PNG-8 with reason `"png-8"`.
21
- * When the optional imagequant WASM isn't installed,
22
- * fall back to PNG-32 with `reason: "imagequant-missing"`.
19
+ * - Otherwise quantize to ≤256 colours via the
20
+ * in-tree Median Cut + FS dither and emit PNG-8 with
21
+ * reason `"png-8"`. PNG-8 is unconditionally
22
+ * available post-Phase 3 (no optional WASM gate).
23
23
  */
24
24
  export declare function encodeRgba(rgba: Uint8Array, width: number, height: number, options?: EncodeOptions): Promise<EncodeResult>;
25
25
  /**
@@ -1,12 +1,10 @@
1
1
  /**
2
- * Quantize RGBA pixels to ≤256 colours via libimagequant and emit
3
- * a PNG-8 file. Returns the encoded bytes, OR `null` if the
4
- * optional imagequant module isn't installed.
2
+ * Quantize RGBA pixels to ≤256 colours via Median Cut + Floyd–
3
+ * Steinberg dither and emit a PNG-8 file.
5
4
  *
6
- * The caller is responsible for falling back to a non-PNG-8 path
7
- * (PNG-32 or JPEG) when this returns `null`.
5
+ * Synchronous, deterministic, GPL-free.
8
6
  */
9
- export declare function quantizeRgbaToPng8(rgba: Uint8Array, width: number, height: number): Promise<Uint8Array | null>;
7
+ export declare function quantizeRgbaToPng8(rgba: Uint8Array, width: number, height: number): Uint8Array;
10
8
  /**
11
9
  * Heuristic: does this image look photo-heavy?
12
10
  *
@@ -17,7 +15,3 @@ export declare function quantizeRgbaToPng8(rgba: Uint8Array, width: number, heig
17
15
  * colours; pages with rich photography return >20,000.
18
16
  */
19
17
  export declare function isPhotoHeavy(rgba: Uint8Array, threshold: number): boolean;
20
- /** Whether the optional imagequant WASM is available at runtime.
21
- * Useful for callers that want to decide ahead of time whether to
22
- * request `format: "smart"`. */
23
- export declare function isImagequantAvailable(): Promise<boolean>;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * "Burn" an editable PNG into a flat one — drop the editor's
3
+ * editable layer (Adobe XMP iTXt + custom `svGo` chunk) while
4
+ * keeping the visible bitmap byte-identical.
5
+ *
6
+ * The editable PNG format embeds:
7
+ *
8
+ * - **visible bytes** — the annotated raster the user sees.
9
+ * - **Adobe XMP iTXt chunk** — `<annot:annotations>` (the SVG
10
+ * layer) + `<annot:tags>` (provenance) for re-edit.
11
+ * - **custom `svGo` chunk** — the original un-annotated capture
12
+ * for re-edit.
13
+ *
14
+ * Flattening strips the iTXt + svGo chunks. The result is a
15
+ * regular PNG with the same visible pixels but no recoverable
16
+ * original / no SVG layer. Re-opening in the editor shows the
17
+ * annotated capture as a non-editable bitmap;
18
+ * `readEditablePngBytes` returns `null`.
19
+ *
20
+ * Use cases:
21
+ *
22
+ * - **Publish-flat** — editor session → distribution-ready
23
+ * PNG; the editable layer is dead weight for downstream
24
+ * consumers (Slack drop, third-party viewers).
25
+ * - **File size** — editable PNG roughly doubles in bytes
26
+ * (original + SVG); flattening drops the overhead.
27
+ * - **Privacy hardening** — `burnRedactions` is the strong
28
+ * version for *redact* regions; flattening drops the
29
+ * recoverable original entirely for *all* annotations,
30
+ * including non-redact ones whose annotated visual the
31
+ * publisher wants to keep but whose original capture
32
+ * they don't want shippable.
33
+ *
34
+ * Pure data — no DOM, no canvas. Returns input bytes unchanged
35
+ * when no editable-layer chunks are present (idempotent).
36
+ */
37
+ export declare function flattenEditablePng(pngBytes: Uint8Array): Uint8Array;
package/dist/index.d.ts CHANGED
@@ -1,8 +1,12 @@
1
- export { type Annotator, type AnnotatorInput, type AnnotatorOptions, createAnnotator, } from './annotator.js';
1
+ export { type Annotator, type AnnotatorInput, type AnnotatorOptions, createAnnotator, type EditableInput, } from './annotator.js';
2
2
  export { decodeAndEncodeImage, encodeRgba } from './encode/encode.js';
3
3
  export { type BrowserEncodeResult, computeResizeTarget, DEFAULT_ENCODE_OPTIONS, type EncodeFormat, type EncodeOptions, type EncodeResult, SAVE_SIZE_LABEL, SAVE_SIZE_MAX_WIDTH, type SaveSizePreset, } from './encode/options.js';
4
- export { isImagequantAvailable, isPhotoHeavy } from './encode/quantize.js';
4
+ export { isPhotoHeavy } from './encode/quantize.js';
5
+ export { burnRedactions, burnRegions, type RedactRegion } from './redact-burn.js';
6
+ export { type DiffOptions, type DiffResult, DimensionMismatchError, diffScreenshots, } from './diff.js';
7
+ export { aggregateDiffRegions } from './diff-aggregate.js';
8
+ export { flattenEditablePng } from './flatten-editable-png.js';
5
9
  export { BBOX_ANNOTATION_SCHEMA, BBOX_REDACT_REGION_SCHEMA, SHARED_DEFS, } from './dsl/schema.js';
6
10
  export { type ArrowOptions, arrowBetween, type BoundingBox, type RectOptions, rectForBoundingBox, type TextOptions, textAt, } from './dsl/svg-primitives.js';
7
11
  export { bboxAnnotationsToSvg } from './dsl/to-svg.js';
8
- export type { AnnotationStyle, BBox, BboxAnnotation, BboxArrowAnnotation, BboxCalloutAnnotation, BboxCircleAnnotation, BboxRectAnnotation, BboxRedactRegion, BboxTextAnnotation, Intent, Point, RawAnnotation, RedactStyle, } from './dsl/types.js';
12
+ export type { AnnotationStyle, BadgePlacement, BBox, BboxAnnotation, BboxArrowAnnotation, BboxCalloutAnnotation, BboxCircleAnnotation, BboxFocusMaskAnnotation, BboxFreehandAnnotation, BboxNumberedBadgeAnnotation, BboxRectAnnotation, BboxRedactRegion, BboxTextAnnotation, Intent, Point, RawAnnotation, RedactStyle, } from './dsl/types.js';