4bf2ca120a50df950f407345c9a25e605c8173c9.svn-base 14.7 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413
// Type definitions for yoga-layout 1.9
// Project: https://github.com/facebook/yoga#readme
// Definitions by: tnobody <https://github.com/tnobody>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1

declare const ALIGN_AUTO: 0;
declare const ALIGN_COUNT: 8;
declare const ALIGN_FLEX_START: 1;
declare const ALIGN_CENTER: 2;
declare const ALIGN_FLEX_END: 3;
declare const ALIGN_STRETCH: 4;
declare const ALIGN_BASELINE: 5;
declare const ALIGN_SPACE_BETWEEN: 6;
declare const ALIGN_SPACE_AROUND: 7;
declare const DIMENSION_COUNT: 2;
declare const DIMENSION_WIDTH: 0;
declare const DIMENSION_HEIGHT: 1;
declare const DIRECTION_COUNT: 3;
declare const DIRECTION_INHERIT: 0;
declare const DIRECTION_LTR: 1;
declare const DIRECTION_RTL: 2;
declare const DISPLAY_COUNT: 2;
declare const DISPLAY_FLEX: 0;
declare const DISPLAY_NONE: 1;
declare const EDGE_COUNT: 9;
declare const EDGE_LEFT: 0;
declare const EDGE_TOP: 1;
declare const EDGE_RIGHT: 2;
declare const EDGE_BOTTOM: 3;
declare const EDGE_START: 4;
declare const EDGE_END: 5;
declare const EDGE_HORIZONTAL: 6;
declare const EDGE_VERTICAL: 7;
declare const EDGE_ALL: 8;
declare const EXPERIMENTAL_FEATURE_COUNT: 1;
declare const EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS: 0;
declare const FLEX_DIRECTION_COUNT: 4;
declare const FLEX_DIRECTION_COLUMN: 0;
declare const FLEX_DIRECTION_COLUMN_REVERSE: 1;
declare const FLEX_DIRECTION_ROW: 2;
declare const FLEX_DIRECTION_ROW_REVERSE: 3;
declare const JUSTIFY_COUNT: 6;
declare const JUSTIFY_FLEX_START: 0;
declare const JUSTIFY_CENTER: 1;
declare const JUSTIFY_FLEX_END: 2;
declare const JUSTIFY_SPACE_BETWEEN: 3;
declare const JUSTIFY_SPACE_AROUND: 4;
declare const JUSTIFY_SPACE_EVENLY: 5;
declare const LOG_LEVEL_COUNT: 6;
declare const LOG_LEVEL_ERROR: 0;
declare const LOG_LEVEL_WARN: 1;
declare const LOG_LEVEL_INFO: 2;
declare const LOG_LEVEL_DEBUG: 3;
declare const LOG_LEVEL_VERBOSE: 4;
declare const LOG_LEVEL_FATAL: 5;
declare const MEASURE_MODE_COUNT: 3;
declare const MEASURE_MODE_UNDEFINED: 0;
declare const MEASURE_MODE_EXACTLY: 1;
declare const MEASURE_MODE_AT_MOST: 2;
declare const NODE_TYPE_COUNT: 2;
declare const NODE_TYPE_DEFAULT: 0;
declare const NODE_TYPE_TEXT: 1;
declare const OVERFLOW_COUNT: 3;
declare const OVERFLOW_VISIBLE: 0;
declare const OVERFLOW_HIDDEN: 1;
declare const OVERFLOW_SCROLL: 2;
declare const POSITION_TYPE_COUNT: 2;
declare const POSITION_TYPE_RELATIVE: 0;
declare const POSITION_TYPE_ABSOLUTE: 1;
declare const PRINT_OPTIONS_COUNT: 3;
declare const PRINT_OPTIONS_LAYOUT: 1;
declare const PRINT_OPTIONS_STYLE: 2;
declare const PRINT_OPTIONS_CHILDREN: 4;
declare const UNIT_COUNT: 4;
declare const UNIT_UNDEFINED: 0;
declare const UNIT_POINT: 1;
declare const UNIT_PERCENT: 2;
declare const UNIT_AUTO: 3;
declare const WRAP_COUNT: 3;
declare const WRAP_NO_WRAP: 0;
declare const WRAP_WRAP: 1;
declare const WRAP_WRAP_REVERSE: 2;

