@popmelt.com/core 0.18.0 → 0.18.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +99 -0
- package/codex-plugin/.codex-plugin/plugin.json +1 -1
- package/dist/adapter-react-three-fiber.d.mts +36 -0
- package/dist/adapter-react-three-fiber.mjs +2 -0
- package/dist/adapter-three.d.mts +2 -0
- package/dist/adapter-three.mjs +1 -1
- package/dist/bridge-entry.mjs +54 -54
- package/dist/chunk-J3UIBBU2.mjs +2 -0
- package/dist/{chunk-RS3XXK26.mjs → chunk-RH6W4F2W.mjs} +1 -1
- package/dist/{chunk-GQOEG3E5.mjs → chunk-UC34UP4S.mjs} +1 -1
- package/dist/cli.mjs +74 -74
- package/dist/index.d.mts +36 -8
- package/dist/index.mjs +40 -40
- package/dist/media.d.mts +3 -2
- package/dist/media.mjs +1 -1
- package/dist/plugin-astro.mjs +1 -1
- package/dist/plugin-vite.mjs +1 -1
- package/dist/{server-MUVH7FWR.mjs → server-PV5AVWEM.mjs} +56 -56
- package/dist/server.d.mts +2 -2
- package/dist/server.mjs +56 -56
- package/dist/{video-adapter-DzNtG67g.d.mts → subjects-CeqtFged.d.mts} +1 -337
- package/dist/video-adapter-Gq8saCDn.d.mts +339 -0
- package/package.json +14 -4
|
@@ -409,340 +409,4 @@ type PopmeltSubjectAdapter = {
|
|
|
409
409
|
removeSubject?(key: string): void;
|
|
410
410
|
};
|
|
411
411
|
|
|
412
|
-
|
|
413
|
-
type ImageObjectBox = {
|
|
414
|
-
left: number;
|
|
415
|
-
top: number;
|
|
416
|
-
width: number;
|
|
417
|
-
height: number;
|
|
418
|
-
};
|
|
419
|
-
/** A provider's observation; no inference runtime is required by Core. */
|
|
420
|
-
type ImageObjectObservation = {
|
|
421
|
-
label: string;
|
|
422
|
-
score: number;
|
|
423
|
-
box: ImageObjectBox;
|
|
424
|
-
};
|
|
425
|
-
|
|
426
|
-
type PersistedImageSubject = {
|
|
427
|
-
id: string;
|
|
428
|
-
label: string;
|
|
429
|
-
detectedLabel?: string;
|
|
430
|
-
score: number;
|
|
431
|
-
box: ImageObjectBox;
|
|
432
|
-
detectedBox?: ImageObjectBox;
|
|
433
|
-
origin: 'detected' | 'manual';
|
|
434
|
-
boundsOverridden?: boolean;
|
|
435
|
-
};
|
|
436
|
-
type PersistedImageSuppression = {
|
|
437
|
-
detectedLabel: string;
|
|
438
|
-
detectedBox: ImageObjectBox;
|
|
439
|
-
};
|
|
440
|
-
type PersistedImageAnalysis = {
|
|
441
|
-
schemaVersion: 1;
|
|
442
|
-
source: string;
|
|
443
|
-
imageHash: string;
|
|
444
|
-
inferenceKey: string;
|
|
445
|
-
dedupeKey: string;
|
|
446
|
-
subjects: readonly PersistedImageSubject[];
|
|
447
|
-
/** Inferred objects explicitly removed by the user for this image hash. */
|
|
448
|
-
suppressions?: readonly PersistedImageSuppression[];
|
|
449
|
-
updatedAt: number;
|
|
450
|
-
};
|
|
451
|
-
type ImageSubjectStore = {
|
|
452
|
-
load(key: string): PersistedImageAnalysis | null | Promise<PersistedImageAnalysis | null>;
|
|
453
|
-
save(key: string, analysis: PersistedImageAnalysis): void | Promise<void>;
|
|
454
|
-
remove?(key: string): void | Promise<void>;
|
|
455
|
-
/** Older content-hash versions retained before the active record changed. */
|
|
456
|
-
loadHistory?(key: string): readonly PersistedImageAnalysis[] | Promise<readonly PersistedImageAnalysis[]>;
|
|
457
|
-
};
|
|
458
|
-
type BrowserImageSubjectStoreOptions = {
|
|
459
|
-
/** Prefix used for browser storage entries. */
|
|
460
|
-
namespace?: string;
|
|
461
|
-
/** Override localStorage, primarily for embedded browsers and tests. */
|
|
462
|
-
storage?: Storage;
|
|
463
|
-
};
|
|
464
|
-
declare function createBrowserImageSubjectStore(options?: BrowserImageSubjectStoreOptions): ImageSubjectStore;
|
|
465
|
-
declare function createMemoryImageSubjectStore(): ImageSubjectStore;
|
|
466
|
-
|
|
467
|
-
type ImageContentHasher = (image: HTMLImageElement) => string | Promise<string>;
|
|
468
|
-
/** Optional perception boundary. Core keeps media authoring usable without it. */
|
|
469
|
-
type ImageRecognitionProvider = {
|
|
470
|
-
cacheKey: string;
|
|
471
|
-
configurationKey: string;
|
|
472
|
-
detect(image: HTMLImageElement): Promise<readonly ImageObjectObservation[]>;
|
|
473
|
-
reconcile(observations: readonly ImageObjectObservation[], previousSubjects: readonly PersistedImageSubject[], suppressions: readonly PersistedImageSuppression[]): readonly PersistedImageSubject[];
|
|
474
|
-
dispose?(): void | Promise<void>;
|
|
475
|
-
};
|
|
476
|
-
type ImageSubjectAdapterOptions = {
|
|
477
|
-
/** Optional perception; omit for manual-only image annotation. */
|
|
478
|
-
recognition?: ImageRecognitionProvider;
|
|
479
|
-
/** Restore saved subjects without hashing or running recognition. */
|
|
480
|
-
hydrateOnly?: boolean;
|
|
481
|
-
/** Images to analyze when the adapter starts. Defaults to every image. */
|
|
482
|
-
selector?: string;
|
|
483
|
-
/** Root to scan and observe. Defaults to document. */
|
|
484
|
-
root?: Document | Element;
|
|
485
|
-
/** Observe added images and src changes. Defaults to true. */
|
|
486
|
-
observe?: boolean;
|
|
487
|
-
/** Override the durable Core adapter id. */
|
|
488
|
-
id?: string;
|
|
489
|
-
/** Persist detections and user overrides. Omit to keep adapter state ephemeral. */
|
|
490
|
-
store?: ImageSubjectStore;
|
|
491
|
-
/** Override content hashing, primarily for authenticated or virtual images. */
|
|
492
|
-
imageHasher?: ImageContentHasher;
|
|
493
|
-
onError?: (error: unknown, image: HTMLImageElement) => void;
|
|
494
|
-
};
|
|
495
|
-
declare class ImageSubjectAdapter implements PopmeltSubjectAdapter {
|
|
496
|
-
private readonly options;
|
|
497
|
-
readonly surfaceKind: "image";
|
|
498
|
-
readonly id: string;
|
|
499
|
-
private readonly records;
|
|
500
|
-
private readonly imageKeys;
|
|
501
|
-
private readonly analyzedSources;
|
|
502
|
-
private readonly pending;
|
|
503
|
-
private readonly analysisMetadata;
|
|
504
|
-
private readonly suppressions;
|
|
505
|
-
private readonly writeChains;
|
|
506
|
-
private readonly pendingWrites;
|
|
507
|
-
private readonly observer;
|
|
508
|
-
private refreshQueued;
|
|
509
|
-
private destroyed;
|
|
510
|
-
private readyPromise;
|
|
511
|
-
private manualSequence;
|
|
512
|
-
constructor(options?: ImageSubjectAdapterOptions);
|
|
513
|
-
whenReady(): Promise<void>;
|
|
514
|
-
listSubjects(): readonly PopmeltSubject[];
|
|
515
|
-
refresh(): Promise<void>;
|
|
516
|
-
hitTest(clientPoint: {
|
|
517
|
-
x: number;
|
|
518
|
-
y: number;
|
|
519
|
-
}): PopmeltSubject | null;
|
|
520
|
-
resolve(key: string): PopmeltSubject | null;
|
|
521
|
-
restoreSubject(key: string, elementInfo: ElementInfo): PopmeltSubject | null;
|
|
522
|
-
private imageObjectContext;
|
|
523
|
-
captureSubject(key: string): Promise<Blob | null>;
|
|
524
|
-
beginCreate(clientPoint: {
|
|
525
|
-
x: number;
|
|
526
|
-
y: number;
|
|
527
|
-
}): PopmeltSubjectCreationSession | null;
|
|
528
|
-
renameSubject(key: string, label: string): PopmeltSubject | null;
|
|
529
|
-
updateSubjectBounds(key: string, bounds: PopmeltSubjectBounds): PopmeltSubject | null;
|
|
530
|
-
removeSubject(key: string): void;
|
|
531
|
-
destroy(): Promise<void>;
|
|
532
|
-
private queueRefresh;
|
|
533
|
-
private analyze;
|
|
534
|
-
private replaceImageRecords;
|
|
535
|
-
private imageIdentity;
|
|
536
|
-
private matchingImages;
|
|
537
|
-
private clampedImagePoint;
|
|
538
|
-
private newObjectId;
|
|
539
|
-
private persistImage;
|
|
540
|
-
private saveImage;
|
|
541
|
-
private imageSubjects;
|
|
542
|
-
private persistencePayload;
|
|
543
|
-
private removeImage;
|
|
544
|
-
}
|
|
545
|
-
declare function createImageSubjectAdapter(options?: ImageSubjectAdapterOptions): ImageSubjectAdapter;
|
|
546
|
-
|
|
547
|
-
type VideoObjectBox = ImageObjectBox;
|
|
548
|
-
type VideoTrackingAnchor = PopmeltSubjectTrackingAnchor;
|
|
549
|
-
type VideoTrackKeyframe = {
|
|
550
|
-
time: number;
|
|
551
|
-
box: VideoObjectBox;
|
|
552
|
-
score: number;
|
|
553
|
-
source: 'manual' | 'tracked';
|
|
554
|
-
};
|
|
555
|
-
type VideoTrackObservation = {
|
|
556
|
-
time: number;
|
|
557
|
-
box: VideoObjectBox;
|
|
558
|
-
score: number;
|
|
559
|
-
};
|
|
560
|
-
type VideoTrackingAttempt = {
|
|
561
|
-
/** Expand the normal local search crop during reacquisition. */
|
|
562
|
-
searchScale?: number;
|
|
563
|
-
};
|
|
564
|
-
type VideoTrackSegment = {
|
|
565
|
-
/** First media time at which this object is confidently observable. */
|
|
566
|
-
start: number;
|
|
567
|
-
/** Last confidently observable media time. Omitted while the segment is open. */
|
|
568
|
-
end?: number;
|
|
569
|
-
};
|
|
570
|
-
type VideoTrackingSeed = {
|
|
571
|
-
video: HTMLVideoElement;
|
|
572
|
-
time: number;
|
|
573
|
-
box: VideoObjectBox;
|
|
574
|
-
anchors?: readonly VideoTrackingAnchor[];
|
|
575
|
-
};
|
|
576
|
-
type VideoTrackingSession = {
|
|
577
|
-
track(video: HTMLVideoElement, time: number, attempt?: VideoTrackingAttempt): Promise<VideoTrackObservation | null>;
|
|
578
|
-
reseed?(seed: VideoTrackingSeed): void | Promise<void>;
|
|
579
|
-
dispose?(): void | Promise<void>;
|
|
580
|
-
};
|
|
581
|
-
type VideoTrackSmoother = {
|
|
582
|
-
/** Builds one presentation frame from a chronological durable observation. */
|
|
583
|
-
smooth(frame: VideoTrackKeyframe): VideoTrackKeyframe;
|
|
584
|
-
};
|
|
585
|
-
type VideoMotionState = {
|
|
586
|
-
visible: boolean;
|
|
587
|
-
misses: number;
|
|
588
|
-
hits: number;
|
|
589
|
-
lostAt?: number;
|
|
590
|
-
};
|
|
591
|
-
type VideoMotionPresenceDecision = {
|
|
592
|
-
state: VideoMotionState;
|
|
593
|
-
action: 'accept' | 'hold' | 'close' | 'reopen';
|
|
594
|
-
};
|
|
595
|
-
type VideoMotionAttempt = {
|
|
596
|
-
framesPerSecond: number;
|
|
597
|
-
tracking: VideoTrackingAttempt;
|
|
598
|
-
};
|
|
599
|
-
type VideoBackwardAnalysisOptions = {
|
|
600
|
-
source: HTMLVideoElement;
|
|
601
|
-
seedTime: number;
|
|
602
|
-
keyframes: readonly VideoTrackKeyframe[];
|
|
603
|
-
anchors: readonly VideoTrackingAnchor[];
|
|
604
|
-
maximumFramesPerSecond: number;
|
|
605
|
-
cancelled: () => boolean;
|
|
606
|
-
forwardWork: () => Promise<void> | undefined;
|
|
607
|
-
};
|
|
608
|
-
type VideoBackwardAnalysisResult = {
|
|
609
|
-
earliestTime: number;
|
|
610
|
-
keyframes: VideoTrackKeyframe[];
|
|
611
|
-
};
|
|
612
|
-
/**
|
|
613
|
-
* Pixel-derived motion policy supplied by a perception extension. Core invokes
|
|
614
|
-
* it, then stores and renders the resulting durable and presentation tracks.
|
|
615
|
-
*/
|
|
616
|
-
type VideoMotionPolicy = {
|
|
617
|
-
createSmoother(): VideoTrackSmoother;
|
|
618
|
-
attempt(options: {
|
|
619
|
-
state: VideoMotionState;
|
|
620
|
-
time: number;
|
|
621
|
-
maximumFramesPerSecond: number;
|
|
622
|
-
}): VideoMotionAttempt;
|
|
623
|
-
observe(options: {
|
|
624
|
-
state: VideoMotionState;
|
|
625
|
-
time: number;
|
|
626
|
-
observation: VideoTrackObservation | null;
|
|
627
|
-
}): VideoMotionPresenceDecision;
|
|
628
|
-
analyzeBackward(options: VideoBackwardAnalysisOptions): Promise<VideoBackwardAnalysisResult>;
|
|
629
|
-
};
|
|
630
|
-
/** Optional local perception boundary. Core owns tracks and authoring. */
|
|
631
|
-
type VideoTrackingProvider = {
|
|
632
|
-
cacheKey: string;
|
|
633
|
-
configurationKey: string;
|
|
634
|
-
motion: VideoMotionPolicy;
|
|
635
|
-
createSession(seed: VideoTrackingSeed): Promise<VideoTrackingSession>;
|
|
636
|
-
dispose?(): void | Promise<void>;
|
|
637
|
-
};
|
|
638
|
-
type PersistedVideoTrack = {
|
|
639
|
-
id: string;
|
|
640
|
-
label: string;
|
|
641
|
-
origin: 'manual' | 'detected';
|
|
642
|
-
keyframes: readonly VideoTrackKeyframe[];
|
|
643
|
-
/** See-derived display geometry, persisted so Core can replay it alone. */
|
|
644
|
-
presentationKeyframes?: readonly VideoTrackKeyframe[];
|
|
645
|
-
anchors?: readonly VideoTrackingAnchor[];
|
|
646
|
-
/** Explicit visible spans. Missing on schema-v1 tracks, which migrate open-ended. */
|
|
647
|
-
segments?: readonly VideoTrackSegment[];
|
|
648
|
-
/** Furthest media time already covered by forward inference. */
|
|
649
|
-
analyzedThrough?: number;
|
|
650
|
-
createdAt: number;
|
|
651
|
-
updatedAt: number;
|
|
652
|
-
};
|
|
653
|
-
type PersistedVideoAnalysis = {
|
|
654
|
-
schemaVersion: 1 | 2 | 3;
|
|
655
|
-
source: string;
|
|
656
|
-
duration: number;
|
|
657
|
-
tracks: readonly PersistedVideoTrack[];
|
|
658
|
-
updatedAt: number;
|
|
659
|
-
};
|
|
660
|
-
type VideoSubjectStore = {
|
|
661
|
-
load(key: string): PersistedVideoAnalysis | null | Promise<PersistedVideoAnalysis | null>;
|
|
662
|
-
save(key: string, analysis: PersistedVideoAnalysis): void | Promise<void>;
|
|
663
|
-
remove?(key: string): void | Promise<void>;
|
|
664
|
-
};
|
|
665
|
-
|
|
666
|
-
type VideoSubjectAdapterOptions = {
|
|
667
|
-
tracking?: VideoTrackingProvider;
|
|
668
|
-
selector?: string;
|
|
669
|
-
root?: Document | Element;
|
|
670
|
-
observe?: boolean;
|
|
671
|
-
id?: string;
|
|
672
|
-
store?: VideoSubjectStore;
|
|
673
|
-
maxTrackingFramesPerSecond?: number;
|
|
674
|
-
onError?: (error: unknown, video: HTMLVideoElement) => void;
|
|
675
|
-
};
|
|
676
|
-
declare class VideoSubjectAdapter implements PopmeltSubjectAdapter {
|
|
677
|
-
private readonly options;
|
|
678
|
-
readonly surfaceKind: "video";
|
|
679
|
-
readonly id: string;
|
|
680
|
-
private readonly records;
|
|
681
|
-
private readonly videoKeys;
|
|
682
|
-
private readonly metadata;
|
|
683
|
-
private readonly analyzedSources;
|
|
684
|
-
private readonly listeners;
|
|
685
|
-
private readonly frameHandles;
|
|
686
|
-
private readonly persistTimers;
|
|
687
|
-
private readonly writeChains;
|
|
688
|
-
private readonly pendingWrites;
|
|
689
|
-
private readonly observer;
|
|
690
|
-
private refreshQueued;
|
|
691
|
-
private destroyed;
|
|
692
|
-
private manualSequence;
|
|
693
|
-
private activeTrackingKey;
|
|
694
|
-
private readyPromise;
|
|
695
|
-
constructor(options?: VideoSubjectAdapterOptions);
|
|
696
|
-
whenReady(): Promise<void>;
|
|
697
|
-
listSubjects(): readonly PopmeltSubject[];
|
|
698
|
-
refresh(): Promise<void>;
|
|
699
|
-
hitTest(point: {
|
|
700
|
-
x: number;
|
|
701
|
-
y: number;
|
|
702
|
-
}): PopmeltSubject | null;
|
|
703
|
-
resolve(key: string): PopmeltSubject | null;
|
|
704
|
-
captureSubject(key: string): Promise<Blob | null>;
|
|
705
|
-
beginCreate(point: {
|
|
706
|
-
x: number;
|
|
707
|
-
y: number;
|
|
708
|
-
}): PopmeltSubjectCreationSession | null;
|
|
709
|
-
renameSubject(key: string, label: string): PopmeltSubject | null;
|
|
710
|
-
updateSubjectBounds(key: string, bounds: PopmeltSubjectBounds): PopmeltSubject | null;
|
|
711
|
-
updateSubjectTrackingAnchors(key: string, anchors: readonly PopmeltSubjectTrackingAnchor[]): PopmeltSubject | null;
|
|
712
|
-
removeSubject(key: string): void;
|
|
713
|
-
destroy(): Promise<void>;
|
|
714
|
-
private analyze;
|
|
715
|
-
private addVideoListeners;
|
|
716
|
-
private removeVideoListeners;
|
|
717
|
-
private scheduleFrame;
|
|
718
|
-
private trackVideo;
|
|
719
|
-
private startSession;
|
|
720
|
-
private reseed;
|
|
721
|
-
private failTracking;
|
|
722
|
-
private activeRecordFor;
|
|
723
|
-
private activateMostRecentRecord;
|
|
724
|
-
private activateTrackingRecord;
|
|
725
|
-
private scheduleBackwardAnalysis;
|
|
726
|
-
private cancelBackwardAnalysis;
|
|
727
|
-
private runBackwardAnalysis;
|
|
728
|
-
private acceptObservation;
|
|
729
|
-
private openSegment;
|
|
730
|
-
private closeSegment;
|
|
731
|
-
private insertKeyframe;
|
|
732
|
-
private rebuildPresentationTrack;
|
|
733
|
-
private clearLiveFrames;
|
|
734
|
-
private videoObjectContext;
|
|
735
|
-
private replaceVideoRecords;
|
|
736
|
-
private persistVideo;
|
|
737
|
-
private schedulePersistence;
|
|
738
|
-
private flushScheduledPersistence;
|
|
739
|
-
private matchingVideos;
|
|
740
|
-
private videoIdentity;
|
|
741
|
-
private newObjectId;
|
|
742
|
-
private removeVideoRecords;
|
|
743
|
-
private removeVideo;
|
|
744
|
-
private queueRefresh;
|
|
745
|
-
}
|
|
746
|
-
declare function createVideoSubjectAdapter(options?: VideoSubjectAdapterOptions): VideoSubjectAdapter;
|
|
747
|
-
|
|
748
|
-
export { type VideoTrackingAttempt as $, type Annotation as A, type BridgeStatus as B, type ClaudeResponse as C, type DomModification as D, type ElementInfo as E, type PersistedImageSuppression as F, type PersistedVideoAnalysis as G, type PersistedVideoTrack as H, type ImageRecognitionProvider as I, type VideoBackwardAnalysisOptions as J, type VideoBackwardAnalysisResult as K, type VideoMotionAttempt as L, type VideoMotionPolicy as M, type VideoMotionPresenceDecision as N, type OpaqueTargetReference as O, type PopmeltSubjectAdapter as P, type VideoMotionState as Q, type ReactSourceLocation as R, type SubjectFeedbackAttachment as S, type TextModification as T, VideoSubjectAdapter as U, type VideoTrackingProvider as V, type VideoTrackKeyframe as W, type VideoTrackObservation as X, type VideoTrackSegment as Y, type VideoTrackSmoother as Z, type VideoTrackingAnchor as _, type ImageSubjectAdapterOptions as a, type VideoTrackingSeed as a0, type VideoTrackingSession as a1, createBrowserImageSubjectStore as a2, createImageSubjectAdapter as a3, createMemoryImageSubjectStore as a4, createVideoSubjectAdapter as a5, type VideoSubjectAdapterOptions as b, type AnnotationAttachment as c, type StyleModification as d, type SpacingTokenChange as e, type AnnotationType as f, type ImageObjectContext as g, type Point as h, type PopmeltSubject as i, type PopmeltSubjectBounds as j, type PopmeltSubjectCreationSession as k, type PopmeltSubjectTrackingAnchor as l, type PopmeltSurfaceSnapshot as m, type StyleChange as n, type ToolType as o, type VideoObjectContext as p, type ImageObjectBox as q, type VideoSubjectStore as r, type VideoObjectBox as s, type BrowserImageSubjectStoreOptions as t, type ImageContentHasher as u, type ImageObjectObservation as v, ImageSubjectAdapter as w, type ImageSubjectStore as x, type PersistedImageAnalysis as y, type PersistedImageSubject as z };
|
|
412
|
+
export type { Annotation as A, BridgeStatus as B, ClaudeResponse as C, DomModification as D, ElementInfo as E, ImageObjectContext as I, OpaqueTargetReference as O, PopmeltSubjectAdapter as P, ReactSourceLocation as R, SubjectFeedbackAttachment as S, TextModification as T, VideoObjectContext as V, AnnotationAttachment as a, StyleModification as b, SpacingTokenChange as c, AnnotationType as d, Point as e, PopmeltSubject as f, PopmeltSubjectBounds as g, PopmeltSubjectCreationSession as h, PopmeltSubjectTrackingAnchor as i, PopmeltSurfaceSnapshot as j, StyleChange as k, ToolType as l };
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import { P as PopmeltSubjectAdapter, f as PopmeltSubject, E as ElementInfo, h as PopmeltSubjectCreationSession, g as PopmeltSubjectBounds, i as PopmeltSubjectTrackingAnchor } from './subjects-CeqtFged.mjs';
|
|
2
|
+
|
|
3
|
+
/** Geometry is normalized against the loaded image, not its rendered size. */
|
|
4
|
+
type ImageObjectBox = {
|
|
5
|
+
left: number;
|
|
6
|
+
top: number;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
};
|
|
10
|
+
/** A provider's observation; no inference runtime is required by Core. */
|
|
11
|
+
type ImageObjectObservation = {
|
|
12
|
+
label: string;
|
|
13
|
+
score: number;
|
|
14
|
+
box: ImageObjectBox;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
type PersistedImageSubject = {
|
|
18
|
+
id: string;
|
|
19
|
+
label: string;
|
|
20
|
+
detectedLabel?: string;
|
|
21
|
+
score: number;
|
|
22
|
+
box: ImageObjectBox;
|
|
23
|
+
detectedBox?: ImageObjectBox;
|
|
24
|
+
origin: 'detected' | 'manual';
|
|
25
|
+
boundsOverridden?: boolean;
|
|
26
|
+
};
|
|
27
|
+
type PersistedImageSuppression = {
|
|
28
|
+
detectedLabel: string;
|
|
29
|
+
detectedBox: ImageObjectBox;
|
|
30
|
+
};
|
|
31
|
+
type PersistedImageAnalysis = {
|
|
32
|
+
schemaVersion: 1;
|
|
33
|
+
source: string;
|
|
34
|
+
imageHash: string;
|
|
35
|
+
inferenceKey: string;
|
|
36
|
+
dedupeKey: string;
|
|
37
|
+
subjects: readonly PersistedImageSubject[];
|
|
38
|
+
/** Inferred objects explicitly removed by the user for this image hash. */
|
|
39
|
+
suppressions?: readonly PersistedImageSuppression[];
|
|
40
|
+
updatedAt: number;
|
|
41
|
+
};
|
|
42
|
+
type ImageSubjectStore = {
|
|
43
|
+
load(key: string): PersistedImageAnalysis | null | Promise<PersistedImageAnalysis | null>;
|
|
44
|
+
save(key: string, analysis: PersistedImageAnalysis): void | Promise<void>;
|
|
45
|
+
remove?(key: string): void | Promise<void>;
|
|
46
|
+
/** Older content-hash versions retained before the active record changed. */
|
|
47
|
+
loadHistory?(key: string): readonly PersistedImageAnalysis[] | Promise<readonly PersistedImageAnalysis[]>;
|
|
48
|
+
};
|
|
49
|
+
type BrowserImageSubjectStoreOptions = {
|
|
50
|
+
/** Prefix used for browser storage entries. */
|
|
51
|
+
namespace?: string;
|
|
52
|
+
/** Override localStorage, primarily for embedded browsers and tests. */
|
|
53
|
+
storage?: Storage;
|
|
54
|
+
};
|
|
55
|
+
declare function createBrowserImageSubjectStore(options?: BrowserImageSubjectStoreOptions): ImageSubjectStore;
|
|
56
|
+
declare function createMemoryImageSubjectStore(): ImageSubjectStore;
|
|
57
|
+
|
|
58
|
+
type ImageContentHasher = (image: HTMLImageElement) => string | Promise<string>;
|
|
59
|
+
/** Optional perception boundary. Core keeps media authoring usable without it. */
|
|
60
|
+
type ImageRecognitionProvider = {
|
|
61
|
+
cacheKey: string;
|
|
62
|
+
configurationKey: string;
|
|
63
|
+
detect(image: HTMLImageElement): Promise<readonly ImageObjectObservation[]>;
|
|
64
|
+
reconcile(observations: readonly ImageObjectObservation[], previousSubjects: readonly PersistedImageSubject[], suppressions: readonly PersistedImageSuppression[]): readonly PersistedImageSubject[];
|
|
65
|
+
dispose?(): void | Promise<void>;
|
|
66
|
+
};
|
|
67
|
+
type ImageSubjectAdapterOptions = {
|
|
68
|
+
/** Optional perception; omit for manual-only image annotation. */
|
|
69
|
+
recognition?: ImageRecognitionProvider;
|
|
70
|
+
/** Restore saved subjects without hashing or running recognition. */
|
|
71
|
+
hydrateOnly?: boolean;
|
|
72
|
+
/** Images to analyze when the adapter starts. Defaults to every image. */
|
|
73
|
+
selector?: string;
|
|
74
|
+
/** Root to scan and observe. Defaults to document. */
|
|
75
|
+
root?: Document | Element;
|
|
76
|
+
/** Observe added images and src changes. Defaults to true. */
|
|
77
|
+
observe?: boolean;
|
|
78
|
+
/** Override the durable Core adapter id. */
|
|
79
|
+
id?: string;
|
|
80
|
+
/** Persist detections and user overrides. Omit to keep adapter state ephemeral. */
|
|
81
|
+
store?: ImageSubjectStore;
|
|
82
|
+
/** Override content hashing, primarily for authenticated or virtual images. */
|
|
83
|
+
imageHasher?: ImageContentHasher;
|
|
84
|
+
onError?: (error: unknown, image: HTMLImageElement) => void;
|
|
85
|
+
};
|
|
86
|
+
declare class ImageSubjectAdapter implements PopmeltSubjectAdapter {
|
|
87
|
+
private readonly options;
|
|
88
|
+
readonly surfaceKind: "image";
|
|
89
|
+
readonly id: string;
|
|
90
|
+
private readonly records;
|
|
91
|
+
private readonly imageKeys;
|
|
92
|
+
private readonly analyzedSources;
|
|
93
|
+
private readonly pending;
|
|
94
|
+
private readonly analysisMetadata;
|
|
95
|
+
private readonly suppressions;
|
|
96
|
+
private readonly writeChains;
|
|
97
|
+
private readonly pendingWrites;
|
|
98
|
+
private readonly observer;
|
|
99
|
+
private refreshQueued;
|
|
100
|
+
private destroyed;
|
|
101
|
+
private readyPromise;
|
|
102
|
+
private manualSequence;
|
|
103
|
+
constructor(options?: ImageSubjectAdapterOptions);
|
|
104
|
+
whenReady(): Promise<void>;
|
|
105
|
+
listSubjects(): readonly PopmeltSubject[];
|
|
106
|
+
refresh(): Promise<void>;
|
|
107
|
+
hitTest(clientPoint: {
|
|
108
|
+
x: number;
|
|
109
|
+
y: number;
|
|
110
|
+
}): PopmeltSubject | null;
|
|
111
|
+
resolve(key: string): PopmeltSubject | null;
|
|
112
|
+
restoreSubject(key: string, elementInfo: ElementInfo): PopmeltSubject | null;
|
|
113
|
+
private imageObjectContext;
|
|
114
|
+
captureSubject(key: string): Promise<Blob | null>;
|
|
115
|
+
beginCreate(clientPoint: {
|
|
116
|
+
x: number;
|
|
117
|
+
y: number;
|
|
118
|
+
}): PopmeltSubjectCreationSession | null;
|
|
119
|
+
renameSubject(key: string, label: string): PopmeltSubject | null;
|
|
120
|
+
updateSubjectBounds(key: string, bounds: PopmeltSubjectBounds): PopmeltSubject | null;
|
|
121
|
+
removeSubject(key: string): void;
|
|
122
|
+
destroy(): Promise<void>;
|
|
123
|
+
private queueRefresh;
|
|
124
|
+
private analyze;
|
|
125
|
+
private replaceImageRecords;
|
|
126
|
+
private imageIdentity;
|
|
127
|
+
private matchingImages;
|
|
128
|
+
private clampedImagePoint;
|
|
129
|
+
private newObjectId;
|
|
130
|
+
private persistImage;
|
|
131
|
+
private saveImage;
|
|
132
|
+
private imageSubjects;
|
|
133
|
+
private persistencePayload;
|
|
134
|
+
private removeImage;
|
|
135
|
+
}
|
|
136
|
+
declare function createImageSubjectAdapter(options?: ImageSubjectAdapterOptions): ImageSubjectAdapter;
|
|
137
|
+
|
|
138
|
+
type VideoObjectBox = ImageObjectBox;
|
|
139
|
+
type VideoTrackingAnchor = PopmeltSubjectTrackingAnchor;
|
|
140
|
+
type VideoTrackKeyframe = {
|
|
141
|
+
time: number;
|
|
142
|
+
box: VideoObjectBox;
|
|
143
|
+
score: number;
|
|
144
|
+
source: 'manual' | 'tracked';
|
|
145
|
+
};
|
|
146
|
+
type VideoTrackObservation = {
|
|
147
|
+
time: number;
|
|
148
|
+
box: VideoObjectBox;
|
|
149
|
+
score: number;
|
|
150
|
+
};
|
|
151
|
+
type VideoTrackingAttempt = {
|
|
152
|
+
/** Expand the normal local search crop during reacquisition. */
|
|
153
|
+
searchScale?: number;
|
|
154
|
+
};
|
|
155
|
+
type VideoTrackSegment = {
|
|
156
|
+
/** First media time at which this object is confidently observable. */
|
|
157
|
+
start: number;
|
|
158
|
+
/** Last confidently observable media time. Omitted while the segment is open. */
|
|
159
|
+
end?: number;
|
|
160
|
+
};
|
|
161
|
+
type VideoTrackingSeed = {
|
|
162
|
+
video: HTMLVideoElement;
|
|
163
|
+
time: number;
|
|
164
|
+
box: VideoObjectBox;
|
|
165
|
+
anchors?: readonly VideoTrackingAnchor[];
|
|
166
|
+
};
|
|
167
|
+
type VideoTrackingSession = {
|
|
168
|
+
track(video: HTMLVideoElement, time: number, attempt?: VideoTrackingAttempt): Promise<VideoTrackObservation | null>;
|
|
169
|
+
reseed?(seed: VideoTrackingSeed): void | Promise<void>;
|
|
170
|
+
dispose?(): void | Promise<void>;
|
|
171
|
+
};
|
|
172
|
+
type VideoTrackSmoother = {
|
|
173
|
+
/** Builds one presentation frame from a chronological durable observation. */
|
|
174
|
+
smooth(frame: VideoTrackKeyframe): VideoTrackKeyframe;
|
|
175
|
+
};
|
|
176
|
+
type VideoMotionState = {
|
|
177
|
+
visible: boolean;
|
|
178
|
+
misses: number;
|
|
179
|
+
hits: number;
|
|
180
|
+
lostAt?: number;
|
|
181
|
+
};
|
|
182
|
+
type VideoMotionPresenceDecision = {
|
|
183
|
+
state: VideoMotionState;
|
|
184
|
+
action: 'accept' | 'hold' | 'close' | 'reopen';
|
|
185
|
+
};
|
|
186
|
+
type VideoMotionAttempt = {
|
|
187
|
+
framesPerSecond: number;
|
|
188
|
+
tracking: VideoTrackingAttempt;
|
|
189
|
+
};
|
|
190
|
+
type VideoBackwardAnalysisOptions = {
|
|
191
|
+
source: HTMLVideoElement;
|
|
192
|
+
seedTime: number;
|
|
193
|
+
keyframes: readonly VideoTrackKeyframe[];
|
|
194
|
+
anchors: readonly VideoTrackingAnchor[];
|
|
195
|
+
maximumFramesPerSecond: number;
|
|
196
|
+
cancelled: () => boolean;
|
|
197
|
+
forwardWork: () => Promise<void> | undefined;
|
|
198
|
+
};
|
|
199
|
+
type VideoBackwardAnalysisResult = {
|
|
200
|
+
earliestTime: number;
|
|
201
|
+
keyframes: VideoTrackKeyframe[];
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* Pixel-derived motion policy supplied by a perception extension. Core invokes
|
|
205
|
+
* it, then stores and renders the resulting durable and presentation tracks.
|
|
206
|
+
*/
|
|
207
|
+
type VideoMotionPolicy = {
|
|
208
|
+
createSmoother(): VideoTrackSmoother;
|
|
209
|
+
attempt(options: {
|
|
210
|
+
state: VideoMotionState;
|
|
211
|
+
time: number;
|
|
212
|
+
maximumFramesPerSecond: number;
|
|
213
|
+
}): VideoMotionAttempt;
|
|
214
|
+
observe(options: {
|
|
215
|
+
state: VideoMotionState;
|
|
216
|
+
time: number;
|
|
217
|
+
observation: VideoTrackObservation | null;
|
|
218
|
+
}): VideoMotionPresenceDecision;
|
|
219
|
+
analyzeBackward(options: VideoBackwardAnalysisOptions): Promise<VideoBackwardAnalysisResult>;
|
|
220
|
+
};
|
|
221
|
+
/** Optional local perception boundary. Core owns tracks and authoring. */
|
|
222
|
+
type VideoTrackingProvider = {
|
|
223
|
+
cacheKey: string;
|
|
224
|
+
configurationKey: string;
|
|
225
|
+
motion: VideoMotionPolicy;
|
|
226
|
+
createSession(seed: VideoTrackingSeed): Promise<VideoTrackingSession>;
|
|
227
|
+
dispose?(): void | Promise<void>;
|
|
228
|
+
};
|
|
229
|
+
type PersistedVideoTrack = {
|
|
230
|
+
id: string;
|
|
231
|
+
label: string;
|
|
232
|
+
origin: 'manual' | 'detected';
|
|
233
|
+
keyframes: readonly VideoTrackKeyframe[];
|
|
234
|
+
/** See-derived display geometry, persisted so Core can replay it alone. */
|
|
235
|
+
presentationKeyframes?: readonly VideoTrackKeyframe[];
|
|
236
|
+
anchors?: readonly VideoTrackingAnchor[];
|
|
237
|
+
/** Explicit visible spans. Missing on schema-v1 tracks, which migrate open-ended. */
|
|
238
|
+
segments?: readonly VideoTrackSegment[];
|
|
239
|
+
/** Furthest media time already covered by forward inference. */
|
|
240
|
+
analyzedThrough?: number;
|
|
241
|
+
createdAt: number;
|
|
242
|
+
updatedAt: number;
|
|
243
|
+
};
|
|
244
|
+
type PersistedVideoAnalysis = {
|
|
245
|
+
schemaVersion: 1 | 2 | 3;
|
|
246
|
+
source: string;
|
|
247
|
+
duration: number;
|
|
248
|
+
tracks: readonly PersistedVideoTrack[];
|
|
249
|
+
updatedAt: number;
|
|
250
|
+
};
|
|
251
|
+
type VideoSubjectStore = {
|
|
252
|
+
load(key: string): PersistedVideoAnalysis | null | Promise<PersistedVideoAnalysis | null>;
|
|
253
|
+
save(key: string, analysis: PersistedVideoAnalysis): void | Promise<void>;
|
|
254
|
+
remove?(key: string): void | Promise<void>;
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
type VideoSubjectAdapterOptions = {
|
|
258
|
+
tracking?: VideoTrackingProvider;
|
|
259
|
+
selector?: string;
|
|
260
|
+
root?: Document | Element;
|
|
261
|
+
observe?: boolean;
|
|
262
|
+
id?: string;
|
|
263
|
+
store?: VideoSubjectStore;
|
|
264
|
+
maxTrackingFramesPerSecond?: number;
|
|
265
|
+
onError?: (error: unknown, video: HTMLVideoElement) => void;
|
|
266
|
+
};
|
|
267
|
+
declare class VideoSubjectAdapter implements PopmeltSubjectAdapter {
|
|
268
|
+
private readonly options;
|
|
269
|
+
readonly surfaceKind: "video";
|
|
270
|
+
readonly id: string;
|
|
271
|
+
private readonly records;
|
|
272
|
+
private readonly videoKeys;
|
|
273
|
+
private readonly metadata;
|
|
274
|
+
private readonly analyzedSources;
|
|
275
|
+
private readonly listeners;
|
|
276
|
+
private readonly frameHandles;
|
|
277
|
+
private readonly persistTimers;
|
|
278
|
+
private readonly writeChains;
|
|
279
|
+
private readonly pendingWrites;
|
|
280
|
+
private readonly observer;
|
|
281
|
+
private refreshQueued;
|
|
282
|
+
private destroyed;
|
|
283
|
+
private manualSequence;
|
|
284
|
+
private activeTrackingKey;
|
|
285
|
+
private readyPromise;
|
|
286
|
+
constructor(options?: VideoSubjectAdapterOptions);
|
|
287
|
+
whenReady(): Promise<void>;
|
|
288
|
+
listSubjects(): readonly PopmeltSubject[];
|
|
289
|
+
refresh(): Promise<void>;
|
|
290
|
+
hitTest(point: {
|
|
291
|
+
x: number;
|
|
292
|
+
y: number;
|
|
293
|
+
}): PopmeltSubject | null;
|
|
294
|
+
resolve(key: string): PopmeltSubject | null;
|
|
295
|
+
captureSubject(key: string): Promise<Blob | null>;
|
|
296
|
+
beginCreate(point: {
|
|
297
|
+
x: number;
|
|
298
|
+
y: number;
|
|
299
|
+
}): PopmeltSubjectCreationSession | null;
|
|
300
|
+
renameSubject(key: string, label: string): PopmeltSubject | null;
|
|
301
|
+
updateSubjectBounds(key: string, bounds: PopmeltSubjectBounds): PopmeltSubject | null;
|
|
302
|
+
updateSubjectTrackingAnchors(key: string, anchors: readonly PopmeltSubjectTrackingAnchor[]): PopmeltSubject | null;
|
|
303
|
+
removeSubject(key: string): void;
|
|
304
|
+
destroy(): Promise<void>;
|
|
305
|
+
private analyze;
|
|
306
|
+
private addVideoListeners;
|
|
307
|
+
private removeVideoListeners;
|
|
308
|
+
private scheduleFrame;
|
|
309
|
+
private trackVideo;
|
|
310
|
+
private startSession;
|
|
311
|
+
private reseed;
|
|
312
|
+
private failTracking;
|
|
313
|
+
private activeRecordFor;
|
|
314
|
+
private activateMostRecentRecord;
|
|
315
|
+
private activateTrackingRecord;
|
|
316
|
+
private scheduleBackwardAnalysis;
|
|
317
|
+
private cancelBackwardAnalysis;
|
|
318
|
+
private runBackwardAnalysis;
|
|
319
|
+
private acceptObservation;
|
|
320
|
+
private openSegment;
|
|
321
|
+
private closeSegment;
|
|
322
|
+
private insertKeyframe;
|
|
323
|
+
private rebuildPresentationTrack;
|
|
324
|
+
private clearLiveFrames;
|
|
325
|
+
private videoObjectContext;
|
|
326
|
+
private replaceVideoRecords;
|
|
327
|
+
private persistVideo;
|
|
328
|
+
private schedulePersistence;
|
|
329
|
+
private flushScheduledPersistence;
|
|
330
|
+
private matchingVideos;
|
|
331
|
+
private videoIdentity;
|
|
332
|
+
private newObjectId;
|
|
333
|
+
private removeVideoRecords;
|
|
334
|
+
private removeVideo;
|
|
335
|
+
private queueRefresh;
|
|
336
|
+
}
|
|
337
|
+
declare function createVideoSubjectAdapter(options?: VideoSubjectAdapterOptions): VideoSubjectAdapter;
|
|
338
|
+
|
|
339
|
+
export { type VideoTrackingSeed as A, type BrowserImageSubjectStoreOptions as B, type VideoTrackingSession as C, createBrowserImageSubjectStore as D, createImageSubjectAdapter as E, createMemoryImageSubjectStore as F, createVideoSubjectAdapter as G, type ImageRecognitionProvider as I, type PersistedImageAnalysis as P, type VideoTrackingProvider as V, type ImageSubjectAdapterOptions as a, type VideoSubjectAdapterOptions as b, type ImageObjectBox as c, type VideoSubjectStore as d, type VideoObjectBox as e, type ImageContentHasher as f, type ImageObjectObservation as g, ImageSubjectAdapter as h, type ImageSubjectStore as i, type PersistedImageSubject as j, type PersistedImageSuppression as k, type PersistedVideoAnalysis as l, type PersistedVideoTrack as m, type VideoBackwardAnalysisOptions as n, type VideoBackwardAnalysisResult as o, type VideoMotionAttempt as p, type VideoMotionPolicy as q, type VideoMotionPresenceDecision as r, type VideoMotionState as s, VideoSubjectAdapter as t, type VideoTrackKeyframe as u, type VideoTrackObservation as v, type VideoTrackSegment as w, type VideoTrackSmoother as x, type VideoTrackingAnchor as y, type VideoTrackingAttempt as z };
|