Skip to content

Commit 93f6c82

Browse files
authored
Merge origin/main into fix/throw-errors
2 parents a9b1610 + debf7f8 commit 93f6c82

14 files changed

Lines changed: 526 additions & 589 deletions

File tree

‎.github/workflows/dependency-review.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ jobs:
1919
- name: 'Checkout Repository'
2020
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2121
- name: 'Dependency Review'
22-
uses: actions/dependency-review-action@2031cfc080254a8a887f58cffee85186f0e49e48 # v4.9.0
22+
uses: actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294 # v5.0.0

‎.github/workflows/npm_release.yml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
npm_tag: ${{ steps.npm_version_output.outputs.NPM_TAG }}
1919
steps:
2020
- name: Harden the runner (Audit all outbound calls)
21-
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
21+
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
2222
with:
2323
egress-policy: audit
2424
- uses: maxim-lobanov/setup-xcode@ed7a3b1fda3918c0306d1b724322adc0b8cc0a90 # v1.7.0
@@ -87,7 +87,7 @@ jobs:
8787
needs: build
8888
steps:
8989
- name: Harden the runner (Audit all outbound calls)
90-
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
90+
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
9191
with:
9292
egress-policy: audit
9393
- uses: maxim-lobanov/setup-xcode@ed7a3b1fda3918c0306d1b724322adc0b8cc0a90 # v1.7.0
@@ -162,7 +162,7 @@ jobs:
162162
NPM_TAG: ${{needs.build.outputs.npm_tag}}
163163
steps:
164164
- name: Harden the runner (Audit all outbound calls)
165-
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
165+
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
166166
with:
167167
egress-policy: audit
168168
- uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
@@ -211,7 +211,7 @@ jobs:
211211
NPM_VERSION: ${{needs.build.outputs.npm_version}}
212212
steps:
213213
- name: Harden the runner (Audit all outbound calls)
214-
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
214+
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
215215
with:
216216
egress-policy: audit
217217
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

‎.github/workflows/scorecards.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,6 @@ jobs:
6868

6969
# Upload the results to GitHub's code scanning dashboard.
7070
- name: "Upload to code-scanning"
71-
uses: github/codeql-action/upload-sarif@89a39a4e59826350b863aa6b6252a07ad50cf83e # v4.32.4
71+
uses: github/codeql-action/upload-sarif@7211b7c8077ea37d8641b6271f6a365a22a5fbfa # v4.36.0
7272
with:
7373
sarif_file: results.sarif

‎NativeScript/inspector/JsV8InspectorClient.mm‎

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,20 @@
2222

2323
namespace v8_inspector {
2424

25+
namespace {
26+
// Build an 8-bit `StringView` directly over a `std::string`'s storage.
27+
// V8 inspector messages on this side are ASCII/UTF-8 JSON, so the
28+
// previous `std::string -> std::vector<uint16_t> -> StringView` path
29+
// inflated each byte to two and then handed it to a 16-bit constructor.
30+
// Going straight through the 8-bit constructor avoids that doubling AND
31+
// dodges the libc++ deprecation that prompted the inspector's
32+
// `UChar = uint16_t -> char16_t` switch.
33+
StringView Make8BitStringView(const std::string& value) {
34+
return StringView(reinterpret_cast<const uint8_t*>(value.data()),
35+
value.size());
36+
}
37+
} // namespace
38+
2539
#define NOTIFICATION(name) \
2640
[[NSString stringWithFormat:@"%@:NativeScript.Debug.%s", \
2741
[[NSBundle mainBundle] bundleIdentifier], name] UTF8String]
@@ -128,6 +142,18 @@
128142
dispatch_semaphore_signal(messageArrived_);
129143
});
130144