interface ConstantsStatic {
   readonly ALIGN_AUTO: typeof ALIGN_AUTO;
   readonly ALIGN_COUNT: typeof ALIGN_COUNT;
   readonly ALIGN_FLEX_START: typeof ALIGN_FLEX_START;
   readonly ALIGN_CENTER: typeof ALIGN_CENTER;
   readonly ALIGN_FLEX_END: typeof ALIGN_FLEX_END;
   readonly ALIGN_STRETCH: typeof ALIGN_STRETCH;
   readonly ALIGN_BASELINE: typeof ALIGN_BASELINE;
   readonly ALIGN_SPACE_BETWEEN: typeof ALIGN_SPACE_BETWEEN;
   readonly ALIGN_SPACE_AROUND: typeof ALIGN_SPACE_AROUND;
   readonly DIMENSION_COUNT: typeof DIMENSION_COUNT;
   readonly DIMENSION_WIDTH: typeof DIMENSION_WIDTH;
   readonly DIMENSION_HEIGHT: typeof DIMENSION_HEIGHT;
   readonly DIRECTION_COUNT: typeof DIRECTION_COUNT;
   readonly DIRECTION_INHERIT: typeof DIRECTION_INHERIT;
   readonly DIRECTION_LTR: typeof DIRECTION_LTR;
   readonly DIRECTION_RTL: typeof DIRECTION_RTL;
   readonly DISPLAY_COUNT: typeof DISPLAY_COUNT;
   readonly DISPLAY_FLEX: typeof DISPLAY_FLEX;
   readonly DISPLAY_NONE: typeof DISPLAY_NONE;
   readonly EDGE_COUNT: typeof EDGE_COUNT;
   readonly EDGE_LEFT: typeof EDGE_LEFT;
   readonly EDGE_TOP: typeof EDGE_TOP;
   readonly EDGE_RIGHT: typeof EDGE_RIGHT;
   readonly EDGE_BOTTOM: typeof EDGE_BOTTOM;
   readonly EDGE_START: typeof EDGE_START;
   readonly EDGE_END: typeof EDGE_END;
   readonly EDGE_HORIZONTAL: typeof EDGE_HORIZONTAL;
   readonly EDGE_VERTICAL: typeof EDGE_VERTICAL;
   readonly EDGE_ALL: typeof EDGE_ALL;
   readonly EXPERIMENTAL_FEATURE_COUNT: typeof EXPERIMENTAL_FEATURE_COUNT;
   readonly EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS: typeof EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS;
   readonly FLEX_DIRECTION_COUNT: typeof FLEX_DIRECTION_COUNT;
   readonly FLEX_DIRECTION_COLUMN: typeof FLEX_DIRECTION_COLUMN;
   readonly FLEX_DIRECTION_COLUMN_REVERSE: typeof FLEX_DIRECTION_COLUMN_REVERSE;
   readonly FLEX_DIRECTION_ROW: typeof FLEX_DIRECTION_ROW;
   readonly FLEX_DIRECTION_ROW_REVERSE: typeof FLEX_DIRECTION_ROW_REVERSE;
   readonly JUSTIFY_COUNT: typeof JUSTIFY_COUNT;
   readonly JUSTIFY_FLEX_START: typeof JUSTIFY_FLEX_START;
   readonly JUSTIFY_CENTER: typeof JUSTIFY_CENTER;
   readonly JUSTIFY_FLEX_END: typeof JUSTIFY_FLEX_END;
   readonly JUSTIFY_SPACE_BETWEEN: typeof JUSTIFY_SPACE_BETWEEN;
   readonly JUSTIFY_SPACE_AROUND: typeof JUSTIFY_SPACE_AROUND;
   readonly JUSTIFY_SPACE_EVENLY: typeof JUSTIFY_SPACE_EVENLY;
   readonly LOG_LEVEL_COUNT: typeof LOG_LEVEL_COUNT;
   readonly LOG_LEVEL_ERROR: typeof LOG_LEVEL_ERROR;
   readonly LOG_LEVEL_WARN: typeof LOG_LEVEL_WARN;
   readonly LOG_LEVEL_INFO: typeof LOG_LEVEL_INFO;
   readonly LOG_LEVEL_DEBUG: typeof LOG_LEVEL_DEBUG;
   readonly LOG_LEVEL_VERBOSE: typeof LOG_LEVEL_VERBOSE;
   readonly LOG_LEVEL_FATAL: typeof LOG_LEVEL_FATAL;
   readonly MEASURE_MODE_COUNT: typeof MEASURE_MODE_COUNT;
   readonly MEASURE_MODE_UNDEFINED: typeof MEASURE_MODE_UNDEFINED;
   readonly MEASURE_MODE_EXACTLY: typeof MEASURE_MODE_EXACTLY;
   readonly MEASURE_MODE_AT_MOST: typeof MEASURE_MODE_AT_MOST;
   readonly NODE_TYPE_COUNT: typeof NODE_TYPE_COUNT;
   readonly NODE_TYPE_DEFAULT: typeof NODE_TYPE_DEFAULT;
   readonly NODE_TYPE_TEXT: typeof NODE_TYPE_TEXT;
   readonly OVERFLOW_COUNT: typeof OVERFLOW_COUNT;
   readonly OVERFLOW_VISIBLE: typeof OVERFLOW_VISIBLE;
   readonly OVERFLOW_HIDDEN: typeof OVERFLOW_HIDDEN;
   readonly OVERFLOW_SCROLL: typeof OVERFLOW_SCROLL;
   readonly POSITION_TYPE_COUNT: typeof POSITION_TYPE_COUNT;
   readonly POSITION_TYPE_RELATIVE: typeof POSITION_TYPE_RELATIVE;
   readonly POSITION_TYPE_ABSOLUTE: typeof POSITION_TYPE_ABSOLUTE;
   readonly PRINT_OPTIONS_COUNT: typeof PRINT_OPTIONS_COUNT;
   readonly PRINT_OPTIONS_LAYOUT: typeof PRINT_OPTIONS_LAYOUT;
   readonly PRINT_OPTIONS_STYLE: typeof PRINT_OPTIONS_STYLE;
   readonly PRINT_OPTIONS_CHILDREN: typeof PRINT_OPTIONS_CHILDREN;
   readonly UNIT_COUNT: typeof UNIT_COUNT;
   readonly UNIT_UNDEFINED: typeof UNIT_UNDEFINED;
   readonly UNIT_POINT: typeof UNIT_POINT;
   readonly UNIT_PERCENT: typeof UNIT_PERCENT;
   readonly UNIT_AUTO: typeof UNIT_AUTO;
   readonly WRAP_COUNT: typeof WRAP_COUNT;
   readonly WRAP_NO_WRAP: typeof WRAP_NO_WRAP;
   readonly WRAP_WRAP: typeof WRAP_WRAP;
   readonly WRAP_WRAP_REVERSE: typeof WRAP_WRAP_REVERSE;
}

