interfaces.d.ts 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. import type { BaseStyleProps } from '..';
  2. import type { DisplayObject } from '../display-objects';
  3. import type { CSSStyleValue } from './cssom';
  4. import type { CSSProperty } from './CSSProperty';
  5. /**
  6. * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type
  7. */
  8. export declare enum PropertySyntax {
  9. /**
  10. * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#coordinate
  11. */
  12. COORDINATE = "<coordinate>",
  13. /**
  14. * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#color
  15. */
  16. COLOR = "<color>",
  17. /**
  18. * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#paint
  19. */
  20. PAINT = "<paint>",
  21. /**
  22. * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#number
  23. */
  24. NUMBER = "<number>",
  25. /**
  26. * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/angle
  27. */
  28. ANGLE = "<angle>",
  29. /**
  30. * <number> with range 0..1
  31. * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#opacity_value
  32. */
  33. OPACITY_VALUE = "<opacity-value>",
  34. /**
  35. * <number> with range 0..Infinity
  36. */
  37. SHADOW_BLUR = "<shadow-blur>",
  38. /**
  39. * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#length
  40. */
  41. LENGTH = "<length>",
  42. /**
  43. * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#percentage
  44. */
  45. PERCENTAGE = "<percentage>",
  46. LENGTH_PERCENTAGE = "<length> | <percentage>",
  47. LENGTH_PERCENTAGE_12 = "[<length> | <percentage>]{1,2}",
  48. /**
  49. * @see https://developer.mozilla.org/en-US/docs/Web/CSS/margin#formal_syntax
  50. */
  51. LENGTH_PERCENTAGE_14 = "[<length> | <percentage>]{1,4}",
  52. /**
  53. * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#list-of-ts
  54. */
  55. LIST_OF_POINTS = "<list-of-points>",
  56. PATH = "<path>",
  57. /**
  58. * @see https://developer.mozilla.org/en-US/docs/Web/CSS/filter#formal_syntax
  59. */
  60. FILTER = "<filter>",
  61. Z_INDEX = "<z-index>",
  62. OFFSET_DISTANCE = "<offset-distance>",
  63. DEFINED_PATH = "<defined-path>",
  64. MARKER = "<marker>",
  65. TRANSFORM = "<transform>",
  66. TRANSFORM_ORIGIN = "<transform-origin>",
  67. TEXT = "<text>",
  68. TEXT_TRANSFORM = "<text-transform>"
  69. }
  70. export interface PropertyMetadata {
  71. n: string;
  72. /**
  73. * The interpolable flag indicates whether a property can be animated smoothly.
  74. * Default to `false`.
  75. */
  76. int?: boolean;
  77. /**
  78. * The property will inherit by default if no value is specified.
  79. * Default to `false`.
  80. */
  81. inh?: boolean;
  82. /**
  83. * This property affects only one field on ComputedStyle, and can be set
  84. * directly during inheritance instead of forcing a recalc.
  85. */
  86. ind?: boolean;
  87. /**
  88. * This specifies the default value for this field.
  89. * - for keyword fields, this is the initial keyword
  90. * - for other fields, this is a string containg the C++ expression that is used to initialise the field.
  91. */
  92. d?: string | ((nodeName: string) => string);
  93. /**
  94. * The resolved value used for getComputedStyle() depends on layout for this
  95. * property, which means we may need to update layout to return the correct
  96. * value from getComputedStyle().
  97. */
  98. l?: boolean;
  99. /**
  100. * This specifies all valid keyword values for the property.
  101. */
  102. k?: string[];
  103. /**
  104. * eg. strokeWidth is an alias of lineWidth
  105. */
  106. a?: string[];
  107. /**
  108. * sort before init attributes according to this priority
  109. */
  110. p?: number;
  111. /**
  112. * eg. <color> <paint> <number>
  113. */
  114. syntax?: string;
  115. }
  116. export interface PropertyParseOptions {
  117. skipUpdateAttribute: boolean;
  118. skipParse: boolean;
  119. forceUpdateGeometry: boolean;
  120. usedAttributes: string[];
  121. }
  122. export interface StyleValueRegistry {
  123. recalc: (displayObject: DisplayObject) => void;
  124. registerMetadata: (metadata: PropertyMetadata) => void;
  125. unregisterMetadata: (name: string) => void;
  126. getPropertySyntax: (syntax: string) => CSSProperty<any, any>;
  127. addUnresolveProperty: (object: DisplayObject, name: string) => void;
  128. processProperties: (object: DisplayObject, attributes: BaseStyleProps, options?: Partial<PropertyParseOptions>) => void;
  129. parseProperty: (name: string, value: any, object: DisplayObject) => CSSStyleValue;
  130. computeProperty: (name: string, computed: CSSStyleValue, object: DisplayObject) => any;
  131. }
  132. export interface LayoutRegistry {
  133. registerLayout: (name: string, ctor: any) => void;
  134. hasLayout: (name: string) => boolean;
  135. getLayout: (name: string) => any;
  136. }
  137. //# sourceMappingURL=interfaces.d.ts.map