@vidispine/vdt-js 23.1.0-pre.4 → 23.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -152,9 +152,13 @@ type InputGroup = {
152
152
  } & Partial<MetadataGroupValueType>;
153
153
  /** Input to create a timespan of */
154
154
  type InputTimespan = {
155
+ /** Start for timespan */
155
156
  start?: string | number;
157
+ /** End for timespan */
156
158
  end?: string | number;
159
+ /** Base for timespan (typically undefined) */
157
160
  base?: string;
161
+ /** Group or field metadata */
158
162
  [groupOrFieldName: string]: InputGroupsOrFields;
159
163
  };
160
164
  type CreateMetadataTypeInput = InputTimespan | InputTimespan[];
@@ -175,6 +179,7 @@ type ParsedValue<TOptions> = TOptions extends {
175
179
  value: string;
176
180
  } & ParsedValueAttributes;
177
181
  type ParseValueOptions = {
182
+ /** Include attributes on value (`true` for all) */
178
183
  includeValueAttributes?: boolean | (keyof ParsedValueAttributes)[];
179
184
  };
180
185
 
@@ -184,10 +189,12 @@ type ParsedValueList<TOptions> = TOptions extends {
184
189
  } ? string : TOptions extends {
185
190
  arrayOnSingleValue?: true;
186
191
  } ? ParsedValue<TOptions>[] : ParsedValue<TOptions> | ParsedValue<TOptions>[];
187
- type ParseValueListOptions = {
192
+ interface ParseValueListOptions extends ParseValueOptions {
193
+ /** String to join the values, (e.g. `,`) */
188
194
  joinValue?: string;
195
+ /** Return values as array even if single value */
189
196
  arrayOnSingleValue?: boolean;
190
- } & ParseValueOptions;
197
+ }
191
198
 
192
199
  type ParsedFieldAttributes = Partial<Omit<MetadataFieldValueType, 'value'>>;
