Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/react-native/Libraries/Blob/File.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

// flowlint unsafe-getters-setters:off

'use strict';

import type {BlobOptions} from './BlobTypes';
Expand Down
4 changes: 3 additions & 1 deletion packages/react-native/Libraries/Blob/FileReader.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

// flowlint unsafe-getters-setters:off

import type {EventCallback} from '../../src/private/webapis/dom/events/EventTarget';
import type Blob from './Blob';

Expand Down
16 changes: 10 additions & 6 deletions packages/react-native/Libraries/Blob/URL.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

// flowlint unsafe-getters-setters:off

import type Blob from './Blob';

import NativeBlobModule from './NativeBlobModule';
Expand Down Expand Up @@ -79,6 +81,7 @@ export class URL {
// $FlowFixMe[missing-local-annot]
constructor(url: string, base?: string | URL) {
let baseUrl = null;
// $FlowFixMe[sketchy-null-string]
if (!base || validateBaseUrl(url)) {
this._url = url;
if (this._url.includes('#')) {
Expand Down Expand Up @@ -112,13 +115,14 @@ export class URL {
if (baseUrl.endsWith('/')) {
baseUrl = baseUrl.slice(0, baseUrl.length - 1);
}
if (!url.startsWith('/')) {
url = `/${url}`;
let path = url;
if (!path.startsWith('/')) {
path = `/${path}`;
}
if (baseUrl.endsWith(url)) {
url = '';
if (baseUrl.endsWith(path)) {
path = '';
}
this._url = `${baseUrl}${url}`;
this._url = `${baseUrl}${path}`;
}
}

Expand Down
4 changes: 3 additions & 1 deletion packages/react-native/Libraries/Blob/URLSearchParams.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

// flowlint unsafe-getters-setters:off

// Small subset from whatwg-url: https://github.com/jsdom/whatwg-url/tree/master/src
// The reference code bloat comes from Unicode issues with URLs, so those won't work here.
export class URLSearchParams {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/Libraries/StyleSheet/StyleSheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

Expand Down Expand Up @@ -86,9 +86,9 @@ declare export const flatten: typeof flattenStyle;
* internally to process color and transform values. You should not use this
* unless you really know what you are doing and have exhausted other options.
*/
declare export const setStyleAttributePreprocessor: (
declare export const setStyleAttributePreprocessor: <T>(
property: string,
process: (nextProp: any) => any,
process: (nextProp: T) => unknown,
) => void;

/**
Expand Down
13 changes: 8 additions & 5 deletions packages/react-native/Libraries/StyleSheet/processFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format strict-local
*/

Expand Down Expand Up @@ -51,13 +51,13 @@ export default function processFilter(
}

if (typeof filter === 'string') {
filter = filter.replace(NEWLINE_REGEX, ' ');
const normalizedFilter = filter.replace(NEWLINE_REGEX, ' ');

// matches on functions with args and nested functions like "drop-shadow(10 10 10 rgba(0, 0, 0, 1))"
FILTER_FUNCTION_REGEX.lastIndex = 0;
let matches;

while ((matches = FILTER_FUNCTION_REGEX.exec(filter))) {
while ((matches = FILTER_FUNCTION_REGEX.exec(normalizedFilter))) {
let filterName = matches[1].toLowerCase();
if (filterName === 'drop-shadow') {
const dropShadow = parseDropShadow(matches[2]);
Expand Down Expand Up @@ -159,7 +159,7 @@ function _getFilterAmount(filterName: string, filterArgs: unknown): ?number {
// blur takes any positive CSS length that is not a percent. In RN
// we currently only have DIPs, so we are not parsing units here.
case 'blur':
if ((unit && unit !== 'px') || filterArgAsNumber < 0) {
if ((Boolean(unit) && unit !== 'px') || filterArgAsNumber < 0) {
return undefined;
}
return filterArgAsNumber;
Expand All @@ -173,7 +173,10 @@ function _getFilterAmount(filterName: string, filterArgs: unknown): ?number {
case 'opacity':
case 'saturate':
case 'sepia':
if ((unit && unit !== '%' && unit !== 'px') || filterArgAsNumber < 0) {
if (
(Boolean(unit) && unit !== '%' && unit !== 'px') ||
filterArgAsNumber < 0
) {
return undefined;
}
if (unit === '%') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

Expand All @@ -20,10 +20,11 @@ const INDEX_Z = 2;

/* eslint-disable no-labels */
export default function processTransformOrigin(
transformOrigin: Array<string | number> | string,
transformOriginInput: Array<string | number> | string,
): Array<string | number> {
if (typeof transformOrigin === 'string') {
const transformOriginString = transformOrigin;
let transformOrigin: Array<string | number>;
if (typeof transformOriginInput === 'string') {
const transformOriginString = transformOriginInput;
TRANSFORM_ORIGIN_REGEX.lastIndex = 0;
const transformOriginArray: Array<string | number> = ['50%', '50%', 0];

Expand Down Expand Up @@ -111,6 +112,8 @@ export default function processTransformOrigin(
}

transformOrigin = transformOriginArray;
} else {
transformOrigin = transformOriginInput;
}

if (__DEV__) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

Expand All @@ -17,15 +17,16 @@
* alpha should be number between 0 and 1
*/
function setNormalizedColorAlpha(input: number, alpha: number): number {
if (alpha < 0) {
alpha = 0;
} else if (alpha > 1) {
alpha = 1;
let normalizedAlpha = alpha;
if (normalizedAlpha < 0) {
normalizedAlpha = 0;
} else if (normalizedAlpha > 1) {
normalizedAlpha = 1;
}

alpha = Math.round(alpha * 255);
normalizedAlpha = Math.round(normalizedAlpha * 255);
// magic bitshift guarantees we return an unsigned int
return ((input & 0xffffff00) | alpha) >>> 0;
return ((input & 0xffffff00) | normalizedAlpha) >>> 0;
}

export default setNormalizedColorAlpha;
8 changes: 4 additions & 4 deletions packages/react-native/ReactNativeApi.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<d895833bed3d3c274a6647773deaa023>>
* @generated SignedSource<<9e84d3a75a150cc9d571738d15f28d91>>
*
* This file was generated by scripts/js-api/build-types/index.js.
*/
Expand Down Expand Up @@ -371,9 +371,9 @@ declare const sequence: typeof $$AnimatedImplementation.sequence
declare const sequenceImpl: (
animations: Array<CompositeAnimation>,
) => CompositeAnimation
declare const setStyleAttributePreprocessor: (
declare const setStyleAttributePreprocessor: <T>(
property: string,
process: (nextProp: any) => any,
process: (nextProp: T) => unknown,
) => void
declare const Settings: typeof Settings_default
declare let Settings_default: {
Expand Down Expand Up @@ -5937,7 +5937,7 @@ export {
StatusBarProps, // c2a44d88
StatusBarStyle, // 78f53eea
StyleProp, // fa0e9b4a
StyleSheet, // e734acd4
StyleSheet, // 94c9aa8e
SubmitBehavior, // c4ddf490
Switch, // f495bab3
SwitchChangeEvent, // 899635b1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,47 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport';
import type {UnsafeObject} from '../../../../Libraries/Types/CodegenTypes';

import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry';

export interface Spec extends TurboModule {
readonly getCurrentBoldTextState: (
onSuccess: (isBoldTextEnabled: boolean) => void,
onError: (error: Object) => void,
onError: (error: UnsafeObject) => void,
) => void;
readonly getCurrentGrayscaleState: (
onSuccess: (isGrayscaleEnabled: boolean) => void,
onError: (error: Object) => void,
onError: (error: UnsafeObject) => void,
) => void;
readonly getCurrentInvertColorsState: (
onSuccess: (isInvertColorsEnabled: boolean) => void,
onError: (error: Object) => void,
onError: (error: UnsafeObject) => void,
) => void;
readonly getCurrentReduceMotionState: (
onSuccess: (isReduceMotionEnabled: boolean) => void,
onError: (error: Object) => void,
onError: (error: UnsafeObject) => void,
) => void;
readonly getCurrentDarkerSystemColorsState?: (
onSuccess: (isDarkerSystemColorsEnabled: boolean) => void,
onError: (error: Object) => void,
onError: (error: UnsafeObject) => void,
) => void;
readonly getCurrentPrefersCrossFadeTransitionsState?: (
onSuccess: (prefersCrossFadeTransitions: boolean) => void,
onError: (error: Object) => void,
onError: (error: UnsafeObject) => void,
) => void;
readonly getCurrentReduceTransparencyState: (
onSuccess: (isReduceTransparencyEnabled: boolean) => void,
onError: (error: Object) => void,
onError: (error: UnsafeObject) => void,
) => void;
readonly getCurrentVoiceOverState: (
onSuccess: (isScreenReaderEnabled: boolean) => void,
onError: (error: Object) => void,
onError: (error: UnsafeObject) => void,
) => void;
readonly setAccessibilityContentSizeMultipliers: (JSMultipliers: {
readonly extraSmall?: ?number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport';
import type {UnsafeObject} from '../../../../Libraries/Types/CodegenTypes';

import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry';

Expand Down Expand Up @@ -45,7 +46,7 @@ export interface Spec extends TurboModule {
failureCallback: (error: {
readonly domain: string,
readonly code: string,
readonly userInfo?: ?Object,
readonly userInfo?: ?UnsafeObject,
readonly message: string,
}) => void,
successCallback: (completed: boolean, activityType: ?string) => void,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport';
import type {UnsafeObject} from '../../../../Libraries/Types/CodegenTypes';

import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry';

export type Args = {
title?: string,
message?: string,
buttons?: Array<Object>, // TODO(T67565166): have a better type
buttons?: Array<UnsafeObject>, // TODO(T67565166): have a better type
type?: string,
defaultValue?: string,
cancelButtonKey?: string,
Expand Down
Loading
Loading