declare namespace Yoga {
    type YogaJustifyContent =
        | typeof JUSTIFY_CENTER
        | typeof JUSTIFY_FLEX_END
        | typeof JUSTIFY_FLEX_START
        | typeof JUSTIFY_SPACE_AROUND
        | typeof JUSTIFY_SPACE_BETWEEN
        | typeof JUSTIFY_SPACE_EVENLY;

    type YogaAlign =
        | typeof ALIGN_AUTO
        | typeof ALIGN_BASELINE
        | typeof ALIGN_CENTER
        | typeof ALIGN_FLEX_END
        | typeof ALIGN_FLEX_START
        | typeof ALIGN_SPACE_AROUND
        | typeof ALIGN_SPACE_BETWEEN
        | typeof ALIGN_STRETCH;

    type YogaFlexDirection =
        | typeof FLEX_DIRECTION_COLUMN
        | typeof FLEX_DIRECTION_COLUMN_REVERSE
        | typeof FLEX_DIRECTION_COUNT
        | typeof FLEX_DIRECTION_ROW
        | typeof FLEX_DIRECTION_ROW_REVERSE;

    type YogaDirection =
        | typeof DIRECTION_INHERIT
        | typeof DIRECTION_LTR
        | typeof DIRECTION_RTL;

    type YogaFlexWrap =
        | typeof WRAP_NO_WRAP
        | typeof WRAP_WRAP
        | typeof WRAP_WRAP_REVERSE;

