Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ada v3 #1830

Merged
merged 3 commits into from
Feb 20, 2025
Merged
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
49 changes: 49 additions & 0 deletions test-app/app/src/main/assets/app/tests/testURLPattern.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

describe("URLPattern", function () {
it("throws on invalid URLPattern", function () {
var exceptionCaught = false;
try {
const pattern = new URLPattern(1);
} catch (e) {
exceptionCaught = true;
}
expect(exceptionCaught).toBe(true);
});

it("does not throw on valid URLPattern", function () {
var exceptionCaught = false;
try {
const pattern = new URLPattern("https://example.com/books/:id");
} catch (e) {
exceptionCaught = true;
}
expect(exceptionCaught).toBe(false);
});

it("parses simple pattern", function () {
const pattern = new URLPattern("https://example.com/books/:id");
expect(pattern.protocol).toBe("https");
expect(pattern.hostname).toBe("example.com");
expect(pattern.pathname).toBe("/books/:id");
expect(pattern.port).toBe("");
expect(pattern.search).toBe("*");
expect(pattern.hash).toBe("*");
expect(pattern.username).toBe("*");
expect(pattern.password).toBe("*");
expect(pattern.hasRegExpGroups).toBe(false);
});


it("parses with undefined base", function () {
const pattern = new URLPattern("https://google.com", undefined);
expect(pattern.protocol).toBe("https");
expect(pattern.hostname).toBe("google.com");
});

it("parses with null base", function () {
const pattern = new URLPattern("https://google.com", null);
expect(pattern.protocol).toBe("https");
expect(pattern.hostname).toBe("google.com");
});

});
10 changes: 5 additions & 5 deletions test-app/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ android.useAndroidX=true
# Default versions used throughout the gradle configurations
NS_DEFAULT_BUILD_TOOLS_VERSION=35.0.0
NS_DEFAULT_COMPILE_SDK_VERSION=35
NS_DEFAULT_MIN_SDK_VERSION=17
NS_DEFAULT_ANDROID_BUILD_TOOLS_VERSION=8.5.0
NS_DEFAULT_MIN_SDK_VERSION=21
NS_DEFAULT_ANDROID_BUILD_TOOLS_VERSION=8.7.0

ns_default_androidx_appcompat_version = 1.5.1
ns_default_androidx_appcompat_version = 1.7.0
ns_default_androidx_exifinterface_version = 1.3.7
ns_default_androidx_fragment_version = 1.5.7
ns_default_androidx_fragment_version = 1.8.5
ns_default_androidx_material_version = 1.8.0
ns_default_androidx_multidex_version = 2.0.1
ns_default_androidx_transition_version = 1.4.1
ns_default_androidx_transition_version = 1.5.1
ns_default_androidx_viewpager_version = 1.0.0
ns_default_asm_util_version = 9.7
ns_default_asm_version = 9.7
Expand Down
3 changes: 2 additions & 1 deletion test-app/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Tue Feb 11 10:56:28 AST 2025
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
12 changes: 5 additions & 7 deletions test-app/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# documentation: https://d.android.com/studio/projects/add-native-code.html

# Command info: https://cmake.org/cmake/help/v3.4/command/cmake_minimum_required.html
cmake_minimum_required(VERSION 3.4.1)
cmake_minimum_required(VERSION 3.18.1)

project(NativeScriptAndroidRuntime)

Expand All @@ -18,13 +18,14 @@ endif (CCACHE_FOUND AND (USE_CCACHE))
# "-DANDROID_STL=c++_static" is just not enough for clang++ to find some libraries in the ndk
MESSAGE(STATUS "## ANDROID_NDK_ROOT: " ${ANDROID_NDK_ROOT})

set(COMMON_CMAKE_ARGUMENTS "-std=c++17 -Werror -Wno-unused-result -mstackrealign -fexceptions -fno-builtin-stpcpy -fno-rtti -DV8_31BIT_SMIS_ON_64BIT_ARCH -DV8_31BIT_SMIS_ON_64BIT_ARCH -DV8_ENABLE_REGEXP_INTERPRETER_THREADED_DISPATCH -DV8_EMBEDDED_BUILTINS")
set(COMMON_CMAKE_ARGUMENTS "-std=c++20 -Werror -Wno-vla-cxx-extension -Wno-unused-result -mstackrealign -fexceptions -fno-builtin-stpcpy -fno-rtti -DV8_31BIT_SMIS_ON_64BIT_ARCH -DV8_31BIT_SMIS_ON_64BIT_ARCH -DV8_ENABLE_REGEXP_INTERPRETER_THREADED_DISPATCH -DV8_EMBEDDED_BUILTINS")

if("${ANDROID_ABI}" MATCHES "arm64-v8a$" OR "${ANDROID_ABI}" MATCHES "x86_64$")
# Enable pointer compression on 64 bit platforms
set(COMMON_CMAKE_ARGUMENTS "${COMMON_CMAKE_ARGUMENTS} -DV8_COMPRESS_POINTERS")
endif()


