@@ -3,13 +3,15 @@ import {DeliveryAction} from "./DeliveryAction.js";
33import { ProgressiveQualifier } from "../../qualifiers/progressive.js" ;
44import { FormatQualifier } from "../../qualifiers/format/FormatQualifier.js" ;
55import { ProgressiveType } from "../../types/types.js" ;
6+ import { IActionModel } from "../../internal/models/IActionModel.js" ;
7+ import { IDeliveryFormatModel } from "../../internal/models/IDeliveryActionModel.js" ;
68
79/**
810 * @memberOf Actions.Delivery
911 * @extends {Actions.Delivery.DeliveryAction }
1012 * @see Visit {@link Actions.Delivery|Delivery} for an example
1113 */
12- class DeliveryFormat extends DeliveryAction {
14+ class DeliveryFormatAction extends DeliveryAction {
1315 constructor ( deliveryKey ?: string , deliveryType ?: FormatQualifier | string | number ) {
1416 super ( deliveryKey , deliveryType , 'formatType' ) ;
1517 }
@@ -46,6 +48,30 @@ class DeliveryFormat extends DeliveryAction {
4648 this . addFlag ( preserveTransparency ( ) ) ;
4749 return this ;
4850 }
51+
52+ static fromJson ( actionModel : IActionModel ) : DeliveryFormatAction {
53+ const { formatType, lossy, progressive, preserveTransparency} = ( actionModel as IDeliveryFormatModel ) ;
54+ let result : DeliveryFormatAction ;
55+
56+ if ( formatType ) {
57+ result = new this ( 'f' , formatType ) ;
58+ } else {
59+ result = new this ( 'f' ) ;
60+ }
61+
62+ if ( progressive ) {
63+ if ( progressive . mode ) {
64+ result . progressive ( progressive . mode as unknown as ProgressiveQualifier ) ;
65+ } else {
66+ result . progressive ( ) ;
67+ }
68+ }
69+
70+ lossy && result . lossy ( ) ;
71+ preserveTransparency && result . preserveTransparency ( ) ;
72+
73+ return result ;
74+ }
4975}
5076
51- export { DeliveryFormat } ;
77+ export { DeliveryFormatAction } ;
0 commit comments