    type YogaEdge =
        | typeof EDGE_LEFT
        | typeof EDGE_TOP
        | typeof EDGE_RIGHT
        | typeof EDGE_BOTTOM
        | typeof EDGE_START
        | typeof EDGE_END
        | typeof EDGE_HORIZONTAL
        | typeof EDGE_VERTICAL
        | typeof EDGE_ALL;

    type YogaDisplay =
        | typeof DISPLAY_FLEX
        | typeof DISPLAY_NONE;

    type YogaUnit =
        | typeof UNIT_AUTO
        | typeof UNIT_PERCENT
        | typeof UNIT_POINT
        | typeof UNIT_UNDEFINED;

    type YogaOverflow =
        | typeof OVERFLOW_HIDDEN
        | typeof OVERFLOW_SCROLL
        | typeof OVERFLOW_VISIBLE;

    type YogaPositionType =
        | typeof POSITION_TYPE_ABSOLUTE
        | typeof POSITION_TYPE_RELATIVE;

    type YogaExperimentalFeature = typeof EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS;

    type YogaMeasureMode =
        | typeof MEASURE_MODE_COUNT
        | typeof MEASURE_MODE_UNDEFINED
        | typeof MEASURE_MODE_EXACTLY
        | typeof MEASURE_MODE_AT_MOST;