193
200
  type ParsedFieldObject<TOptions> = {
@@ -196,15 +203,19 @@ type ParsedFieldObject<TOptions> = {
196
203
  type ParsedField<TOptions> = TOptions extends {
197
204
  includeFieldAttributes?: false;
198
205
  } ? ParsedValueList<TOptions> : ParsedFieldObject<TOptions>;
199
- type ParseFieldOptions = {
206
+ interface ParseFieldOptions extends ParseValueListOptions {
207
+ /** Include attributes on field (`true` for all) */
200
208
  includeFieldAttributes?: boolean | (keyof ParsedFieldAttributes)[];
201
- } & ParseValueListOptions;
209
+ }
202
210
 
203
- type ParseFieldListOptions = {
211
+ interface ParseFieldListOptions extends ParseFieldOptions {
212
+ /** Return fields as list */
204
213
  fieldAsList?: boolean;
214
+ /** Return fields as array even if only one field */
205
215
  arrayOnSingleField?: boolean;
216
+ /** Return all fields flattened (Note: keys might be overridden) */
206
217
  overrideField?: boolean;
207
- } & ParseFieldOptions;
218
+ }
208
219
  type ParsedFieldList<TOptions> = TOptions extends {
209
220
  fieldAsList?: true;
210
221
  } ? ParsedField<TOptions>[] : TOptions extends {
@@ -244,12 +255,16 @@ type ParsedFieldList<TOptions> = TOptions extends {
244
255
  declare const parseFieldList: <TOptions extends ParseFieldListOptions = ParseFieldListOptions>(fieldList: MetadataFieldValueType[], options?: TOptions) => ParsedFieldList<TOptions>;
245
256
 
246
257
  type ParsedGroupAttributes = Omit<MetadataGroupValueType, 'field' | 'group'>;
247
- type ParseGroupOptions = {
258
+ interface ParseGroupOptions extends ParseFieldListOptions {
259
+ /** Include group attributes (`true` for all) */
248
260
  includeGroupAttributes?: boolean | (keyof ParsedGroupAttributes)[];
261
+ /** Return groups as list */
249
262
  groupAsList?: boolean;
263
+ /** Return groups as array even if only one group */
250
264
  arrayOnSingleGroup?: boolean;
265
+ /** Return all groups flattened (Note: keys might be overridden) */
251
266
  overrideGroup?: boolean;
252
- } & ParseFieldListOptions;
267
+ }
253
268
  type ParsedGroup<TOptions> = ((TOptions extends {
254
269
  groupAsList?: true;
255
270
  } ? {
@@ -301,24 +316,14 @@ type ParsedGroupList<TOptions> = TOptions extends {
301
316
  declare const parseGroupList: <TOptions extends ParseGroupOptions = ParseGroupOptions>(groupList: MetadataGroupValueType[], options?: TOptions) => ParsedGroupList<TOptions>;
302
317
 
303
318
  type ParsedTimespanAttributes = Omit<MetadataType['timespan'][number], 'field' | 'group'>;
304
- /**
305
- * __includeTimespanAttributes__:
306
- * Include attributes on timespan
307
- * (Set `true` or "array of attribute keys" to include specific attributes)
308
- *
309
- * __arrayOnSingle__:
310
- * Return groups, fields and values as array if single
311
- *
312
- * __flat__:
313
- * Return a flat (no array) representation of the timespan (Note: fields/groups might be overridden)
314
- *
315
- * @defaultValue `{ includeTimespanAttributes: false, arrayOnSingle: true, flat: false }`
316
- */
317
- type ParseTimespanOptions = {
319
+ interface ParseTimespanOptions extends ParseGroupListOptions {
320
+ /** Include attributes on timespan (`true` for all) */
318
321
  includeTimespanAttributes?: boolean | (keyof ParsedTimespanAttributes)[];
322
+ /** Return groups, fields, and values as array */
319
323
  arrayOnSingle?: boolean;
324
+ /** Flatten timespan, groups and fields (Note: keys might be overridden) */
320
325
  flat?: boolean;
321
- } & ParseGroupListOptions;
326
+ }
322
327
  type ParsedTimespan<TOptions> = ((TOptions extends {
323
328
  groupAsList?: true;
324
329
  } ? {
@@ -359,13 +364,18 @@ type ParsedTimespanList<TOptions> = TOptions extends {
359
364
  } ? ParsedTimespan<TOptions> : {
360
365
  [timespanKey: string]: ParsedTimespan<TOptions>[];
361
366
  };
362
- type ParseTimespanListOptions = {
367
+ interface ParseTimespanListOptions extends ParseTimespanOptions {
368
+ /** Return timespans as list */
363
369
  timespanAsList?: boolean;
370
+ /** String to join timespans with (defaults to '_') */
364
371
  joinTimespan?: string;
372
+ /** Sort timespanList by ascending start then end time */
365
373
  sortTimespan?: boolean;
374
+ /** Return a flat representation - only one timespan with groups/fields named the same as single - of the timespan list (Note: timespans/fields/groups can be overridden) */
366
375
  flat?: boolean;
376
+ /** Flatten timespans to one object with generic timespan having highest priority (Note: fields/groups might be overridden) */
367
377
  flatTimespan?: boolean;
368
- } & ParseTimespanOptions;
378
+ }
369
379
  /**
370
380
  * Parses timespanList according to specified options.
371
381
  * The attributes can be targeted for each sub-type.
@@ -394,10 +404,12 @@ type ParsedMetadataType<TOptions> = (TOptions extends {
394
404
  }) & (TOptions extends {
395
405
  includeMetadataAttributes?: true | string[];
396
406
  } ? ParsedMetadataAttributes : {});
397
- type ParseMetadataTypeOptions = {
407
+ interface ParseMetadataTypeOptions extends ParseTimespanListOptions {
408
+ /** Include metadata attributes (`true` for all) */
398
409
  includeMetadataAttributes?: boolean | (keyof ParsedMetadataAttributes)[];
410
+ /** Flatten timespans, groups and fields (Note: keys might be overridden) */
399
411
  flat?: boolean;
400
- } & ParseTimespanListOptions;
412
+ }
401
413
  /**
402
414
  * Parses MetadataType according to specified options
403
415
  *
@@ -431,7 +443,9 @@ declare const parseSimpleMetadataType: (simpleMetadataType: SimpleMetadataType)
431
443
  };
432
444
 
433
445
  type MetadataTypeToWebVttOptions = {
446
+ /** Name of group containing subtitle field/text */
434
447
  subtitleGroup?: string;
448
+ /** Name of field (text) to use for the subtitles */
435
449
  subtitleField?: string;
436
450
  };
437
451
  /**
@@ -518,8 +532,11 @@ type ParsedFacetType = {
518
532
  declare const parseFacetType: (facetType?: FacetType[]) => ParsedFacetType;
519
533
 
520
534
  type ParseHighlightTimespanOptions = {
535
+ /** Return an array if there is a single value */
521
536
  arrayOnSingle?: boolean;
537
+ /** Return timespans as list */
522
538
  timespanAsList?: boolean;
539
+ /** String to join the values (e.g. `,`) */
523
540
  joinValue?: string;
524
541
  };
525
542
  type ParsedHighlightTimespan = {
@@ -537,12 +554,16 @@ type ParsedHighlightTimespan = {
537
554
  */
538
555
  declare const parseHighlightTimespan: (timespan: SearchResultEntryTimespanType, options: ParseHighlightTimespanOptions) => ParsedHighlightTimespan;
539
556
 
540
- type ParseHighlightTimespanListOptions = {
557
+ interface ParseHighlightTimespanListOptions extends ParseHighlightTimespanOptions {
558
+ /** Return parsed timespan as list (in an array) */
541
559
  timespanAsList?: boolean;
560
+ /** Character to join the start/end time codes with */
542
561
  joinTimespan?: string;
562
+ /** Flatten to field-name/field-value (Note: field-values may be overwritten) */
543
563
  flat?: boolean;
564
+ /** Flatten timespan to object with start/end as key */
544
565
  flatTimespan?: boolean;
545
- } & ParseHighlightTimespanOptions;
566
+ }
546
567
  /**
547
568
  * Parses highlight timespans from VidiCore into key/value object.
548
569
  * The attributes can be targeted for each sub-type.
@@ -671,7 +692,9 @@ type ParsedContainerComponentType = {
671
692
  declare const parseContainerComponent: (containerComponentType?: ContainerComponentType) => ParsedContainerComponentType;
672
693
 
673
694
  type TimeBaseInput = {
695
+ /** The numerator for the TimeBase */
674
696
  numerator?: number | string;
697
+ /** The denominator for the TimeBase */
675
698
  denominator?: number | string;
676
699
  };
677
700
  /**
@@ -682,7 +705,9 @@ type TimeBaseInput = {
682
705
  * @category Time
683
706
  */
684
707
  declare class TimeBase {
708
+ /** The numerator for the TimeBase */
685
709
  numerator: number;
710
+ /** The denominator for the TimeBase */
686
711
  denominator: number;
687
712
  /**
688
713
  * Constructor for TimeBase
@@ -707,31 +732,32 @@ declare class TimeBase {
707
732
  * @returns Text representation of the TimeBase
708
733
  */
709
734
  toText(options?: {
735
+ /** Show time base as constant (e.g. PAL) */
710
736
  constant?: boolean;
737
+ /** Show time base as fraction (25:1) even when numerator is 1 */
711
738
  fraction?: boolean;
712
739
  }): string;
713
740
  /**
714
741
  * Output TimeBase as frame rate (by default max 16 decimal places)
715
742
  *
716
743
  * @remarks
717
- * For `options.fixed`:
718
- * - `true` gives two decimal places
719
- * - `false` gives max amount of decimal places
720
- * - `number` gives that amount of decimal places
721
- *
722
744
  * Default format: rate with two decimals if needed (i.e. decimals are > 0)
723
745
  *
724
- * Option precedence (when all true): `constant` > `rounded` > `fixed`
746
+ * `rounded` has precedence over `fixed`
725
747
  *
726
- * @param options For how to display it as rate
748
+ * @param options On how to return the rate
727
749
  *
728
750
  * @return Rate of the TimeBase
729
- *
730
- * @category Time
731
751
  */
732
752
  toRate(options?: {
733
- fixed?: boolean | number;
753
+ /** Rounded to nearest integer */
734
754
  rounded?: boolean;
755
+ /** Amount of decimal places
756
+ * - `true` two decimal places
757
+ * - `false` max amount of decimal places
758
+ * - `number` that amount of decimal places
759
+ */
760
+ fixed?: boolean | number;
735
761
  }): number;
736
762
  /**
737
763
  * Get TimeBase in a object representation
@@ -778,11 +804,15 @@ declare const formatTimeBaseText: (timeBaseText?: string | number) => TimeBase;
778
804
  declare const formatTimeBaseType: (timeBase: TimeBaseInput) => TimeBase;
779
805
 
780
806
  type TimeCodeInput = {
807
+ /** Amount of samples for the time code */
781
808
  samples?: number | string;
809
+ /** The time base for the time code */
782
810
  timeBase?: string | TimeBaseInput | TimeBase;
783
811
  };
784
812
  type TimeCodeInputOptions = {
813
+ /** If time code is dropFrame or not (by default checks timeBase) */
785
814
  dropFrame?: boolean;
815
+ /** Separator for frame in smpte output (default ":" for non-drop-frame and ";" for dropFrame) */
786
816
  frameSeparator?: string;
787
817
  };
788
818
  /**
@@ -793,9 +823,13 @@ type TimeCodeInputOptions = {
793
823
  * @category Time
794
824
  */
795
825
  declare class TimeCode {
826
+ /** Amount of samples for the time code */
796
827
  samples: number;
828
+ /** The time base for the time code */
797
829
  timeBase: TimeBase;
830
+ /** If time code is dropFrame or not (by default checks timeBase) */
798
831
  dropFrame?: boolean;
832
+ /** Separator for frame in smpte output (default ":" for non-drop-frame and ";" for dropFrame) */
799
833
  frameSeparator?: string;
800
834
  /**
801
835
  * Constructor for TimeCode
@@ -806,12 +840,15 @@ declare class TimeCode {
806
840
  constructor(timeCodeType: TimeCodeInput, options?: TimeCodeInputOptions);
807
841
  /**
808
842
  * Return this TimeCode added with the supplied timeCodeType
809
- * If time bases differ, it will retain the time base of this TimeCode instance
810
- * If supplied time code has a more granular time base - it will round down exceeding samples (hasn't reached that sample yet)
843
+ * - If time bases differ, it will retain the time base of this TimeCode instance
844
+ * - If supplied time code has a more granular time base, it will round down exceeding samples (hasn't reached that sample yet)
845
+ *
846
+ * @remarks
847
+ * If you don't want to "lose" frames in the manner described above, make sure time code you're operating on has higher time base granularity
811
848
  *
812
- * Note: This might make you "lose" frames depending on granularity of time bases, e.g.
813
- * "51@50".add("25@25") => "101@50"
814
- * while "25@25".add("51@50") => "50@25" (not "101@50")
849
+ * To exemplify:
850
+ * - "51@50".add("25@25") => "101@50"
851
+ * - while "25@25".add("51@50") => "50@25"
815
852
  *
816
853
  * @param timeCode A TimeCode instance you want to add with
817
854
  * @returns A new TimeCode instance with the addition applied
@@ -819,12 +856,15 @@ declare class TimeCode {
819
856
  add(timeCode: TimeCode): TimeCode;
820
857
  /**
821
858
  * Return this TimeCode subtracted with the supplied timeCodeType
822
- * If time bases differ, it will retain the time base of the instance time code
823
- * If supplied time code has a more granular time base - it will round down exceeding samples (hasn't reached that sample yet)
859
+ * - If time bases differ, it will retain the time base of the instance time code
860
+ * - If supplied time code has a more granular time base, it will round down exceeding samples (hasn't reached that sample yet)
824
861
  *
825
- * Note: This might make you "lose" frames depending on granularity of time bases, e.g.
826
- * "101@50".subtract("25@25") => "51@50"
827
- * while "50@25".subtract("51@50") => "25@25" (not "49@50")
862
+ * @remarks
863
+ * If you don't want to "lose" frames in the manner described above, make sure time code you're operating on has higher time base granularity
864
+
865
+ * To exemplify:
866
+ * - "101@50".subtract("25@25") => "51@50"
867
+ * - while "50@25".subtract("51@50") => "25@25"
828
868
  *
829
869
  * @param timeCode A TimeCode instance you want to subtract with
830
870
  * @returns A new TimeCode instance with the subtraction applied
@@ -833,29 +873,32 @@ declare class TimeCode {
833
873
  /**
834
874
  * Creates a new TimeCode instance with specified timeBase and samples adjusted to that.
835
875
  *
876
+ * @remarks
836
877
  * If it conforms to a less granular time base - it will floor samples (hasn't reached that sample yet)
837
878
  * - e.g. "51@50".conformTo("PAL") => "25@PAL" (not "26@PAL")
838
879
  *
839
880
  * @param timeBase The TimeBase it should conform the TimeCode to
881
+ * @param options Explicitly set TimeCode options, by default these are derived from `timeBase`
840
882
  * @returns A new TimeCode instance with the conformTo timeBase applied
841
883
  */
842
- conformTimeBase(timeBase: TimeCodeInput['timeBase']): TimeCode;
884
+ conformTimeBase(timeBase: TimeCodeInput['timeBase'], options?: TimeCodeInputOptions): TimeCode;
843
885
  /**
844
886
  * Get TimeCode as a text representation
845
887
  *
846
888
  * @remarks
847
- * Default format: samples@denominator(:numerator if > 1)
889
+ * Default format: `samples@denominator[:numerator (if > 1)])`
848
890
  *
849
891
  * `constant` has precedence over `fraction` if both are true
850
892
  *
851
893
  * @param options Options for how to format text
852
894
  * @returns Text representation of TimeCode
853
- *
854
- * @category Time
855
895
  */
856
896
  toText(options?: {
897
+ /** Include time base even if seconds (i.e. append @1 or @1:1) */
857
898
  includeTimeBaseForSeconds?: boolean;
899
+ /** show as constant (e.g. @PAL) */
858
900
  constant?: boolean;
901
+ /** show as fraction (e.g. @25:1) */
859
902
  fraction?: boolean;
860
903
  }): string;
861
904
  /**
@@ -871,7 +914,8 @@ declare class TimeCode {
871
914
  };
872
915
  /**
873
916
  * Get TimeCode in a time object representation
874
- * "milliseconds" is rounded down, if you want another representation use "partialSeconds"
917
+ *
918
+ * Note: "milliseconds" is rounded down - use "partialSeconds" for another representation
875
919
  *
876
920
  * @returns Time for the time code
877
921
  */
@@ -890,14 +934,15 @@ declare class TimeCode {
890
934
  toSeconds(): number;
891
935
  /**
892
936
  * Get TimeCode in a duration representation
893
- * The time unit char keys for the format string are:
894
- * - "h" for hour
895
- * - "m" for minute
896
- * - "s" for seconds
897
- * - "S" for milliseconds
898
- * Any other char will be kept in the duration output string.
899
937
  *
900
- * Add consecutive chars for zero padding.
938
+ * The time unit keys for the format string are:
939
+ * - `h` for hour
940
+ * - `m` for minute
941
+ * - `s` for seconds
942
+ * - `S` for milliseconds
943
+ * - Any other char will be kept in the duration output string
944
+ *
945
+ * Note: Add several consecutive chars for zero padding.
901
946
  *
902
947
  * By default it:
903
948
  * - uses colon delimiter (e.g. for format "hhmmss")
@@ -907,6 +952,7 @@ declare class TimeCode {
907
952
  * @returns Duration representation of the TimeCode
908
953
  */
909
954
  toDuration(options?: {
955
+ /** Specify format of duration string, (e.g. `hh:mm:ss.S` for "01:23:04.5") */
910
956
  format?: string;
911
957
  }): string;
912
958
  /**
@@ -935,10 +981,20 @@ declare class TimeCode {
935
981
  };
936
982
  }
937
983
 
938
- type FormatTimeCodeSecondsOptions = {
984
+ interface FormatTimeCodeSecondsOptions extends TimeCodeInputOptions {
985
+ /**
986
+ * The TimeBase the output TimeCode should have
987
+ *
988
+ * Note: if unset and useGCD=false, denominator will be 10^(amount-of-decimals)
989
+ */
939
990
  timeBase?: number | string | TimeBaseInput;
991
+ /**
992
+ * Samples and denominator are divided with GCD
993
+ *
994
+ * e.g. `1.04 => 104@100 => 26@25` (if no explicit `timeBase` is set)
995
+ */
940
996
  useGCD?: boolean;
941
- } & TimeCodeInputOptions;
997
+ }
942
998
  /**
943
999
  * Format seconds to TimeCode object
944
1000
  *
@@ -958,19 +1014,19 @@ type FormatTimeCodeSecondsOptions = {
958
1014
  */
959
1015
  declare const formatTimeCodeSeconds: (seconds: string | number, options?: FormatTimeCodeSecondsOptions) => TimeCode;
960
1016
 
961
- type FormatTimeCodeSmpteOptions = {
1017
+ interface FormatTimeCodeSmpteOptions extends TimeCodeInputOptions {
1018
+ /** TimeBase of smpte (and consequently TimeBase of output TimeCode) */
962
1019
  timeBase?: number | string | TimeBaseInput;
1020
+ /** How to handle exceeding values (default `error`) */
963
1021
  exceedingMode?: 'add' | 'ignore' | 'error';
964
- dropFrame?: boolean;
965
- frameSeparator?: string;
966
- } & Omit<TimeCodeInputOptions, 'dropFrame' | ' frameSeparator'>;
1022
+ }
967
1023
  /**
968
1024
  * Format smpte text to a TimeCode Instance
969
1025
  *
970
- * exceedingMode:
971
- * - "overflow" exceeding values will be kept (e.g. PAL and 00:00:00:25 => 00:00:01:00)
972
- * - "truncate" exceeding values will be truncated (e.g. PAL and 00:00:00:25 => 00:00:00:24)
973
- * - "error" exceeding values will throw error (e.g. PAL and 00:00:00:25 => Error)
1026
+ * Options for `exceedingMode`:
1027
+ * - `add` will be overflow to higher unit (e.g. PAL and 00:00:00:25 => 00:00:01:00)
1028
+ * - `ignore` will be truncated (e.g. PAL and 00:00:00:25 => 00:00:00:24)
1029
+ * - `error` will throw error (e.g. PAL and 00:00:00:25 => Error)
974
1030
  *
975
1031
  * @param smpte String representation of smpte
976
1032
  * @param options Options for creating the time code from smpte
@@ -980,9 +1036,10 @@ type FormatTimeCodeSmpteOptions = {
980
1036
  */
981
1037
  declare const formatTimeCodeSmpte: (smpte: string, options?: FormatTimeCodeSmpteOptions) => TimeCode;
982
1038
 
983
- type FormatTimeCodeTextOptions = {
1039
+ interface FormatTimeCodeTextOptions extends TimeCodeInputOptions {
1040
+ /** The time base the returned TimeCode should have */
984
1041
  timeBase?: number | string | TimeBaseInput;
985
- } & TimeCodeInputOptions;
1042
+ }
986
1043
  /**
987
1044
  * Format text to a TimeCode instance
988
1045
  *
@@ -1129,7 +1186,7 @@ type FilterShapeSourceOption = {
1129
1186
  *
1130
1187
  * @category Shape
1131
1188
  */
1132
- declare const filterShapeSource: (itemType: ItemType, options: FilterShapeSourceOption) => FilteredShapeListObject[];
1189
+ declare const filterShapeSource: (itemType: ItemType, options?: FilterShapeSourceOption) => FilteredShapeListObject[];
1133
1190
 
1134
1191
  type ShapeMediaType = keyof typeof SHAPE_MEDIA_TYPES;
1135
1192
  /**