Match xplat/yoga/javascript
prettier conventions
Summary: Match Prettier config to match other Meta OSS projects Didn't update the test generator to use this form yet. Reviewed By: yungsters Differential Revision: D45570415 fbshipit-source-id: d5fd791b047debf41c28aecac75fb8dde16da3e3
This commit is contained in:
committed by
Facebook GitHub Bot
parent
0cb4a49d38
commit
0a6a581936
@@ -7,9 +7,9 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
const wrapAsm = require("../wrapAsm");
|
||||
const wrapAsm = require('../wrapAsm');
|
||||
|
||||
module.exports = (loadAsm) => ({
|
||||
module.exports = loadAsm => ({
|
||||
loadYoga: () => loadAsm().then(wrapAsm),
|
||||
...require("../generated/YGEnums"),
|
||||
...require('../generated/YGEnums'),
|
||||
});
|
||||
|
@@ -7,5 +7,5 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
const wrapAsm = require("../wrapAsm");
|
||||
module.exports = (asm) => wrapAsm(asm());
|
||||
const wrapAsm = require('../wrapAsm');
|
||||
module.exports = asm => wrapAsm(asm());
|
||||
|
@@ -7,5 +7,5 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
const asm = require("../build/asmjs-async");
|
||||
module.exports = require("./_entryAsync")(asm);
|
||||
const asm = require('../build/asmjs-async');
|
||||
module.exports = require('./_entryAsync')(asm);
|
||||
|
@@ -7,5 +7,5 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
const asm = require("../build/asmjs-sync");
|
||||
module.exports = require("./_entrySync")(asm);
|
||||
const asm = require('../build/asmjs-sync');
|
||||
module.exports = require('./_entrySync')(asm);
|
||||
|
@@ -7,5 +7,5 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
const asm = require("../build/wasm-async");
|
||||
module.exports = require("./_entryAsync")(asm);
|
||||
const asm = require('../build/wasm-async');
|
||||
module.exports = require('./_entryAsync')(asm);
|
||||
|
@@ -7,5 +7,5 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
const asm = require("../build/wasm-sync");
|
||||
module.exports = require("./_entrySync")(asm);
|
||||
const asm = require('../build/wasm-sync');
|
||||
module.exports = require('./_entrySync')(asm);
|
||||
|
6
javascript/src_js/index.d.ts
vendored
6
javascript/src_js/index.d.ts
vendored
@@ -7,9 +7,9 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
import type { Yoga } from "./wrapAsm";
|
||||
import type {Yoga} from './wrapAsm';
|
||||
|
||||
export * from "./generated/YGEnums";
|
||||
export * from "./wrapAsm";
|
||||
export * from './generated/YGEnums';
|
||||
export * from './wrapAsm';
|
||||
|
||||
export function loadYoga(): Promise<Yoga>;
|
||||
|
@@ -8,4 +8,4 @@
|
||||
*/
|
||||
|
||||
// Fallback for when the export map is not followed
|
||||
module.exports = require("./entrypoint/asmjs-async");
|
||||
module.exports = require('./entrypoint/asmjs-async');
|
||||
|
6
javascript/src_js/sync.d.ts
vendored
6
javascript/src_js/sync.d.ts
vendored
@@ -7,10 +7,10 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
import type { Yoga } from "./wrapAsm";
|
||||
import type {Yoga} from './wrapAsm';
|
||||
|
||||
export * from "./generated/YGEnums";
|
||||
export * from "./wrapAsm";
|
||||
export * from './generated/YGEnums';
|
||||
export * from './wrapAsm';
|
||||
|
||||
declare const yoga: Yoga;
|
||||
export default yoga;
|
||||
|
@@ -8,4 +8,4 @@
|
||||
*/
|
||||
|
||||
// Fallback for when the export map is not followed
|
||||
module.exports = require("./entrypoint/asmjs-sync");
|
||||
module.exports = require('./entrypoint/asmjs-sync');
|
||||
|
16
javascript/src_js/wrapAsm.d.ts
vendored
16
javascript/src_js/wrapAsm.d.ts
vendored
@@ -22,9 +22,9 @@ import type {
|
||||
PositionType,
|
||||
Unit,
|
||||
Wrap,
|
||||
} from "./generated/YGEnums";
|
||||
} from './generated/YGEnums';
|
||||
|
||||
import type * as YGEnums from "./generated/YGEnums";
|
||||
import type * as YGEnums from './generated/YGEnums';
|
||||
|
||||
type Layout = {
|
||||
left: number;
|
||||
@@ -50,7 +50,7 @@ export type Config = {
|
||||
isExperimentalFeatureEnabled(feature: ExperimentalFeature): boolean;
|
||||
setExperimentalFeatureEnabled(
|
||||
feature: ExperimentalFeature,
|
||||
enabled: boolean
|
||||
enabled: boolean,
|
||||
): void;
|
||||
setPointScaleFactor(factor: number): void;
|
||||
/**
|
||||
@@ -77,7 +77,7 @@ export type MeasureFunction = (
|
||||
width: number,
|
||||
widthMode: MeasureMode,
|
||||
height: number,
|
||||
heightMode: MeasureMode
|
||||
heightMode: MeasureMode,
|
||||
) => Size;
|
||||
|
||||
export type Node = {
|
||||
@@ -135,20 +135,20 @@ export type Node = {
|
||||
setBorder(edge: Edge, borderWidth: number): void;
|
||||
setDisplay(display: Display): void;
|
||||
setFlex(flex: number): void;
|
||||
setFlexBasis(flexBasis: number | "auto" | `${number}%`): void;
|
||||
setFlexBasis(flexBasis: number | 'auto' | `${number}%`): void;
|
||||
setFlexBasisPercent(flexBasis: number): void;
|
||||
setFlexBasisAuto(): void;
|
||||
setFlexDirection(flexDirection: FlexDirection): void;
|
||||
setFlexGrow(flexGrow: number): void;
|
||||
setFlexShrink(flexShrink: number): void;
|
||||
setFlexWrap(flexWrap: Wrap): void;
|
||||
setHeight(height: number | "auto" | `${number}%`): void;
|
||||
setHeight(height: number | 'auto' | `${number}%`): void;
|
||||
setIsReferenceBaseline(isReferenceBaseline: boolean): void;
|
||||
setHeightAuto(): void;
|
||||
setHeightPercent(height: number): void;
|
||||
setJustifyContent(justifyContent: Justify): void;
|
||||
setGap(gutter: Gutter, gapLength: number): Value;
|
||||
setMargin(edge: Edge, margin: number | "auto" | `${number}%`): void;
|
||||
setMargin(edge: Edge, margin: number | 'auto' | `${number}%`): void;
|
||||
setMarginAuto(edge: Edge): void;
|
||||
setMarginPercent(edge: Edge, margin: number): void;
|
||||
setMaxHeight(maxHeight: number | `${number}%`): void;
|
||||
@@ -167,7 +167,7 @@ export type Node = {
|
||||
setPosition(edge: Edge, position: number | `${number}%`): void;
|
||||
setPositionPercent(edge: Edge, position: number): void;
|
||||
setPositionType(positionType: PositionType): void;
|
||||
setWidth(width: number | "auto" | `${number}%`): void;
|
||||
setWidth(width: number | 'auto' | `${number}%`): void;
|
||||
setWidthAuto(): void;
|
||||
setWidthPercent(width: number): void;
|
||||
unsetDirtiedFunc(): void;
|
||||
|
@@ -7,9 +7,9 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
const CONSTANTS = require("./generated/YGEnums");
|
||||
const CONSTANTS = require('./generated/YGEnums');
|
||||
|
||||
module.exports = (lib) => {
|
||||
module.exports = lib => {
|
||||
function patch(prototype, name, fn) {
|
||||
const original = prototype[name];
|
||||
|
||||
@@ -19,16 +19,16 @@ module.exports = (lib) => {
|
||||
}
|
||||
|
||||
for (const fnName of [
|
||||
"setPosition",
|
||||
"setMargin",
|
||||
"setFlexBasis",
|
||||
"setWidth",
|
||||
"setHeight",
|
||||
"setMinWidth",
|
||||
"setMinHeight",
|
||||
"setMaxWidth",
|
||||
"setMaxHeight",
|
||||
"setPadding",
|
||||
'setPosition',
|
||||
'setMargin',
|
||||
'setFlexBasis',
|
||||
'setWidth',
|
||||
'setHeight',
|
||||
'setMinWidth',
|
||||
'setMinHeight',
|
||||
'setMaxWidth',
|
||||
'setMaxHeight',
|
||||
'setPadding',
|
||||
]) {
|
||||
const methods = {
|
||||
[CONSTANTS.UNIT_POINT]: lib.Node.prototype[fnName],
|
||||
@@ -43,15 +43,15 @@ module.exports = (lib) => {
|
||||
const value = args.pop();
|
||||
let unit, asNumber;
|
||||
|
||||
if (value === "auto") {
|
||||
if (value === 'auto') {
|
||||
unit = CONSTANTS.UNIT_AUTO;
|
||||
asNumber = undefined;
|
||||
} else if (typeof value === "object") {
|
||||
} else if (typeof value === 'object') {
|
||||
unit = value.unit;
|
||||
asNumber = value.valueOf();
|
||||
} else {
|
||||
unit =
|
||||
typeof value === "string" && value.endsWith("%")
|
||||
typeof value === 'string' && value.endsWith('%')
|
||||
? CONSTANTS.UNIT_PERCENT
|
||||
: CONSTANTS.UNIT_POINT;
|
||||
asNumber = parseFloat(value);
|
||||
@@ -62,7 +62,7 @@ module.exports = (lib) => {
|
||||
|
||||
if (!methods[unit])
|
||||
throw new Error(
|
||||
`Failed to execute "${fnName}": Unsupported unit '${value}'`
|
||||
`Failed to execute "${fnName}": Unsupported unit '${value}'`,
|
||||
);
|
||||
|
||||
if (asNumber !== undefined) {
|
||||
@@ -76,7 +76,7 @@ module.exports = (lib) => {
|
||||
function wrapMeasureFunction(measureFunction) {
|
||||
return lib.MeasureCallback.implement({
|
||||
measure: (...args) => {
|
||||
const { width, height } = measureFunction(...args);
|
||||
const {width, height} = measureFunction(...args);
|
||||
return {
|
||||
width: width ?? NaN,
|
||||
height: height ?? NaN,
|
||||
@@ -85,7 +85,7 @@ module.exports = (lib) => {
|
||||
});
|
||||
}
|
||||
|
||||
patch(lib.Node.prototype, "setMeasureFunc", function (original, measureFunc) {
|
||||
patch(lib.Node.prototype, 'setMeasureFunc', function (original, measureFunc) {
|
||||
// This patch is just a convenience patch, since it helps write more
|
||||
// idiomatic source code (such as .setMeasureFunc(null))
|
||||
if (measureFunc) {
|
||||
@@ -96,33 +96,33 @@ module.exports = (lib) => {
|
||||
});
|
||||
|
||||
function wrapDirtiedFunc(dirtiedFunction) {
|
||||
return lib.DirtiedCallback.implement({ dirtied: dirtiedFunction });
|
||||
return lib.DirtiedCallback.implement({dirtied: dirtiedFunction});
|
||||
}
|
||||
|
||||
patch(lib.Node.prototype, "setDirtiedFunc", function (original, dirtiedFunc) {
|
||||
patch(lib.Node.prototype, 'setDirtiedFunc', function (original, dirtiedFunc) {
|
||||
original.call(this, wrapDirtiedFunc(dirtiedFunc));
|
||||
});
|
||||
|
||||
patch(lib.Config.prototype, "free", function () {
|
||||
patch(lib.Config.prototype, 'free', function () {
|
||||
// Since we handle the memory allocation ourselves (via lib.Config.create),
|
||||
// we also need to handle the deallocation
|
||||
lib.Config.destroy(this);
|
||||
});
|
||||
|
||||
patch(lib.Node, "create", (_, config) => {
|
||||
patch(lib.Node, 'create', (_, config) => {
|
||||
// We decide the constructor we want to call depending on the parameters
|
||||
return config
|
||||
? lib.Node.createWithConfig(config)
|
||||
: lib.Node.createDefault();
|
||||
});
|
||||
|
||||
patch(lib.Node.prototype, "free", function () {
|
||||
patch(lib.Node.prototype, 'free', function () {
|
||||
// Since we handle the memory allocation ourselves (via lib.Node.create),
|
||||
// we also need to handle the deallocation
|
||||
lib.Node.destroy(this);
|
||||
});
|
||||
|
||||
patch(lib.Node.prototype, "freeRecursive", function () {
|
||||
patch(lib.Node.prototype, 'freeRecursive', function () {
|
||||
for (let t = 0, T = this.getChildCount(); t < T; ++t) {
|
||||
this.getChild(0).freeRecursive();
|
||||
}
|
||||
@@ -131,16 +131,16 @@ module.exports = (lib) => {
|
||||
|
||||
patch(
|
||||
lib.Node.prototype,
|
||||
"calculateLayout",
|
||||
'calculateLayout',
|
||||
function (
|
||||
original,
|
||||
width = NaN,
|
||||
height = NaN,
|
||||
direction = CONSTANTS.DIRECTION_LTR
|
||||
direction = CONSTANTS.DIRECTION_LTR,
|
||||
) {
|
||||
// Just a small patch to add support for the function default parameters
|
||||
return original.call(this, width, height, direction);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
return {
|
||||
|
Reference in New Issue
Block a user