    interface YogaNode {
        calculateLayout(
            width?: number,
            height?: number,
            direction?: YogaDirection,
        ): void;
        copyStyle(node: YogaNode): void;
        free(): void;
        freeRecursive(): void;
        getAlignContent(): YogaAlign;
        getAlignItems(): YogaAlign;
        getAlignSelf(): YogaAlign;
        getAspectRatio(): number;
        getBorder(edge: YogaEdge): number;
        getChild(index: number): YogaNode;
        getChildCount(): number;
        getComputedBorder(edge: YogaEdge): number;
        getComputedBottom(): number;
        getComputedHeight(): number;
        getComputedLayout(): Layout;
        getComputedLeft(): number;
        getComputedMargin(edge: YogaEdge): number;
        getComputedPadding(edge: YogaEdge): number;
        getComputedRight(): number;
        getComputedTop(): number;
        getComputedWidth(): number;
        getDisplay(): YogaDisplay;
        getFlexBasis(): number;
        getFlexDirection(): YogaFlexDirection;
        getFlexGrow(): number;
        getFlexShrink(): number;
        getFlexWrap(): YogaFlexWrap;
        getHeight(): Value;
        getJustifyContent(): YogaJustifyContent;
        getMargin(edge: YogaEdge): Value;
        getMaxHeight(): Value;
        getMaxWidth(): Value;
        getMinHeight(): Value;
        getMinWidth(): Value;
        getOverflow(): YogaOverflow;
        getPadding(edge: YogaEdge): Value;
        getParent(): YogaNode | null;
        getPosition(edge: YogaEdge): Value;
        getPositionType(): YogaPositionType;
        getWidth(): Value;
        insertChild(child: YogaNode, index: number): void;
        isDirty(): boolean;
        markDirty(): void;
        removeChild(child: YogaNode): void;
        reset(): void;
        setAlignContent(alignContent: YogaAlign): void;
        setAlignItems(alignItems: YogaAlign): void;
        setAlignSelf(alignSelf: YogaAlign): void;
        setAspectRatio(aspectRatio: number): void;
        setBorder(edge: YogaEdge, borderWidth: number): void;
        setDisplay(display: YogaDisplay): void;
        setFlex(flex: number): void;
        setFlexBasis(flexBasis: number | string): void;
        setFlexBasisPercent(flexBasis: number): void;
        setFlexDirection(flexDirection: YogaFlexDirection): void;
        setFlexGrow(flexGrow: number): void;
        setFlexShrink(flexShrink: number): void;
        setFlexWrap(flexWrap: YogaFlexWrap): void;
        setHeight(height: number | string): void;
        setHeightAuto(): void;
        setHeightPercent(height: number): void;
        setJustifyContent(justifyContent: YogaJustifyContent): void;
        setMargin(edge: YogaEdge, margin: number): void;
        setMarginAuto(edge: YogaEdge): void;
        setMarginPercent(edge: YogaEdge, margin: number): void;
        setMaxHeight(maxHeight: number | string): void;
        setMaxHeightPercent(maxHeight: number): void;
        setMaxWidth(maxWidth: number | string): void;
        setMaxWidthPercent(maxWidth: number): void;
        setMeasureFunc(measureFunc: (width: number, widthMeasureMode: YogaMeasureMode, height: number, heightMeasureMode: YogaMeasureMode) => { width?: number; height?: number } | null): void;
        setMinHeight(minHeight: number | string): void;
        setMinHeightPercent(minHeight: number): void;
        setMinWidth(minWidth: number | string): void;
        setMinWidthPercent(minWidth: number): void;
        setOverflow(overflow: YogaOverflow): void;
        setPadding(edge: YogaEdge, padding: number | string): void;
        setPaddingPercent(edge: YogaEdge, padding: number): void;
        setPosition(edge: YogaEdge, position: number | string): void;
        setPositionPercent(edge: YogaEdge, position: number): void;
        setPositionType(positionType: YogaPositionType): void;
        setWidth(width: number | string): void;
        setWidthAuto(): void;
        setWidthPercent(width: number): void;
        unsetMeasureFunc(): void;
    }

    interface YogaConfig {
        isExperimentalFeatureEnabled(feature: YogaExperimentalFeature): boolean;
        setExperimentalFeatureEnabled(
            feature: YogaExperimentalFeature,
            enabled: boolean,
        ): void;
        setPointScaleFactor(factor: number): void;
    }
}

declare class Layout {
    readonly left: number;
    readonly right: number;
    readonly top: number;
    readonly bottom: number;
    readonly width: number;
    readonly height: number;
    constructor(
        left: number,
        right: number,
        top: number,
        bottom: number,
        width: number,
        height: number,
    );

    fromJs(expose: (
        left: number,
        right: number,
        top: number,
        bottom: number,
        width: number,
        height: number,
    ) => any): void;

    toString(): string;
}

declare class Size {
    static fromJS(dim: { width: number, height: number }): Size;

    readonly width: number;
    readonly height: number;

    constructor(width: number, height: number);

    fromJS(expose: (width: number, height: number) => any): void;

    toString(): string;
}

declare class Value {
    readonly unit: Yoga.YogaUnit | number;
    readonly value: number;

    constructor(unit: Yoga.YogaUnit | number, value: number);

    fromJS(expose: (unit: Yoga.YogaUnit | number, value: number) => any): void;

    toString(): string;
    valueOf(): number;
}

interface NodeStatic {
    create(): Yoga.YogaNode;
    createDefault(): Yoga.YogaNode;
    createWithConfig(config: Yoga.YogaConfig): Yoga.YogaNode;
    destroy(node: Yoga.YogaNode): any;
}

interface ConfigStatic {
    create(): Yoga.YogaConfig;
    destroy(config: Yoga.YogaConfig): any;
}

interface YogaStatic extends ConstantsStatic {
    Node: NodeStatic;
    Config: ConfigStatic;
    getInstanceCount(): number;
}

declare const Yoga: YogaStatic;

export = Yoga;