diff --git a/.appveyor.yml b/.appveyor.yml index 28afb32b..a97a5b09 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,5 +1,5 @@ environment: - NODEJS_VERSION: "10" + NODEJS_VERSION: "16" PREBUILD_UPLOAD: secure: oNyyLE7/Oq3TUGZPz6DkLFPUuQzc8FiFS1iuPp7LZ2fyOP/UF4Np4NzJmWcXVyY/ @@ -7,8 +7,11 @@ platform: - x64 - x86 +image: Ubuntu + +stack: node 16, python 3.10 + install: - - ps: Install-Product node $env:NODEJS_VERSION $env:Platform - git submodule update --init --recursive - npm install diff --git a/binding.gyp b/binding.gyp index 8f93e64f..e703906c 100644 --- a/binding.gyp +++ b/binding.gyp @@ -49,7 +49,10 @@ ] } ], - 'variables': { 'runtime%': 'node' }, + 'variables': { + 'runtime%': 'node', + 'openssl_fips': '', + }, 'conditions': [ ['runtime=="electron"', { 'defines': ['NODE_RUNTIME_ELECTRON=1'] }], ] diff --git a/package.json b/package.json index e4232aff..6c5d7deb 100644 --- a/package.json +++ b/package.json @@ -15,21 +15,27 @@ "main": "index.js", "types": "tree-sitter.d.ts", "dependencies": { - "nan": "^2.14.0", - "prebuild-install": "^6.0.1" + "nan": "^2.17.0", + "prebuild-install": "^7.1.1" }, "devDependencies": { - "@types/node": "^14.14.31", - "chai": "^4.3.3", - "mocha": "^8.3.1", - "prebuild": "^10.0.1", - "superstring": "^2.4.2", + "@types/node": "^18.14.6", + "chai": "^4.3.7", + "mocha": "^10.2.0", + "node-gyp": "9.3.1", + "prebuild": "^11.0.4", + "superstring": "^2.4.4", "tree-sitter-javascript": "https://github.com/tree-sitter/tree-sitter-javascript.git#master" }, + "overrides": { + "prebuild": { + "node-gyp": "$node-gyp" + } + }, "scripts": { "install": "prebuild-install || node-gyp rebuild", "build": "node-gyp build", - "prebuild": "prebuild -r electron -t 3.0.0 -t 4.0.0 -t 4.0.4 -t 5.0.0 --strip && prebuild -t 10.12.0 -t 12.13.0 --strip", + "prebuild": "prebuild -r electron -t 16.0.0 -t 17.0.0 -t 18.0.0 -t 19.0.0 -t 20.0.0 -t 21.0.0 -t 22.0.0 -t 23.0.0 -t 23.0.0 --strip && prebuild -t 14.0.0 -t 16.0.0 -t 18.0.0 -t 20.0.0 --strip", "prebuild:upload": "prebuild --upload-all", "test": "mocha" } diff --git a/src/conversions.cc b/src/conversions.cc index fefe01d7..0c749dd9 100644 --- a/src/conversions.cc +++ b/src/conversions.cc @@ -34,7 +34,7 @@ void InitConversions(Local exports) { v8::Local bufferView; bufferView = node::Buffer::New(Isolate::GetCurrent(), point_transfer_buffer, 0, 2 * sizeof(uint32_t)).ToLocalChecked(); auto js_point_transfer_buffer = node::Buffer::Data(bufferView); - #elif V8_MAJOR_VERSION >= 8 + #elif (V8_MAJOR_VERSION > 8 || (V8_MAJOR_VERSION == 8 && V8_MINOR_VERION > 3)) auto backing_store = ArrayBuffer::NewBackingStore(point_transfer_buffer, 2 * sizeof(uint32_t), BackingStore::EmptyDeleter, nullptr); auto js_point_transfer_buffer = ArrayBuffer::New(Isolate::GetCurrent(), std::move(backing_store)); #else diff --git a/src/logger.cc b/src/logger.cc index 5f0cacd1..aeb86ff7 100644 --- a/src/logger.cc +++ b/src/logger.cc @@ -41,14 +41,24 @@ void Logger::Log(void *payload, TSLogType type, const char *message_str) { Local argv[3] = { name, params, type_name }; TryCatch try_catch(Isolate::GetCurrent()); - Nan::Call(fn, fn->CreationContext()->Global(), 3, argv); + + #if (V8_MAJOR_VERSION > 9 || (V8_MAJOR_VERSION == 9 && V8_MINOR_VERION > 4)) + Nan::Call(fn, fn->GetCreationContext().ToLocalChecked()->Global(), 3, argv); + #else + Nan::Call(fn, fn->CreationContext()->Global(), 3, argv); + #endif if (try_catch.HasCaught()) { Local log_argv[2] = { Nan::New("Error in debug callback:").ToLocalChecked(), try_catch.Exception() }; - Local console = Local::Cast(Nan::Get(fn->CreationContext()->Global(), Nan::New("console").ToLocalChecked()).ToLocalChecked()); + + #if (V8_MAJOR_VERSION > 9 || (V8_MAJOR_VERSION == 9 && V8_MINOR_VERION > 4)) + Local console = Local::Cast(Nan::Get(fn->GetCreationContext().ToLocalChecked()->Global(), Nan::New("console").ToLocalChecked()).ToLocalChecked()); + #else + Local console = Local::Cast(Nan::Get(fn->CreationContext()->Global(), Nan::New("console").ToLocalChecked()).ToLocalChecked()); + #endif Local error_fn = Local::Cast(Nan::Get(console, Nan::New("error").ToLocalChecked()).ToLocalChecked()); Nan::Call(error_fn, console, 2, log_argv); } diff --git a/src/node.cc b/src/node.cc index be9b0468..f855ec7c 100644 --- a/src/node.cc +++ b/src/node.cc @@ -35,7 +35,7 @@ static inline void setup_transfer_buffer(uint32_t node_count) { v8::Local bufferView; bufferView = node::Buffer::New(Isolate::GetCurrent(), transfer_buffer, 0, transfer_buffer_length * sizeof(uint32_t)).ToLocalChecked(); auto js_point_transfer_buffer = node::Buffer::Data(bufferView); - #elif V8_MAJOR_VERSION >= 8 + #elif (V8_MAJOR_VERSION > 8 || (V8_MAJOR_VERSION == 8 && V8_MINOR_VERION > 3)) auto backing_store = ArrayBuffer::NewBackingStore(transfer_buffer, transfer_buffer_length * sizeof(uint32_t), BackingStore::EmptyDeleter, nullptr); auto js_transfer_buffer = ArrayBuffer::New(Isolate::GetCurrent(), std::move(backing_store)); #else diff --git a/src/parser.cc b/src/parser.cc index 52e1beac..cd333a87 100644 --- a/src/parser.cc +++ b/src/parser.cc @@ -60,7 +60,11 @@ class CallbackInput { uint32_t utf16_unit = byte / 2; Local argv[2] = { Nan::New(utf16_unit), PointToJS(position) }; TryCatch try_catch(Isolate::GetCurrent()); - auto maybe_result_value = Nan::Call(callback, callback->CreationContext()->Global(), 2, argv); + #if (V8_MAJOR_VERSION > 9 || (V8_MAJOR_VERSION == 9 && V8_MINOR_VERION > 4)) + auto maybe_result_value = Nan::Call(callback, callback->GetCreationContext().ToLocalChecked()->Global(), 2, argv); + #else + auto maybe_result_value = Nan::Call(callback, callback->CreationContext()->Global(), 2, argv); + #endif if (try_catch.HasCaught()) return nullptr; Local result_value; @@ -364,7 +368,11 @@ void Parser::ParseTextBuffer(const Nan::FunctionCallbackInfo &info) { delete input; Local argv[] = {Tree::NewInstance(result)}; auto callback = info[0].As(); - Nan::Call(callback, callback->CreationContext()->Global(), 1, argv); + #if (V8_MAJOR_VERSION > 9 || (V8_MAJOR_VERSION == 9 && V8_MINOR_VERION > 4)) + Nan::Call(callback, callback->GetCreationContext().ToLocalChecked()->Global(), 1, argv); + #else + Nan::Call(callback, callback->CreationContext()->Global(), 1, argv); + #endif return; } } diff --git a/src/tree.cc b/src/tree.cc index 4447d4cc..4657834d 100644 --- a/src/tree.cc +++ b/src/tree.cc @@ -196,7 +196,7 @@ void Tree::GetEditedRange(const Nan::FunctionCallbackInfo &info) { void Tree::PrintDotGraph(const Nan::FunctionCallbackInfo &info) { Tree *tree = ObjectWrap::Unwrap(info.This()); - ts_tree_print_dot_graph(tree->tree_, stderr); + ts_tree_print_dot_graph(tree->tree_, 2); info.GetReturnValue().Set(info.This()); } diff --git a/vendor/tree-sitter b/vendor/tree-sitter index 3d554ecf..c51896d3 160000 --- a/vendor/tree-sitter +++ b/vendor/tree-sitter @@ -1 +1 @@ -Subproject commit 3d554ecf6b68ad2c267c1e90b6ef9aa68ae88bcd +Subproject commit c51896d32dcc11a38e41f36e3deb1a6a9c4f4b14