@lumy-pack/scene-sieve 0.2.0 → 0.2.1

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 (29) hide show
  1. package/README.md +88 -25
  2. package/dist/cli/commands/Sieve.d.ts +5 -0
  3. package/dist/cli/options/parse-options.d.ts +5 -1
  4. package/dist/cli.mjs +749 -237
  5. package/dist/constants/package-version.d.ts +2 -0
  6. package/dist/constants/pipeline-defaults.d.ts +20 -0
  7. package/dist/core/index.d.ts +1 -0
  8. package/dist/core/orchestrator/orchestrator.d.ts +6 -0
  9. package/dist/core/utils/metadata/build-edge-metadata.d.ts +11 -0
  10. package/dist/core/utils/metadata/build-frame-metadata.d.ts +20 -0
  11. package/dist/core/utils/metadata/build-sieve-metadata.d.ts +14 -0
  12. package/dist/core/utils/metadata/build-tool-metadata.d.ts +8 -0
  13. package/dist/core/utils/metadata/change/build-frame-change.d.ts +20 -0
  14. package/dist/core/utils/metadata/change/select-regions.d.ts +8 -0
  15. package/dist/core/utils/metadata/change/union-area/y-coverage-tree.d.ts +26 -0
  16. package/dist/core/utils/metadata/change/union-area.d.ts +7 -0
  17. package/dist/core/utils/metadata/scale-bounding-box.d.ts +11 -0
  18. package/dist/core/utils/output/finalize-selection.d.ts +15 -0
  19. package/dist/core/utils/sheet/build-tile-label-svg.d.ts +8 -0
  20. package/dist/core/utils/sheet/format-tile-label.d.ts +7 -0
  21. package/dist/core/utils/sheet/render-contact-sheet.d.ts +19 -0
  22. package/dist/core/utils/sheet/sample-tile-frames.d.ts +10 -0
  23. package/dist/core/workspace/workspace.d.ts +11 -2
  24. package/dist/index.cjs +701 -205
  25. package/dist/index.d.ts +1 -1
  26. package/dist/index.mjs +700 -204
  27. package/dist/pipeline-worker.mjs +640 -188
  28. package/dist/types/index.d.ts +148 -0
  29. package/package.json +14 -11
@@ -0,0 +1,2 @@
1
+ /** Runtime manifest version shared by CLI responses and metadata documents. */
2
+ export declare const PACKAGE_VERSION: string;
@@ -11,3 +11,23 @@ export declare const DEFAULT_MAX_SEGMENT_DURATION = 300;
11
11
  export declare const DEFAULT_SEGMENT_CONCURRENCY = 2;
12
12
  export declare const IOU_THRESHOLD = 0.9;
13
13
  export declare const ANIMATION_FRAME_THRESHOLD = 5;
14
+ /** Default maximum contact sheet columns. */
15
+ export declare const DEFAULT_SHEET_COLUMNS = 4;
16
+ /** Default contact sheet tile width in pixels. */
17
+ export declare const DEFAULT_SHEET_TILE_WIDTH = 320;
18
+ /** Default maximum contact sheet tiles. */
19
+ export declare const DEFAULT_SHEET_MAX_TILES = 40;
20
+ /** Enable timestamp labels on contact sheet tiles by default. */
21
+ export declare const DEFAULT_SHEET_LABEL = true;
22
+ /** White contact sheet margin and gap in pixels. */
23
+ export declare const SHEET_TILE_GAP = 4;
24
+ /** Tile-height fraction used for label font size. */
25
+ export declare const SHEET_LABEL_HEIGHT_RATIO = 0.07;
26
+ /** Maximum distinct regions retained per selected-frame span. */
27
+ export declare const CHANGE_REGION_LIMIT = 5;
28
+ /** Metadata schema discriminator. */
29
+ export declare const METADATA_VERSION = 2;
30
+ /** Fixed contact sheet output name. */
31
+ export declare const SHEET_FILE_NAME = "sheet.jpg";
32
+ /** Fixed metadata document output name. */
33
+ export declare const METADATA_FILE_NAME = ".metadata.json";
@@ -1,4 +1,5 @@
1
1
  export { runPipeline, runPipelineInWorker } from './orchestrator/index.js';
