Update types + fix generate_dts on linux

This commit is contained in:
Eric NGUYEN 2022-09-28 18:13:14 +02:00 committed by Eric
parent 18cbacaca1
commit 10260d3811
2 changed files with 510 additions and 474 deletions

View file

@ -27,7 +27,7 @@ export_pattern = re.compile(
r"export ([*] from [\"'\s].*[\"'\s]|{.*}(?: from [\"'\s].*[\"'\s])?);" r"export ([*] from [\"'\s].*[\"'\s]|{.*}(?: from [\"'\s].*[\"'\s])?);"
) )
filter_directories = ["./dist\Enums", "./dist\Interfaces"] filter_directories = ["./dist/Enums", "./dist/Interfaces", "./dist\Enums", "./dist\Interfaces"]
def main(): def main():
''' '''

982
src/dts/svgld.d.ts vendored
View file

@ -1,473 +1,509 @@
declare namespace SVGLD { declare namespace SVGLD {
/** /**
* Add method when creating a container * Add method when creating a container
* - Append will append to the last children in list * - Append will append to the last children in list
* - Insert will always place it at the begining * - Insert will always place it at the begining
* - Replace will remove the selected container and insert a new one * - Replace will remove the selected container and insert a new one
* (default: Append) * (default: Append)
*/ */
export enum AddMethod { export enum AddMethod {
Append = 0, Append = 0,
Insert = 1, Insert = 1,
Replace = 2 Replace = 2
} }
export enum MessageType { export enum MessageType {
Normal = 0, Normal = 0,
Success = 1, Success = 1,
Warning = 2, Warning = 2,
Error = 3 Error = 3
} }
/** export enum PositionReference {
* Describe the type of the property. TopLeft = 0,
* Used for the assignation in the OnPropertyChange function TopCenter = 1,
* See ContainerOperations.ts's OnPropertyChange TopRight = 2,
*/ CenterLeft = 3,
export enum PropertyType { CenterCenter = 4,
/** CenterRight = 5,
* Simple property: is not inside any object: id, x, width... (default) BottomLeft = 6,
*/ BottomCenter = 7,
Simple = 0, BottomRight = 8
/** }
* Style property: is inside the style object: stroke, fillOpacity...
*/ /**
Style = 1, * Describe the type of the property.
/** * Used for the assignation in the OnPropertyChange function
* Margin property: is inside the margin property: left, bottom, top, right... * See ContainerOperations.ts's OnPropertyChange
*/ */
Margin = 2 export enum PropertyType {
} /**
* Simple property: is not inside any object: id, x, width... (default)
export enum XPositionReference { */
Left = 0, Simple = 0,
Center = 1, /**
Right = 2 * Style property: is inside the style object: stroke, fillOpacity...
} */
Style = 1,
/**
* Margin property: is inside the margin property: left, bottom, top, right...
export interface IAction { */
Id: string; Margin = 2
CustomLogo: IImage; }
Label: string;
Description: string; export enum XPositionReference {
Action: string; Left = 0,
AddingBehavior: AddMethod; Center = 1,
} Right = 2
}
export interface IAction {
Id: string;
/** Model of available container used in application configuration */ CustomLogo: IImage;
export interface IAvailableContainer { Label: string;
/** type */ Description: string;
Type: string; Action: string;
/** displayed text */ AddingBehavior: AddMethod;
DisplayedText?: string; }
/** category */
Category?: string;
/** horizontal offset */
X?: number;
/** vertical offset */
Y?: number;
/** width */
Width?: number; /** Model of available container used in application configuration */
/** height */ export interface IAvailableContainer {
Height?: number; /** type */
/** Type: string;
* Minimum width (min=1) /** displayed text */
* Allows the container to set isRigidBody to false when it gets squeezed DisplayedText?: string;
* by an anchor /** category */
*/ Category?: string;
MinWidth?: number; /** orientation */
/** Orientation?: Orientation;
* Maximum width /** horizontal offset */
*/ X?: number;
MaxWidth?: number; /** vertical offset */
/** margin */ Y?: number;
Margin?: IMargin; /** width */
/** true if anchor, false otherwise */ Width?: number;
IsAnchor?: boolean; /** height */
/** true if flex, false otherwise */ Height?: number;
IsFlex?: boolean; /**
/** Method used on container add */ * Minimum width (min=1)
AddMethod?: AddMethod; */
/** Horizontal alignment, also determines the visual location of x {Left = 0, Center, Right } */ MinWidth?: number;
XPositionReference?: XPositionReference; /**
/** * Maximum width
* (optional) */
* Replace a <rect> by a customized "SVG". It is not really an svg but it at least allows MaxWidth?: number;
* to draw some patterns that can be bind to the properties of the container /**
* Use {prop} to bind a property. Use {{ styleProp }} to use an object. * Minimum height (min=1)
* Example : */
* ``` MinHeight?: number;
* `<rect width="{width}" height="{height}" style="{style}"></rect> /**
* <rect width="{width}" height="{height}" stroke="black" fill-opacity="0"></rect> * Maximum height
* <line x1="0" y1="0" x2="{width}" y2="{height}" stroke="black" style='{{ "transform":"scaleY(0.5)"}}'></line> */
* <line x1="{width}" y1="0" x2="0" y2="{height}" stroke="black" style='{userData.styleLine}'></line> MaxHeight?: number;
* ` /** margin */
* ``` Margin?: IMargin;
*/ /** true if anchor, false otherwise */
CustomSVG?: string; IsAnchor?: boolean;
/** /** true if flex, false otherwise */
* (optional) IsFlex?: boolean;
* Disabled when Pattern is used. /** Method used on container add */
* AddMethod?: AddMethod;
* Replace a <rect> by a customized "SVG". It is not really an svg but it at least allows /** Horizontal alignment, also determines the visual location of x {Left = 0, Center, Right } */
* to draw some patterns that can be bind to the properties of the container PositionReference?: PositionReference;
* Use {prop} to bind a property. Use {{ styleProp }} to use an object. /**
* Example : * (optional)
* ``` * Replace a <rect> by a customized "SVG". It is not really an svg but it at least allows
* `<rect width="{width}" height="{height}" style="{style}"></rect> * to draw some patterns that can be bind to the properties of the container
* <rect width="{width}" height="{height}" stroke="black" fill-opacity="0"></rect> * Use {prop} to bind a property. Use {{ styleProp }} to use an object.
* <line x1="0" y1="0" x2="{width}" y2="{height}" stroke="black" style='{{ "transform":"scaleY(0.5)"}}'></line> * Example :
* <line x1="{width}" y1="0" x2="0" y2="{height}" stroke="black" style='{userData.styleLine}'></line> * ```
* ` * `<rect width="{width}" height="{height}" style="{style}"></rect>
* ``` * <rect width="{width}" height="{height}" stroke="black" fill-opacity="0"></rect>
*/ * <line x1="0" y1="0" x2="{width}" y2="{height}" stroke="black" style='{{ "transform":"scaleY(0.5)"}}'></line>
DefaultChildType?: string; * <line x1="{width}" y1="0" x2="0" y2="{height}" stroke="black" style='{userData.styleLine}'></line>
/** * `
* Allow to use a Pattern to create the list of children * ```
* Cannot be used with DefaultChildType, */
* DefaultChildType will be disabled for this container and the children CustomSVG?: string;
*/ /**
Pattern?: string; * (optional)
/** Hide the children in the treeview */ * Disabled when Pattern is used.
HideChildrenInTreeview?: boolean; *
/** if true, show the dimension of the container */ * Replace a <rect> by a customized "SVG". It is not really an svg but it at least allows
ShowSelfDimensions?: boolean; * to draw some patterns that can be bind to the properties of the container
/** if true show the overall dimensions of its children */ * Use {prop} to bind a property. Use {{ styleProp }} to use an object.
ShowChildrenDimensions?: boolean; * Example :
/** * ```
* if true, allows a parent dimension borrower to uses its x coordinate for as a reference point for a dimension * `<rect width="{width}" height="{height}" style="{style}"></rect>
*/ * <rect width="{width}" height="{height}" stroke="black" fill-opacity="0"></rect>
MarkPositionToDimensionBorrower?: boolean; * <line x1="0" y1="0" x2="{width}" y2="{height}" stroke="black" style='{{ "transform":"scaleY(0.5)"}}'></line>
/** * <line x1="{width}" y1="0" x2="0" y2="{height}" stroke="black" style='{userData.styleLine}'></line>
* if true, show a dimension from the edge of the container to end * `
* and insert dimensions marks at lift up children (see liftDimensionToBorrower) * ```
*/ */
IsDimensionBorrower?: boolean; DefaultChildType?: string;
/** /**
* if true, hide the entry in the sidebar (default: false) * Allow to use a Pattern to create the list of children
*/ * Cannot be used with DefaultChildType,
IsHidden?: boolean; * DefaultChildType will be disabled for this container and the children
/** */
* Disable a list of available container to be added inside Pattern?: string;
*/ /** Hide the children in the treeview */
Blacklist?: string[]; HideChildrenInTreeview?: boolean;
/** /** if true, show the dimension of the container */
* Cannot be used with blacklist. Whitelist will be prioritized. ShowSelfDimensions?: boolean;
* To disable the whitelist, Whitelist must be undefined. /** if true show the overall dimensions of its children */
* Only allow a set of available container to be added inside ShowChildrenDimensions?: boolean;
*/ /**
Whitelist?: string[]; * if true, allows a parent dimension borrower to uses its x coordinate for as a reference point for a dimension
/** */
* (optional) MarkPositionToDimensionBorrower?: boolean;
* Style of the <rect> /**
*/ * if true, show a dimension from the edge of the container to end
Style?: React.CSSProperties; * and insert dimensions marks at lift up children (see liftDimensionToBorrower)
/** */
* List of possible actions shown on right-click IsDimensionBorrower?: boolean;
*/ /**
Actions?: IAction[]; * if true, hide the entry in the sidebar (default: false)
/** */
* (optional) IsHidden?: boolean;
* User data that can be used for data storage or custom SVG /**
*/ * Disable a list of available container to be added inside
UserData?: object; */
} Blacklist?: string[];
/**
* Cannot be used with blacklist. Whitelist will be prioritized.
* To disable the whitelist, Whitelist must be undefined.
/** * Only allow a set of available container to be added inside
* Model of available symbol to configure the application */ */
export interface IAvailableSymbol { Whitelist?: string[];
Name: string; /**
Image: IImage; * (optional)
Width?: number; * Style of the <rect>
Height?: number; */
XPositionReference?: XPositionReference; Style?: React.CSSProperties;
} /**
* List of possible actions shown on right-click
export interface ICategory { */
Type: string; Actions?: IAction[];
DisplayedText?: string; /**
} * (optional)
* User data that can be used for data storage or custom SVG
*/
UserData?: object;
}
/** Model of configuration for the application to configure it */
export interface IConfiguration {
AvailableContainers: IAvailableContainer[]; /**
AvailableSymbols: IAvailableSymbol[]; * Model of available symbol to configure the application */
Categories: ICategory[]; export interface IAvailableSymbol {
Patterns: IPattern[]; Name: string;
MainContainer: IAvailableContainer; Image: IImage;
} Width?: number;
Height?: number;
XPositionReference?: PositionReference;
export interface IContainerModel { }
children: IContainerModel[];
parent: IContainerModel | null; export interface ICategory {
properties: IContainerProperties; Type: string;
userData: Record<string, string | number>; DisplayedText?: string;
} }
/**
* Macro for creating the interface
* Do not add methods since they will be lost during serialization
*/
export class ContainerModel implements IContainerModel {
children: IContainerModel[]; /** Model of configuration for the application to configure it */
parent: IContainerModel | null; export interface IConfiguration {
properties: IContainerProperties; AvailableContainers: IAvailableContainer[];
userData: Record<string, string | number>; AvailableSymbols: IAvailableSymbol[];
constructor(parent: IContainerModel | null, properties: IContainerProperties, children?: IContainerModel[], userData?: {}); Categories: ICategory[];
} Patterns: IPattern[];
MainContainer: IAvailableContainer;
}
/** export interface IContainerModel {
* Properties of a container children: IContainerModel[];
*/ parent: IContainerModel | null;
export interface IContainerProperties { properties: IContainerProperties;
/** id of the container */ userData: Record<string, string | number>;
id: string; }
/** type matching the configuration on construction */ /**
type: string; * Macro for creating the interface
/** id of the parent container (null when there is no parent) */ * Do not add methods since they will be lost during serialization
parentId: string; */
/** id of the linked symbol ('' when there is no parent) */ export class ContainerModel implements IContainerModel {
linkedSymbolId: string; children: IContainerModel[];
/** Text displayed in the container */ parent: IContainerModel | null;
displayedText: string; properties: IContainerProperties;
/** horizontal offset */ userData: Record<string, string | number>;
x: number; constructor(parent: IContainerModel | null, properties: IContainerProperties, children?: IContainerModel[], userData?: {});
/** vertical offset */ }
y: number;
/** margin */
margin: IMargin;
/**
* Minimum width (min=1)
* Allows the container to set isRigidBody to false when it gets squeezed /**
* by an anchor * Properties of a container
*/ */
minWidth: number; export interface IContainerProperties {
/** /** id of the container */
* Maximum width id: string;
*/ /** type matching the configuration on construction */
maxWidth: number; type: string;
/** width */ /** id of the parent container (null when there is no parent) */
width: number; parentId: string;
/** height */ /** id of the linked symbol ('' when there is no parent) */
height: number; linkedSymbolId: string;
/** true if anchor, false otherwise */ /** Text displayed in the container */
isAnchor: boolean; displayedText: string;
/** true if flex, false otherwise */ /** orientation */
isFlex: boolean; orientation: Orientation;
/** Horizontal alignment, also determines the visual location of x {Left = 0, Center, Right } */ /** horizontal offset */
xPositionReference: XPositionReference; x: number;
/** Hide the children in the treeview */ /** vertical offset */
hideChildrenInTreeview: boolean; y: number;
/** if true, show the dimension of the container */ /** margin */
showSelfDimensions: boolean; margin: IMargin;
/** if true show the overall dimensions of its children */ /** width */
showChildrenDimensions: boolean; width: number;
/** /** height */
* if true, allows a parent dimension borrower to borrow its x coordinate height: number;
* as a reference point for a dimension /**
*/ * Minimum width (min=1)
markPositionToDimensionBorrower: boolean; */
/** minWidth: number;
* if true, show a dimension from the edge of the container to end /**
* and insert dimensions marks at lift up children (see liftDimensionToBorrower) * Maximum width
*/ */
isDimensionBorrower: boolean; maxWidth: number;
/** /**
* Warnings of a container * Minimum height (min=1)
*/ */
warning: string; minHeight: number;
/** /**
* (optional) * Maximum height
* Replace a <rect> by a customized "SVG". It is not really an svg but it at least allows */
* to draw some patterns that can be bind to the properties of the container maxHeight: number;
* Use {prop} to bind a property. Use {{ styleProp }} to use an object. /** true if anchor, false otherwise */
* Example : isAnchor: boolean;
* ``` /** true if flex, false otherwise */
* `<rect width="{width}" height="{height}" style="{style}"></rect> isFlex: boolean;
* <rect width="{width}" height="{height}" stroke="black" fill-opacity="0"></rect> /** Horizontal alignment, also determines the visual location of x {Left = 0, Center, Right } */
* <line x1="0" y1="0" x2="{width}" y2="{height}" stroke="black" style='{{ "transform":"scaleY(0.5)"}}'></line> positionReference: PositionReference;
* <line x1="{width}" y1="0" x2="0" y2="{height}" stroke="black" style='{userData.styleLine}'></line> /** Hide the children in the treeview */
* ` hideChildrenInTreeview: boolean;
* ``` /** if true, show the dimension of the container */
*/ showSelfDimensions: boolean;
customSVG?: string; /** if true show the overall dimensions of its children */
/** showChildrenDimensions: boolean;
* (optional) /**
* Style of the <rect> * if true, allows a parent dimension borrower to borrow its x coordinate
*/ * as a reference point for a dimension
style?: React.CSSProperties; */
/** markPositionToDimensionBorrower: boolean;
* (optional) /**
* User data that can be used for data storage or custom SVG * if true, show a dimension from the edge of the container to end
*/ * and insert dimensions marks at lift up children (see liftDimensionToBorrower)
userData?: object; */
} isDimensionBorrower: boolean;
/**
* Warnings of a container
*/
export interface IEditorState { warning: string;
history: IHistoryState[]; /**
historyCurrentStep: number; * (optional)
configuration: IConfiguration; * Replace a <rect> by a customized "SVG". It is not really an svg but it at least allows
} * to draw some patterns that can be bind to the properties of the container
* Use {prop} to bind a property. Use {{ styleProp }} to use an object.
* Example :
export interface IGetFeedbackRequest { * ```
/** Current application state */ * `<rect width="{width}" height="{height}" style="{style}"></rect>
ApplicationState: IHistoryState; * <rect width="{width}" height="{height}" stroke="black" fill-opacity="0"></rect>
} * <line x1="0" y1="0" x2="{width}" y2="{height}" stroke="black" style='{{ "transform":"scaleY(0.5)"}}'></line>
* <line x1="{width}" y1="0" x2="0" y2="{height}" stroke="black" style='{userData.styleLine}'></line>
* `
export interface IGetFeedbackResponse { * ```
messages: IMessage[]; */
} customSVG?: string;
/**
* (optional)
* Style of the <rect>
export interface IHistoryState { */
/** Last editor action */ style?: React.CSSProperties;
lastAction: string; /**
/** Reference to the main container */ * (optional)
mainContainer: IContainerModel; * User data that can be used for data storage or custom SVG
/** Id of the selected container */ */
selectedContainerId: string; userData?: object;
/** Counter of type of container. Used for ids. */ }
typeCounters: Record<string, number>;
/** List of symbols */
symbols: Map<string, ISymbolModel>;
/** Selected symbols id */ export interface IEditorState {
selectedSymbolId: string; history: IHistoryState[];
} historyCurrentStep: number;
configuration: IConfiguration;
/** }
* Model of an image with multiple source
* It must at least have one source.
* export interface IGetFeedbackRequest {
* If Url/Base64Image and Svg are set, /** Current application state */
* Url/Base64Image will be shown in the menu while SVG will be drawn ApplicationState: IHistoryState;
*/ }
export interface IImage {
/** Name of the image */
Name: string; export interface IGetFeedbackResponse {
/** (optional) Url of the image */ messages: IMessage[];
Url?: string; }
/** (optional) base64 data of the image */
Base64Image?: string;
/** (optional) SVG string */
Svg?: string; export interface IHistoryState {
} /** Last editor action */
lastAction: string;
/** Reference to the main container */
export interface IInputGroup { mainContainer: IContainerModel;
text: React.ReactNode; /** Id of the selected container */
value: string; selectedContainerId: string;
} /** Counter of type of container. Used for ids. */
typeCounters: Record<string, number>;
export interface IMargin { /** List of symbols */
left?: number; symbols: Map<string, ISymbolModel>;
bottom?: number; /** Selected symbols id */
top?: number; selectedSymbolId: string;
right?: number; }
}
/**
* Model of an image with multiple source
export interface IMessage { * It must at least have one source.
text: string; *
type: MessageType; * If Url/Base64Image and Svg are set,
} * Url/Base64Image will be shown in the menu while SVG will be drawn
*/
export interface IImage {
export interface IPattern { /** Name of the image */
/** Name: string;
* Unique id for the pattern /** (optional) Url of the image */
*/ Url?: string;
id: string; /** (optional) base64 data of the image */
/** Base64Image?: string;
* Text to display in the sidebar /** (optional) SVG string */
*/ Svg?: string;
text: string; }
/**
* IAvailableContainer id used to wrap the children.
*/ export interface IInputGroup {
wrapper: string; key: string;
/** text: React.ReactNode;
* List of ids of Pattern or IAvailableContainer value: string;
* If a IAvailableContainer and a Pattern have the same id, }
* IAvailableContainer will be prioritized
*/ export interface IMargin {
children: string[]; left?: number;
} bottom?: number;
export type ContainerOrPattern = IAvailableContainer | IPattern; top?: number;
export function GetPattern(id: string, configs: Map<string, IAvailableContainer>, patterns: Map<string, IPattern>): ContainerOrPattern | undefined; right?: number;
export function IsPattern(id: string, configs: Map<string, IAvailableContainer>, patterns: Map<string, IPattern>): boolean; }
export interface IPoint {
x: number; export interface IMessage {
y: number; text: string;
} type: MessageType;
}
export interface ISetContainerListRequest { export interface IPattern {
/** Name of the action declared in the API */ /**
Action: string; * Unique id for the pattern
/** Selected container */ */
Container: IContainerModel; id: string;
/** The previous sibling container */ /**
PreviousContainer: IContainerModel | undefined; * Text to display in the sidebar
/** The next sibling container */ */
NextContainer: IContainerModel | undefined; text: string;
/** Current application state */ /**
ApplicationState: IHistoryState; * IAvailableContainer id used to wrap the children.
} */
wrapper: string;
/**
export interface ISetContainerListResponse { * List of ids of Pattern or IAvailableContainer
Containers: IAvailableContainer[]; * If a IAvailableContainer and a Pattern have the same id,
} * IAvailableContainer will be prioritized
*/
/** children: string[];
* A SizePointer is a pointer in a 1 dimensional array of width/space }
* x being the address where the pointer is pointing export type ContainerOrPattern = IAvailableContainer | IPattern;
* width being the overall (un)allocated space affected to the address export function GetPattern(id: string, configs: Map<string, IAvailableContainer>, patterns: Map<string, IPattern>): ContainerOrPattern | undefined;
*/ export function IsPattern(id: string, configs: Map<string, IAvailableContainer>, patterns: Map<string, IPattern>): boolean;
export interface ISizePointer {
x: number; export interface IPoint {
width: number; x: number;
} y: number;
}
export interface ISymbolModel {
/** Identifier */
id: string; export interface ISetContainerListRequest {
/** Type */ /** Name of the action declared in the API */
type: string; Action: string;
/** Configuration of the symbol */ /** Selected container */
config: IAvailableSymbol; Container: IContainerModel;
/** Horizontal offset */ /** The previous sibling container */
x: number; PreviousContainer: IContainerModel | undefined;
/** Width */ /** The next sibling container */
width: number; NextContainer: IContainerModel | undefined;
/** Height */ /** Current application state */
height: number; ApplicationState: IHistoryState;
/** List of linked container id */ }
linkedContainers: Set<string>;
}
export interface ISetContainerListResponse {
} Containers: IAvailableContainer[];
}
/**
* A SizePointer is a pointer in a 1 dimensional array of width/space
* x being the address where the pointer is pointing
* width being the overall (un)allocated space affected to the address
*/
export interface ISizePointer {
x: number;
width: number;
}
export interface ISymbolModel {
/** Identifier */
id: string;
/** Type */
type: string;
/** Configuration of the symbol */
config: IAvailableSymbol;
/** Horizontal offset */
x: number;
/** Width */
width: number;
/** Height */
height: number;
/** List of linked container id */
linkedContainers: Set<string>;
}
export enum Orientation {
Horizontal = 0,
Vertical = 1
}
}