Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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: 2 additions & 2 deletions macos/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1841,7 +1841,7 @@ PODS:
- Yoga
- Sentry/HybridSDK (8.56.1)
- SocketRocket (0.7.1)
- Sparkle (2.8.1)
- Sparkle (2.9.0)
- Yoga (0.0.0)

DEPENDENCIES:
Expand Down Expand Up @@ -2173,7 +2173,7 @@ SPEC CHECKSUMS:
RNSentry: eeaaa1a61ce59874fb46bba120042464618723e6
Sentry: b3ec44d01708fce73f99b544beb57e890eca4406
SocketRocket: 03f7111df1a343b162bf5b06ead333be808e1e0a
Sparkle: a346a4341537c625955751ed3ae4b340b68551fa
Sparkle: f4355f9ebbe9b7d932df4980d70f13922ac97b2a
Yoga: be08366e61155f388be00b3943f4b3febdef8d30

PODFILE CHECKSUM: 09d9f4d8690650f7bbc4a5e78de155d44c82904c
Expand Down
3 changes: 1 addition & 2 deletions macos/sol-macOS/lib/ClipboardHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ class ClipboardHelper {
self, selector: #selector(frontmostAppChanged(sender:)),
name: NSWorkspace.didActivateApplicationNotification, object: nil)