2
+ export type { AnimationMetadata, VideoMetadata, FrameMetadata, FrameChange, ToolMetadata, ToolParams, SheetMetadata, SheetOptions, SieveMetadata, EdgeMetadata, EdgeChange, } from '../types/index.js';
2
3
  export { analyzeFrames, computeIoU, computeInformationGain, dbscan, } from './analyzer/index.js';
3
4
  export type { Point2D } from './analyzer/index.js';
4
5
  export { extractFrames } from './extractor/index.js';
@@ -1,2 +1,8 @@
1
1
  import type { SieveOptions, SieveResult } from '../../types/index.js';
2
+ /**
3
+ * Run the five pipeline stages, delegating segmented inputs to the segmenter.
4
+ * @param options - Mode-specific input and optional pipeline settings.
5
+ * @returns Selected outputs with v2 frame metadata and zero-based API animations.
6
+ * @throws Propagates stage failures after cleaning the workspace unless debug is enabled.
7
+ */
2
8
  export declare function runPipeline(options: SieveOptions): Promise<SieveResult>;
@@ -0,0 +1,11 @@
1
+ import type { EdgeMetadata, ScoreEdge } from '../../../types/index.js';
2
+ /**
3
+ * Serialize raw candidate edges in graph order.
4
+ * @param graph - Adjacent-pair edges, optionally carrying tracker partitions.
5
+ * @param analysisResolution - Analysis dimensions used for both area fractions.
6
+ * @returns One-based IDs with six-decimal scores and four-decimal clamped ratios.
7
+ */
8
+ export declare function buildEdgeMetadata(graph: ScoreEdge[], analysisResolution: {
9
+ width: number;
10
+ height: number;
11
+ }): EdgeMetadata[];
@@ -0,0 +1,20 @@
1
+ import type { FrameMetadata, FrameNode, ScoreEdge } from '../../../types/index.js';
2
+ /**
3
+ * Describe selected frames using candidate adjacency rather than synthetic pruning edges.
4
+ * @param input - Chronological candidates and selections, raw graph and output dimensions.
5
+ * @returns One-based frame summaries with rounded timestamps and nonnegative holds.
6
+ */
7
+ export declare function buildFrameMetadata(input: {
8
+ frames: FrameNode[];
9
+ graph: ScoreEdge[];
10
+ selected: FrameNode[];
11
+ originalDurationMs: number;
12
+ analysisResolution: {
13
+ width: number;
14
+ height: number;
15
+ };
16
+ outputResolution: {
17
+ width: number;
18
+ height: number;
19
+ };
20
+ }): FrameMetadata[];
@@ -0,0 +1,14 @@
1
+ import type { AnimationMetadata, FrameNode, ProcessContext, SheetMetadata, SieveMetadata, VideoMetadata } from '../../../types/index.js';
2
+ /**
3
+ * Assemble the complete v2 document without I/O or mutation.
4
+ * @param input - Pipeline state, selections, output-space video and zero-based animations.
5
+ * @returns Contract-ordered metadata, omitting unrequested optional keys entirely.
6
+ */
7
+ export declare function buildSieveMetadata(input: {
8
+ ctx: ProcessContext;
9
+ selected: FrameNode[];
10
+ video: VideoMetadata;
11
+ animations: AnimationMetadata[];
12
+ version: string;
13
+ sheet?: SheetMetadata;
14
+ }): SieveMetadata;
@@ -0,0 +1,8 @@
1
+ import type { ResolvedOptions, ToolMetadata } from '../../../types/index.js';
2
+ /**
3
+ * Record the tool and the nine selection and encoding settings in contract order.
4
+ * @param options - Validated pipeline settings; operational options are excluded.
5
+ * @param version - Runtime package version supplied by the I/O boundary.
6
+ * @returns Deterministic tool provenance without paths or execution details.
7
+ */
8
+ export declare function buildToolMetadata(options: ResolvedOptions, version: string): ToolMetadata;
@@ -0,0 +1,20 @@
1
+ import type { FrameChange, ScoreEdge } from '../../../../types/index.js';
2
+ /**
3
+ * Aggregate adjacent-pair evidence across one selected-frame span.
4
+ * @param input - Ordered raw edges, one-based previous ID, skipped count and dimensions.
5
+ * @returns Rounded raw scores, analysis-space union ratio and output-space regions.
6
+ */
7
+ export declare function buildFrameChange(input: {
8
+ spanEdges: ScoreEdge[];
9
+ fromFrameId: number;
10
+ skippedCandidates: number;
11
+ analysisResolution: {
12
+ width: number;
13
+ height: number;
14
+ };
15
+ outputResolution: {
16
+ width: number;
17
+ height: number;
18
+ };
19
+ regionLimit: number;
20
+ }): FrameChange;
@@ -0,0 +1,8 @@
1
+ import type { BoundingBox } from '../../../../types/index.js';
2
+ /**
3
+ * Select distinct positive-area boxes with deterministic area and coordinate ties.
4
+ * @param boxes - Already scaled output rectangles; the input is not mutated.
5
+ * @param limit - Nonnegative maximum number of regions.
6
+ * @returns Largest boxes ordered by area descending, then y, x and width ascending.
7
+ */
8
+ export declare function selectRegions(boxes: BoundingBox[], limit: number): BoundingBox[];
@@ -0,0 +1,26 @@
1
+ /** Internal sweep helper retaining cover counts and lengths between sorted y bounds. */
2
+ export declare class YCoverageTree {
3
+ private readonly bounds;
4
+ /** Number of whole-node covering intervals, independent of descendants. */
5
+ private readonly counts;
6
+ /** Covered geometric length for each node, including partially covered children. */
7
+ private readonly lengths;
8
+ /**
9
+ * Allocate linear storage for the elementary intervals between coordinates.
10
+ * @param bounds - At least two sorted unique finite y endpoints.
11
+ */
12
+ constructor(bounds: number[]);
13
+ /** Total active covered y length, in the input coordinate system. */
14
+ get coveredLength(): number;
15
+ /**
16
+ * Adjust a nonempty half-open interval and refresh its ancestors' lengths.
17
+ * @param start - Inclusive endpoint index; 0 <= start < end.
18
+ * @param end - Exclusive endpoint index; end < bounds.length.
19
+ * @param delta - One on entry, minus one for the matching departure.
20
+ * @param node - Internal tree slot; callers use the root default.
21
+ * @param left - Inclusive endpoint index of this node.
22
+ * @param right - Exclusive endpoint index of this node.
23
+ * @returns Nothing; mutates this tree's coverage in O(log n).
24
+ */
25
+ update(start: number, end: number, delta: number, node?: number, left?: number, right?: number): void;
26
+ }
@@ -0,0 +1,7 @@
1
+ import type { BoundingBox } from '../../../../types/index.js';
2
+ /**
3
+ * Measure rectangle union with an x sweep in O(n log n) time and O(n) space.
4
+ * @param boxes - Finite rectangles; nonpositive dimensions are ignored.
5
+ * @returns Covered area in the input coordinate system, or zero for empty input.
6
+ */
7
+ export declare function unionArea(boxes: BoundingBox[]): number;
@@ -0,0 +1,11 @@
1
+ import type { BoundingBox } from '../../../types/index.js';
2
+ /**
3
+ * Convert an analysis box to clamped integer output pixels.
4
+ * @param box - Analysis-space rectangle; the input remains unchanged.
5
+ * @param sx - Horizontal output-to-analysis scale.
6
+ * @param sy - Vertical output-to-analysis scale.
7
+ * @param width - Nonnegative output image width.
8
+ * @param height - Nonnegative output image height.
9
+ * @returns A rectangle contained within the output dimensions.
10
+ */
11
+ export declare function scaleBoundingBox(box: BoundingBox, sx: number, sy: number, width: number, height: number): BoundingBox;
@@ -0,0 +1,15 @@
1
+ import type { AnimationMetadata, FrameNode, ProcessContext, SieveMetadata } from '../../../types/index.js';
2
+ /**
3
+ * Read output dimensions once, render optional sheets and finalize the shared v2 document.
4
+ * @param ctx - Pipeline state owned by the orchestrator; this function does not mutate it.
5
+ * @param selected - Selected frames in temporal order.
6
+ * @returns Mode-specific output, the document and zero-based API animations.
7
+ * @throws Propagates image, rendering and output I/O errors to the orchestrator.
8
+ */
9
+ export declare function finalizeSelection(ctx: ProcessContext, selected: FrameNode[]): Promise<{
10
+ outputFiles: string[];
11
+ outputBuffers?: Buffer[];
12
+ document: SieveMetadata;
13
+ animations: AnimationMetadata[];
14
+ sheetBuffer?: Buffer;
15
+ }>;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Build a tile-sized SVG overlay with a translucent badge and an explicit text baseline.
3
+ * @param text - A formatTileLabel result containing only digits, #, spaces, colons and periods.
4
+ * @param tileWidth - Positive tile canvas width in pixels.
5
+ * @param tileHeight - Positive tile canvas height in pixels.
6
+ * @returns Encoded SVG bytes for a top-left sharp composite overlay.
7
+ */
8
+ export declare function buildTileLabelSvg(text: string, tileWidth: number, tileHeight: number): Buffer;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Format a contact sheet label without rounding into the next tenth of a second.
3
+ * @param frameId - One-based candidate frame ID.
4
+ * @param timestampMs - Nonnegative candidate time in milliseconds.
5
+ * @returns A label in the form "#<id> mm:ss.s", allowing minutes beyond two digits.
6
+ */
7
+ export declare function formatTileLabel(frameId: number, timestampMs: number): string;
@@ -0,0 +1,19 @@
1
+ import type { FrameNode, SheetMetadata, SheetOptions } from '../../../types/index.js';
2
+ /**
3
+ * Read selected frame images and render a row-major contact sheet.
4
+ * @param input - Nonempty ordered selections, positive dimensions and validated sheet settings.
5
+ * @returns JPEG bytes and the effective tile layout with one-based frame IDs.
6
+ * @throws Propagates sharp image reading, compositing or encoding errors.
7
+ */
8
+ export declare function renderContactSheet(input: {
9
+ selected: FrameNode[];
10
+ resolution: {
11
+ width: number;
12
+ height: number;
13
+ };
14
+ options: Required<SheetOptions>;
15
+ quality: number;
16
+ }): Promise<{
17
+ buffer: Buffer;
18
+ metadata: SheetMetadata;
19
+ }>;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Sample a sequence uniformly while always retaining both endpoints.
3
+ * @param items - Items in temporal order.
4
+ * @param maxTiles - Validated integer limit of at least two.
5
+ * @returns The original sequence when within the limit, otherwise evenly sampled items.
6
+ */
7
+ export declare function sampleTileFrames<T>(items: T[], maxTiles: number): {
8
+ items: T[];
9
+ sampled: boolean;
10
+ };
@@ -1,6 +1,15 @@
1
- import type { FrameNode, ProcessContext } from '../../types/index.js';
1
+ import type { FrameNode, ProcessContext, SieveMetadata } from '../../types/index.js';
2
2
  export declare function createWorkspace(sessionId: string): Promise<string>;
3
- export declare function finalizeOutput(ctx: ProcessContext, selectedFrames: FrameNode[]): Promise<string[]>;
3
+ /**
4
+ * Write selected JPEGs and the supplied document before replacing the output directory.
5
+ * @param ctx - Workspace, quality and destination settings.
6
+ * @param selectedFrames - Frames paired by position with document.frames.
7
+ * @param document - Complete metadata, including the output file names.
8
+ * @param sheetBuffer - Optional JPEG contact sheet bytes to persist unchanged.
9
+ * @returns Selected JPEG paths, optional sheet path and finally the metadata path.
10
+ * @throws Rejects mismatched frame counts and propagates image or filesystem errors.
11
+ */
12
+ export declare function finalizeOutput(ctx: ProcessContext, selectedFrames: FrameNode[], document: SieveMetadata, sheetBuffer?: Buffer): Promise<string[]>;
4
13
  export declare function createSegmentWorkspace(parentWorkspacePath: string, segmentIndex: number): Promise<string>;
5
14
  export declare function cleanupWorkspace(workspacePath: string): Promise<void>;
6
15
  /**