Skip to content

Commit

Permalink
Merge branch 'main' into keyDownEvents
Browse files Browse the repository at this point in the history
  • Loading branch information
Saadnajmi authored Oct 15, 2024
2 parents 9f5c5b9 + 09cf897 commit 0ac5979
Show file tree
Hide file tree
Showing 22 changed files with 246 additions and 245 deletions.
12 changes: 12 additions & 0 deletions .ado/jobs/build-test-rntester.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,18 @@ jobs:
steps:
- template: /.ado/templates/apple-tools-setup.yml@self

- ${{ if in(slice.sdk, 'xros', 'xrsimulator') }}:
- task: CmdLine@2
displayName: Download visionOS SDDK
inputs:
script: |
set -eox pipefail
# https://github.com/actions/runner-images/issues/10559
sudo xcodebuild -runFirstLaunch
sudo xcrun simctl list
sudo xcodebuild -downloadPlatform visionOS
sudo xcodebuild -runFirstLaunch
- task: CmdLine@2
displayName: yarn install
inputs:
Expand Down
42 changes: 36 additions & 6 deletions .ado/jobs/test-react-native-macos-init.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,22 @@ jobs:

- template: /.ado/templates/apple-tools-setup.yml@self

- task: CmdLine@2
displayName: yarn install react-native-macos-init
inputs:
script: |
set -eox pipefail
cd packages/react-native-macos-init
yarn install
- task: CmdLine@2
displayName: Build react-native-macos-init
inputs:
script: |
set -eox pipefail
cd packages/react-native-macos-init
yarn build
- template: /.ado/templates/verdaccio-init.yml@self

- template: /.ado/templates/verdaccio-publish.yml@self
Expand All @@ -21,42 +37,56 @@ jobs:
- task: CmdLine@2
displayName: yarn install (local react-native-macos)
inputs:
script: yarn install --immutable
script: |
set -eox pipefail
yarn install --immutable
- task: CmdLine@2
displayName: yarn install (local react-native-macos-init)
inputs:
script: |
set -eox pipefail
cd packages/react-native-macos-init
yarn install --immutable
- task: CmdLine@2
displayName: yarn build (local react-native-macos-init)
inputs:
script: |
set -eox pipefail
cd packages/react-native-macos-init
yarn build
- task: CmdLine@2
displayName: Init new project
inputs:
script: npx --yes [email protected] init testcli --template [email protected] --skip-install
script: |
set -eox pipefail
npx --yes @react-native-community/cli init testcli --version 0.75 --skip-install
workingDirectory: $(Agent.BuildDirectory)

- task: CmdLine@2
displayName: yarn install (local react-native-macos-init)
displayName: yarn install (testcli)
inputs:
script: yarn install --immutable
script: |
set -eox pipefail
yarn install --mode=update-lockfile
# `update-lockfile` skips the linking step, so we need to run `yarn install` again
yarn install
workingDirectory: $(Agent.BuildDirectory)/testcli

- task: CmdLine@2
displayName: Apply macos template
inputs:
script: npx react-native-macos-init --version latest --overwrite --prerelease
script: |
set -eox pipefail
npx react-native-macos-init --version latest --overwrite --prerelease
workingDirectory: $(Agent.BuildDirectory)/testcli

- task: CmdLine@2
displayName: Run macos [test]
inputs:
script: npx react-native run-macos
script: |
set -eox pipefail
npx react-native run-macos
workingDirectory: $(Agent.BuildDirectory)/testcli
8 changes: 5 additions & 3 deletions packages/helloworld/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,21 @@ GEM
netrc (0.11.0)
nkf (0.2.0)
public_suffix (4.0.7)
rexml (3.2.6)
rexml (3.3.6)
strscan
ruby-macho (2.5.1)
strscan (3.1.0)
typhoeus (1.4.1)
ethon (>= 0.9.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
xcodeproj (1.24.0)
xcodeproj (1.25.0)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.3.0)
rexml (~> 3.2.4)
rexml (>= 3.3.2, < 4.0)
zeitwerk (2.6.13)