# AOSP has switched to using LLD by default and the NDK will use it by default in the next release.
# BFD and Gold will be removed once LLD has been through a release cycle with no major unresolved issues (estimated r21)
# Note: lld does not currently work on Windows: https://github.com/android-ndk/ndk/issues/888
Expand Down Expand Up @@ -142,6 +143,7 @@ add_library(
src/main/cpp/ada/ada.cpp
src/main/cpp/URLImpl.cpp
src/main/cpp/URLSearchParamsImpl.cpp
src/main/cpp/URLPatternImpl.cpp

# V8 inspector source files will be included only in Release mode
${INSPECTOR_SOURCES}
Expand All @@ -163,6 +165,7 @@ else ()
)
endif ()


MESSAGE(STATUS "# General cmake Info")
MESSAGE(STATUS "# PROJECT_SOURCE_DIR: " ${PROJECT_SOURCE_DIR})
MESSAGE(STATUS "# CMAKE_VERSION: " ${CMAKE_VERSION})
Expand All @@ -183,11 +186,6 @@ if("${ANDROID_ABI}" MATCHES "armeabi-v7a$" OR "${ANDROID_ABI}" MATCHES "x86$")
target_link_libraries(NativeScript ${ANDROID_NDK_ROOT}/sources/cxx-stl/llvm-libc++/libs/${ANDROID_ABI}/libandroid_support.a)
endif()


if("${ANDROID_ABI}" MATCHES "arm64-v8a$" OR "${ANDROID_ABI}" MATCHES "x86_64$")
target_link_options(NativeScript PRIVATE "-Wl,-z,max-page-size=16384")
endif()

# Command info: https://cmake.org/cmake/help/v3.4/command/find_library.html
# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
Expand Down
7 changes: 4 additions & 3 deletions test-app/runtime/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ if (useCCache) {
}


def defaultNdkVersion = "23.2.8568313"
def defaultNdkVersion = "27.2.12479018"


def hasNdkVersion = project.hasProperty("ndkVersion")
if (hasNdkVersion) {
Expand Down Expand Up @@ -113,7 +114,7 @@ android {
//
// arguments "-DANDROID_TOOLCHAIN=clang", "-DANDROID_STL=c++_static", "-DANDROID_NDK_ROOT=${NDK_PATH}"

cppFlags "-std=c++14"
cppFlags "-std=c++20"
arguments "-DANDROID_STL=c++_static", "-DANDROID_NDK_ROOT=${NDK_PATH}"
}
}
Expand Down Expand Up @@ -147,7 +148,7 @@ allprojects {
gradle.projectsEvaluated {
tasks.withType(JavaCompile).tap {
configureEach {
options.compilerArgs << "-Xlint:all" << "-Werror"
//options.compilerArgs << "-Xlint:all" << "-Werror"
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions test-app/runtime/src/main/cpp/Runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "ModuleBinding.h"
#include "URLImpl.h"
#include "URLSearchParamsImpl.h"
#include "URLPatternImpl.h"

#ifdef APPLICATION_IN_DEBUG
// #include "NetworkDomainCallbackHandlers.h"
Expand Down Expand Up @@ -529,6 +530,7 @@ Isolate* Runtime::PrepareV8Runtime(const string& filesPath, const string& native
globalTemplate->Set(ArgConverter::ConvertToV8String(isolate, "__removeFrameCallback"), FunctionTemplate::New(isolate, CallbackHandlers::RemoveFrameCallback));
globalTemplate->Set(ArgConverter::ConvertToV8String(isolate, "URL"), URLImpl::GetCtor(isolate));
globalTemplate->Set(ArgConverter::ConvertToV8String(isolate, "URLSearchParams"), URLSearchParamsImpl::GetCtor(isolate));
globalTemplate->Set(ArgConverter::ConvertToV8String(isolate, "URLPattern"), URLPatternImpl::GetCtor(isolate));

/*
* Attach `Worker` object constructor only to the main thread (isolate)'s global object
Expand Down
2 changes: 1 addition & 1 deletion test-app/runtime/src/main/cpp/Timers.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ namespace tns {
// background thread lost cycles
std::set<int> deletedTimers_;
int fd_[2];
std::atomic_bool isBufferFull = ATOMIC_VAR_INIT(false);
std::atomic_bool isBufferFull = false;
std::condition_variable taskReady;
std::condition_variable bufferFull;
std::mutex mutex;
Expand Down
3 changes: 3 additions & 0 deletions test-app/runtime/src/main/cpp/URLImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ v8::Local<v8::FunctionTemplate> URLImpl::GetCtor(v8::Isolate *isolate) {
tmpl->SetAccessor(
ArgConverter::ConvertToV8String(isolate, "host"),
GetHost, SetHost);
tmpl->SetAccessor(
ArgConverter::ConvertToV8String(isolate, "hash"),
GetHash, SetHash);
tmpl->SetAccessor(
ArgConverter::ConvertToV8String(isolate, "hostname"),
GetHostName, SetHostName);
Expand Down
Loading
Loading