Skip to content

Commit b31fc5f

Browse files
authored
feat: ada v3 (#1830)
1 parent e293636 commit b31fc5f

File tree

14 files changed

+9904
-4127
lines changed

14 files changed

+9904
-4127
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
2+
describe("URLPattern", function () {
3+
it("throws on invalid URLPattern", function () {
4+
var exceptionCaught = false;
5+
try {
6+
const pattern = new URLPattern(1);
7+
} catch (e) {
8+
exceptionCaught = true;
9+
}
10+
expect(exceptionCaught).toBe(true);
11+
});
12+
13+
it("does not throw on valid URLPattern", function () {
14+
var exceptionCaught = false;
15+
try {
16+
const pattern = new URLPattern("https://example.com/books/:id");
17+
} catch (e) {
18+
exceptionCaught = true;
19+
}
20+
expect(exceptionCaught).toBe(false);
21+
});
22+
23+
it("parses simple pattern", function () {
24+
const pattern = new URLPattern("https://example.com/books/:id");
25+
expect(pattern.protocol).toBe("https");
26+
expect(pattern.hostname).toBe("example.com");
27+
expect(pattern.pathname).toBe("/books/:id");
28+
expect(pattern.port).toBe("");
29+
expect(pattern.search).toBe("*");
30+
expect(pattern.hash).toBe("*");
31+
expect(pattern.username).toBe("*");
32+
expect(pattern.password).toBe("*");
33+
expect(pattern.hasRegExpGroups).toBe(false);
34+
});
35+
36+
37+
it("parses with undefined base", function () {
38+
const pattern = new URLPattern("https://google.com", undefined);
39+
expect(pattern.protocol).toBe("https");
40+
expect(pattern.hostname).toBe("google.com");
41+
});
42+
43+
it("parses with null base", function () {
44+
const pattern = new URLPattern("https://google.com", null);
45+
expect(pattern.protocol).toBe("https");
46+
expect(pattern.hostname).toBe("google.com");
47+
});
48+
49+
});

test-app/gradle.properties

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ android.useAndroidX=true
2121
# Default versions used throughout the gradle configurations
2222
NS_DEFAULT_BUILD_TOOLS_VERSION=35.0.0
2323
NS_DEFAULT_COMPILE_SDK_VERSION=35
24-
NS_DEFAULT_MIN_SDK_VERSION=17
25-
NS_DEFAULT_ANDROID_BUILD_TOOLS_VERSION=8.5.0
24+
NS_DEFAULT_MIN_SDK_VERSION=21
25+
NS_DEFAULT_ANDROID_BUILD_TOOLS_VERSION=8.7.0
2626

27-
ns_default_androidx_appcompat_version = 1.5.1
27+
ns_default_androidx_appcompat_version = 1.7.0
2828
ns_default_androidx_exifinterface_version = 1.3.7
29-
ns_default_androidx_fragment_version = 1.5.7
29+
ns_default_androidx_fragment_version = 1.8.5
3030
ns_default_androidx_material_version = 1.8.0
3131
ns_default_androidx_multidex_version = 2.0.1
32-
ns_default_androidx_transition_version = 1.4.1
32+
ns_default_androidx_transition_version = 1.5.1
3333
ns_default_androidx_viewpager_version = 1.0.0
3434
ns_default_asm_util_version = 9.7
3535
ns_default_asm_version = 9.7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
#Tue Feb 11 10:56:28 AST 2025
12
distributionBase=GRADLE_USER_HOME
23
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
45
zipStoreBase=GRADLE_USER_HOME
56
zipStorePath=wrapper/dists

test-app/runtime/CMakeLists.txt

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# documentation: https://d.android.com/studio/projects/add-native-code.html
22

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

66
project(NativeScriptAndroidRuntime)
77

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

21-
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")
21+
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")
2222

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

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

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

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

186-
187-
if("${ANDROID_ABI}" MATCHES "arm64-v8a$" OR "${ANDROID_ABI}" MATCHES "x86_64$")
188-
target_link_options(NativeScript PRIVATE "-Wl,-z,max-page-size=16384")
189-
endif()
190-
191189
# Command info: https://cmake.org/cmake/help/v3.4/command/find_library.html
192190
# Searches for a specified prebuilt library and stores the path as a
193191
# variable. Because CMake includes system libraries in the search path by

test-app/runtime/build.gradle

+4-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ if (useCCache) {
2121
}
2222

2323

24-
def defaultNdkVersion = "23.2.8568313"
24+
def defaultNdkVersion = "27.2.12479018"
25+
2526

2627
def hasNdkVersion = project.hasProperty("ndkVersion")
2728
if (hasNdkVersion) {
@@ -113,7 +114,7 @@ android {
113114
//
114115
// arguments "-DANDROID_TOOLCHAIN=clang", "-DANDROID_STL=c++_static", "-DANDROID_NDK_ROOT=${NDK_PATH}"
115116

116-
cppFlags "-std=c++14"
117+
cppFlags "-std=c++20"
117118
arguments "-DANDROID_STL=c++_static", "-DANDROID_NDK_ROOT=${NDK_PATH}"
118119
}
119120
}
@@ -147,7 +148,7 @@ allprojects {
147148
gradle.projectsEvaluated {
148149
tasks.withType(JavaCompile).tap {
149150
configureEach {
150-
options.compilerArgs << "-Xlint:all" << "-Werror"
151+
//options.compilerArgs << "-Xlint:all" << "-Werror"
151152
}
152153
}
153154
}

test-app/runtime/src/main/cpp/Runtime.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "ModuleBinding.h"
3434
#include "URLImpl.h"
3535
#include "URLSearchParamsImpl.h"
36+
#include "URLPatternImpl.h"
3637

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

533535
/*
534536
* Attach `Worker` object constructor only to the main thread (isolate)'s global object

test-app/runtime/src/main/cpp/Timers.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ namespace tns {
123123
// background thread lost cycles
124124
std::set<int> deletedTimers_;
125125
int fd_[2];
126-
std::atomic_bool isBufferFull = ATOMIC_VAR_INIT(false);
126+
std::atomic_bool isBufferFull = false;
127127
std::condition_variable taskReady;
128128
std::condition_variable bufferFull;
129129
std::mutex mutex;

test-app/runtime/src/main/cpp/URLImpl.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ v8::Local<v8::FunctionTemplate> URLImpl::GetCtor(v8::Isolate *isolate) {
3333
tmpl->SetAccessor(
3434
ArgConverter::ConvertToV8String(isolate, "host"),
3535
GetHost, SetHost);
36+
tmpl->SetAccessor(
37+
ArgConverter::ConvertToV8String(isolate, "hash"),
38+
GetHash, SetHash);
3639
tmpl->SetAccessor(
3740
ArgConverter::ConvertToV8String(isolate, "hostname"),
3841
GetHostName, SetHostName);

0 commit comments

Comments
 (0)