// TODO find if there is any better way to observe for changes other than continously check if the amount of items has changed
Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { _ in
Timer.scheduledTimer(withTimeInterval: 0.2, repeats: true) { _ in
if pasteboard.changeCount != changeCount {
callback(pasteboard, self.frontmostApp)
changeCount = pasteboard.changeCount
Expand Down
5 changes: 4 additions & 1 deletion macos/sol-macOS/lib/FileSearch.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
#include <vector>
#include <string>

static const int MAX_SEARCH_DEPTH = 5;
static const size_t MAX_SEARCH_RESULTS = 200;

struct File {
std::string path;
bool is_folder;
std::string name;
};

std::vector<File> search_files(NSString *basePath, NSString *query);
std::vector<File> search_files(NSString *basePath, NSString *query, int depth = 0, size_t *result_count = nullptr);

#endif /* FileSearch_h */
65 changes: 54 additions & 11 deletions macos/sol-macOS/lib/FileSearch.mm
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,83 @@
#include "FileSearch.h"
#include "NSString+Score.h"

std::vector<File> search_files(NSString *basePath, NSString *query) {
static NSSet *skippedDirectories = nil;

static NSSet *getSkippedDirectories() {
if (!skippedDirectories) {
skippedDirectories = [NSSet setWithObjects:
@"node_modules", @".git", @"Library", @".cache",
@".Trash", @"__pycache__", @".npm", @".yarn",
@"Pods", @"build", @"DerivedData", nil];
}
return skippedDirectories;
}

static bool shouldSkipDirectory(NSString *name) {
if ([name hasPrefix:@"."]) return true;
if ([name hasSuffix:@".app"]) return true;
if ([name hasSuffix:@".framework"]) return true;
if ([getSkippedDirectories() containsObject:name]) return true;
return false;
}

std::vector<File> search_files(NSString *basePath, NSString *query, int depth, size_t *result_count) {
std::vector<File> files;

size_t localCount = 0;
if (!result_count) {
result_count = &localCount;
}

if (depth >= MAX_SEARCH_DEPTH || *result_count >= MAX_SEARCH_RESULTS) {
return files;
}

NSFileManager *defFM = [NSFileManager defaultManager];
NSError *error = nil;
NSArray *dirPath = [defFM contentsOfDirectoryAtPath:basePath error:&error];
if (!dirPath) {
return files;
}

for(NSString *path in dirPath) {
if (*result_count >= MAX_SEARCH_RESULTS) {
break;
}

BOOL is_dir;
NSString *full_path = [basePath stringByAppendingPathComponent:path];
std::string cpp_full_path = [full_path UTF8String];
float distance = [path scoreAgainst:query];

if([defFM fileExistsAtPath:full_path isDirectory:&is_dir] && is_dir){

if([defFM fileExistsAtPath:full_path isDirectory:&is_dir] && is_dir) {
if (shouldSkipDirectory(path)) {
continue;
}

if (distance > 0.5) {
files.push_back({
.path = cpp_full_path,
.is_folder = true,
.name = [path UTF8String]
});
(*result_count)++;
}

std::vector<File> sub_files = search_files(full_path, query);
files.insert(files.end(), sub_files.begin(), sub_files.end());
} else {

if (distance > 0.5) {
std::vector<File> sub_files = search_files(full_path, query, depth + 1, result_count);
files.insert(files.end(), sub_files.begin(), sub_files.end());
} else {
if (distance > 0.5) {
files.push_back({
.path = cpp_full_path,
.is_folder = false,
.name = [path UTF8String]
});
(*result_count)++;
}
}
}
}
return files;

return files;
}

7 changes: 6 additions & 1 deletion macos/sol-macOS/lib/JSIBindings.mm
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,16 @@ void install(jsi::Runtime &rt,
auto paths = arguments[0].asObject(rt).asArray(rt);
auto query = arguments[1].asString(rt).utf8(rt);
std::vector<File> res;
size_t result_count = 0;
for (size_t i = 0; i < paths.size(rt); i++) {
if (result_count >= MAX_SEARCH_RESULTS) {
break;
}
auto path = paths.getValueAtIndex(rt, i).asString(rt).utf8(rt);
std::vector<File> path_results =
search_files([NSString stringWithUTF8String:path.c_str()],
[NSString stringWithUTF8String:query.c_str()]);
[NSString stringWithUTF8String:query.c_str()],
0, &result_count);
res.insert(res.end(), path_results.begin(), path_results.end());
}

Expand Down
35 changes: 26 additions & 9 deletions macos/sol.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,8 @@
83CBB9F71A601CBA00E9B192 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1340;
BuildIndependentTargetsInParallel = YES;
LastUpgradeCheck = 2630;
TargetAttributes = {
514201482437B4B30078DB4F = {
CreatedOnToolsVersion = 11.4;
Expand Down Expand Up @@ -432,7 +433,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "set -e\n\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\nSENTRY_XCODE=\"../node_modules/@sentry/react-native/scripts/sentry-xcode.sh\"\nBUNDLE_REACT_NATIVE=\"/bin/sh $SENTRY_XCODE $REACT_NATIVE_XCODE\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT \\\"$BUNDLE_REACT_NATIVE\\\"\"\n";
shellScript = "set -e\n\nexport SENTRY_DISABLE_AUTO_UPLOAD=${SENTRY_DISABLE_AUTO_UPLOAD:-true}\n\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\nSENTRY_XCODE=\"../node_modules/@sentry/react-native/scripts/sentry-xcode.sh\"\nBUNDLE_REACT_NATIVE=\"/bin/sh $SENTRY_XCODE $REACT_NATIVE_XCODE\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT \\\"$BUNDLE_REACT_NATIVE\\\"\"\n";
};
381D8A6F24576A6C00465D17 /* Start Packager */ = {
isa = PBXShellScriptBuildPhase;
Expand Down Expand Up @@ -529,7 +530,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "/bin/sh ../node_modules/@sentry/react-native/scripts/sentry-xcode-debug-files.sh\n";
shellScript = "export SENTRY_DISABLE_AUTO_UPLOAD=${SENTRY_DISABLE_AUTO_UPLOAD:-true}\n/bin/sh ../node_modules/@sentry/react-native/scripts/sentry-xcode-debug-files.sh\n";
};
9ACD38329CAF517BAD27034C /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
Expand Down Expand Up @@ -666,15 +667,21 @@
baseConfigurationReference = 434AA4134E3E6A10DF347D75 /* Pods-macOS.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
AUTOMATION_APPLE_EVENTS = YES;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = "sol-macOS/sol-macOS.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = NO;
DEVELOPMENT_TEAM = 24CMR7378R;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = FFRGZZ3V5A;
ENABLE_APP_SANDBOX = NO;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_OUTGOING_NETWORK_CONNECTIONS = YES;
ENABLE_RESOURCE_ACCESS_CALENDARS = YES;
ENABLE_RESOURCE_ACCESS_LOCATION = YES;
ENABLE_USER_SELECTED_FILES = readonly;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "i386 arm64";
INFOPLIST_FILE = "sol-macos/Info.plist";
INFOPLIST_KEY_CFBundleDisplayName = SolDebug;
Expand Down Expand Up @@ -706,15 +713,21 @@
baseConfigurationReference = 95E8C102E7DEC7DFB286A43C /* Pods-macOS.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
AUTOMATION_APPLE_EVENTS = YES;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = "sol-macOS/sol-macOS.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = NO;
DEVELOPMENT_TEAM = 24CMR7378R;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = FFRGZZ3V5A;
ENABLE_APP_SANDBOX = NO;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_OUTGOING_NETWORK_CONNECTIONS = YES;
ENABLE_RESOURCE_ACCESS_CALENDARS = YES;
ENABLE_RESOURCE_ACCESS_LOCATION = YES;
ENABLE_USER_SELECTED_FILES = readonly;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "i386 arm64";
INFOPLIST_FILE = "sol-macos/Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
Expand Down Expand Up @@ -772,6 +785,7 @@
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = i386;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
Expand All @@ -789,7 +803,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = (
/usr/lib/swift,
"$(inherited)",
Expand All @@ -803,6 +817,7 @@
OTHER_LDFLAGS = "$(inherited)";
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
STRING_CATALOG_GENERATE_SYMBOLS = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) DEBUG";
USE_HERMES = true;
};
Expand Down Expand Up @@ -841,6 +856,7 @@
COPY_PHASE_STRIP = YES;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = i386;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
Expand All @@ -854,7 +870,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = (
/usr/lib/swift,
"$(inherited)",
Expand All @@ -867,6 +883,7 @@
OTHER_LDFLAGS = "$(inherited)";
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
STRING_CATALOG_GENERATE_SYMBOLS = YES;
SWIFT_COMPILATION_MODE = wholemodule;
USE_HERMES = true;
VALIDATE_PRODUCT = YES;
Expand Down
2 changes: 1 addition & 1 deletion macos/sol.xcodeproj/xcshareddata/xcschemes/debug.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1340"
LastUpgradeVersion = "2630"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1340"
LastUpgradeVersion = "2630"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Loading
Loading