145+
// Debugger.pause needs to interrupt V8 even if the main thread is busy
146+
// executing JS. RequestInterrupt fires at the next safe bytecode boundary.
147+
auto parsed = json::parse(message, nullptr, false);
148+
if (!parsed.is_discarded() && parsed.contains("method") && parsed["method"] == "Debugger.pause") {
149+
isolate_->RequestInterrupt(
150+
[](Isolate* isolate, void* data) {
151+
auto client = static_cast<JsV8InspectorClient*>(data);
152+
client->session_->schedulePauseOnNextStatement({}, {});
153+
},
154+
this);
155+
}
156+
131157
tns::ExecuteOnMainThread([this, message]() {
132158
dispatch_sync(this->messageLoopQueue_, ^{
133159
// prevent execution if we're already pumping messages
@@ -257,8 +283,7 @@
257283
}
258284

259285
void JsV8InspectorClient::dispatchMessage(const std::string& message) {
260-
std::vector<uint16_t> vector = tns::ToVector(message);
261-
StringView messageView(vector.data(), vector.size());
286+
StringView messageView = Make8BitStringView(message);
262287
Isolate* isolate = isolate_;
263288
v8::Locker locker(isolate);
264289
Isolate::Scope isolate_scope(isolate);
@@ -343,8 +368,7 @@
343368
auto returnString = GetReturnMessageFromDomainHandlerResult(result, requestId);
344369

345370
if (returnString.size() > 0) {
346-
std::vector<uint16_t> vector = tns::ToVector(returnString);
347-
StringView messageView(vector.data(), vector.size());
371+
StringView messageView = Make8BitStringView(returnString);
348372
auto msg = StringBuffer::create(messageView);
349373
this->sendNotification(std::move(msg));
350374
}
@@ -486,8 +510,7 @@
486510
Local<v8::String> arg = args[0].As<v8::String>();
487511
std::string message = tns::ToString(isolate, arg);
488512

489-
std::vector<uint16_t> vector = tns::ToVector(message);
490-
StringView messageView(vector.data(), vector.size());
513+
StringView messageView = Make8BitStringView(message);
491514
auto msg = StringBuffer::create(messageView);
492515
client->sendNotification(std::move(msg));
493516
}

‎NativeScript/inspector/src/inspector/string-16.h‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@
1717

1818
namespace v8_inspector {
1919

20-
using UChar = uint16_t;
20+
// Xcode 26.x libc++ deprecates `std::basic_string<unsigned short>`
21+
// (and any `char_traits<T>` specialization for non-standard char types).
22+
// Switch to `char16_t` so `std::basic_string<UChar>` resolves to the
23+
// fully supported `std::u16string`. The V8 inspector public API still
24+
// takes `uint16_t*`, so call sites that cross that boundary now use
25+
// `reinterpret_cast` (see string-util.h).
26+
using UChar = char16_t;
2127

2228
class String16 {
2329
public:

‎NativeScript/inspector/src/inspector/string-util.h‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,17 @@ class StringUtil {
3030
}
3131

3232
static String fromUTF16LE(const uint16_t* data, size_t length) {
33-
return String16::fromUTF16LE(data, length);
33+
// V8 inspector protocol passes `uint16_t*` over its public API but
34+
// `String16` is now backed by `std::u16string` (UChar = char16_t).
35+
// The two are bit-identical 16-bit codepoints, so a reinterpret_cast
36+
// is sound at the API boundary.
37+
return String16::fromUTF16LE(reinterpret_cast<const UChar*>(data), length);
3438
}
3539

3640
static const uint8_t* CharactersLatin1(const String& s) { return nullptr; }
3741
static const uint8_t* CharactersUTF8(const String& s) { return nullptr; }
3842
static const uint16_t* CharactersUTF16(const String& s) {
39-
return s.characters16();
43+
return reinterpret_cast<const uint16_t*>(s.characters16());
4044
}
4145
static size_t CharacterCount(const String& s) { return s.length(); }
4246
};

‎NativeScript/inspector/utils.mm‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,22 @@
3535
}
3636

3737
std::string v8_inspector::ToStdString(const StringView& value) {
38-
std::vector<uint16_t> buffer(value.length());
38+
// Build the std::u16string directly. The previous version went via
39+
// std::vector<uint16_t> + a copy-construct into u16string, which on
40+
// Xcode 26.x's libc++ tripped the `char_traits<unsigned short>`
41+
// deprecation through the construct-from-iterator path. Writing
42+
// char16_t straight into the destination avoids the
43+
// non-standard char-traits specialization entirely.
44+
std::u16string value16;
45+
value16.resize(value.length());
3946
for (size_t i = 0; i < value.length(); i++) {
4047
if (value.is8Bit()) {
41-
buffer[i] = value.characters8()[i];
48+
value16[i] = static_cast<char16_t>(value.characters8()[i]);
4249
} else {
43-
buffer[i] = value.characters16()[i];
50+
value16[i] = static_cast<char16_t>(value.characters16()[i]);
4451
}
4552
}
4653

47-
std::u16string value16(buffer.begin(), buffer.end());
48-
4954
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
5055
// FIXME: std::codecvt_utf8_utf16 is deprecated
5156
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert;

0 commit comments

Comments
 (0)