PLATFORMS
Expand Down
15 changes: 15 additions & 0 deletions packages/react-native-macos-init/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
{
"name": "react-native-macos-init",
"entries": [
{
"date": "Tue, 15 Oct 2024 20:02:42 GMT",
"version": "2.1.3",
"tag": "react-native-macos-init_v2.1.3",
"comments": {
"patch": [
{
"author": "[email protected]",
"package": "react-native-macos-init",
"commit": "b86ac5239832d7d72e22cb84b1878ce2f73138fe",
"comment": "fix: Properly import `npm-registry-fetch` in `react-native-macos-init`"
}
]
}
},
{
"date": "Mon, 18 May 2020 23:31:12 GMT",
"tag": "react-native-macos-init_v2.1.0",
Expand Down
10 changes: 9 additions & 1 deletion packages/react-native-macos-init/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
# Change Log - react-native-macos-init

This log was last generated on Mon, 18 May 2020 23:31:12 GMT and should not be manually modified.
This log was last generated on Tue, 15 Oct 2024 20:02:42 GMT and should not be manually modified.

<!-- Start content -->

## 2.1.3

Tue, 15 Oct 2024 20:02:42 GMT

### Patches

- fix: Properly import `npm-registry-fetch` in `react-native-macos-init` ([email protected])

## 2.1.0

Mon, 18 May 2020 23:31:12 GMT
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-macos-init/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-macos-init",
"version": "2.1.0",
"version": "2.1.3",
"description": "CLI to add react-native-macos to an existing react-native project",
"main": "index.js",
"repository": "https://github.com/microsoft/react-native-macos",
Expand Down
3 changes: 1 addition & 2 deletions packages/react-native-macos-init/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import * as validUrl from 'valid-url';
import * as prompts from 'prompts';
import * as findUp from 'find-up';
import * as chalk from 'chalk';
// @ts-ignore
import npmFetch from 'npm-registry';
import * as npmFetch from 'npm-registry-fetch';

const npmConfReg = execSync('npm config get registry').toString().trim();
const NPM_REGISTRY_URL = validUrl.isUri(npmConfReg)
Expand Down
19 changes: 9 additions & 10 deletions packages/react-native/Libraries/Image/RCTImageBlurUtils.mm
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,22 @@

// convert to ARGB if it isn't
if (CGImageGetBitsPerPixel(imageRef) != 32 || !((CGImageGetBitmapInfo(imageRef) & kCGBitmapAlphaInfoMask))) {
#if !TARGET_OS_OSX // [macOS]
UIGraphicsImageRendererFormat *const rendererFormat = [UIGraphicsImageRendererFormat defaultFormat];
rendererFormat.scale = inputImage.scale;
UIGraphicsImageRenderer *const renderer = [[UIGraphicsImageRenderer alloc] initWithSize:inputImage.size
format:rendererFormat];
RCTUIGraphicsImageRendererFormat *const rendererFormat = [RCTUIGraphicsImageRendererFormat defaultFormat]; // [macOS]
rendererFormat.scale = UIImageGetScale(inputImage); // [macOS]
RCTUIGraphicsImageRenderer *const renderer = [[RCTUIGraphicsImageRenderer alloc] initWithSize:inputImage.size // [macOS]
format:rendererFormat];

#if !TARGET_OS_OSX // [macOS]
imageRef = [renderer imageWithActions:^(UIGraphicsImageRendererContext *_Nonnull context) {
[inputImage drawAtPoint:CGPointZero];
}].CGImage;
#else // [macOS
UIGraphicsBeginImageContextWithOptions(inputImage.size, NO, imageScale);
[inputImage drawAtPoint:CGPointZero fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:1.0];
imageRef = (CGImageRef)CFAutorelease(CGBitmapContextCreateImage(UIGraphicsGetCurrentContext()));
UIGraphicsEndImageContext();
NSImage *image = [renderer imageWithActions:^(RCTUIGraphicsImageRendererContext *_Nonnull context) {
[inputImage drawAtPoint:CGPointZero fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:1.0];
}];
imageRef = UIImageGetCGImageRef(image);
#endif // macOS]
}

vImage_Buffer buffer1, buffer2;
buffer1.width = buffer2.width = CGImageGetWidth(imageRef);
buffer1.height = buffer2.height = CGImageGetHeight(imageRef);
Expand Down
18 changes: 6 additions & 12 deletions packages/react-native/Libraries/Image/RCTImageUtils.mm
Original file line number Diff line number Diff line change
Expand Up @@ -382,25 +382,19 @@ BOOL RCTUpscalingRequired(
}

BOOL opaque = !RCTUIImageHasAlpha(image); // [macOS]
#if !TARGET_OS_OSX // [macOS]
UIGraphicsImageRendererFormat *const rendererFormat = [UIGraphicsImageRendererFormat defaultFormat];
RCTUIGraphicsImageRendererFormat *const rendererFormat = [RCTUIGraphicsImageRendererFormat defaultFormat]; // [macOS]
rendererFormat.opaque = opaque;
rendererFormat.scale = destScale;
UIGraphicsImageRenderer *const renderer = [[UIGraphicsImageRenderer alloc] initWithSize:destSize
RCTUIGraphicsImageRenderer *const renderer = [[RCTUIGraphicsImageRenderer alloc] initWithSize:destSize // [macOS]
format:rendererFormat];
return [renderer imageWithActions:^(UIGraphicsImageRendererContext *_Nonnull context) {
return [renderer imageWithActions:^(RCTUIGraphicsImageRendererContext *_Nonnull context) { // [macOS]
CGContextConcatCTM(context.CGContext, transform);
#if !TARGET_OS_OSX // [macOS]
[image drawAtPoint:CGPointZero];
}];
#else // [macOS
UIGraphicsBeginImageContextWithOptions(destSize, opaque, destScale);
CGContextRef currentContext = UIGraphicsGetCurrentContext();
CGContextConcatCTM(currentContext, transform);
[image drawAtPoint:CGPointZero fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:1.0];
UIImage *result = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return result;
[image drawAtPoint:CGPointZero fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:1.0];
#endif // macOS]
}];
}

BOOL RCTImageHasAlpha(CGImageRef image)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ - (void)deleteBackward {
}
#else // [macOS
- (BOOL)performKeyEquivalent:(NSEvent *)event {
if (!self.hasMarkedText && ![self.textInputDelegate textInputShouldHandleKeyEvent:event]) {
if (self.window.firstResponder == self && !self.hasMarkedText && ![self.textInputDelegate textInputShouldHandleKeyEvent:event]) {
return YES;
}

Expand Down
31 changes: 28 additions & 3 deletions packages/react-native/React/Base/RCTUIKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,6 @@ extern "C" {

// UIGraphics.h
CGContextRef UIGraphicsGetCurrentContext(void);
void UIGraphicsBeginImageContextWithOptions(CGSize size, BOOL opaque, CGFloat scale);
NSImage *UIGraphicsGetImageFromCurrentImageContext(void);
void UIGraphicsEndImageContext(void);
CGImageRef UIImageGetCGImageRef(NSImage *image);

#ifdef __cplusplus
Expand Down Expand Up @@ -641,3 +638,31 @@ NS_ASSUME_NONNULL_BEGIN
NS_ASSUME_NONNULL_END
@end
#endif

#if !TARGET_OS_OSX
typedef UIGraphicsImageRendererContext RCTUIGraphicsImageRendererContext;
typedef UIGraphicsImageDrawingActions RCTUIGraphicsImageDrawingActions;
typedef UIGraphicsImageRendererFormat RCTUIGraphicsImageRendererFormat;
typedef UIGraphicsImageRenderer RCTUIGraphicsImageRenderer;
#else
NS_ASSUME_NONNULL_BEGIN
typedef NSGraphicsContext RCTUIGraphicsImageRendererContext;
typedef void (^RCTUIGraphicsImageDrawingActions)(RCTUIGraphicsImageRendererContext *rendererContext);

@interface RCTUIGraphicsImageRendererFormat : NSObject

+ (instancetype)defaultFormat;

@property (nonatomic) CGFloat scale;
@property (nonatomic) BOOL opaque;

@end

@interface RCTUIGraphicsImageRenderer : NSObject

- (instancetype)initWithSize:(CGSize)size format:(RCTUIGraphicsImageRendererFormat *)format;
- (NSImage *)imageWithActions:(NS_NOESCAPE RCTUIGraphicsImageDrawingActions)actions;

@end
NS_ASSUME_NONNULL_END
#endif
Loading

0 comments on commit 0ac5979

Please sign in to comment.