diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 906ec387..79c442ee 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,6 +14,10 @@ jobs: - ubuntu-latest - macos-latest - windows-latest + node_version: + - 14 + - 16 + - 18 name: Node ${{ matrix.node_version }} on ${{ matrix.os }} steps: @@ -30,7 +34,7 @@ jobs: - name: Setup node uses: actions/setup-node@v2-beta with: - node-version: 14 + node-version: ${{ matrix.node_version }} - name: Install dependencies run: npm install diff --git a/src/bindings/text-buffer-wrapper.cc b/src/bindings/text-buffer-wrapper.cc index 52e7bded..3c633269 100644 --- a/src/bindings/text-buffer-wrapper.cc +++ b/src/bindings/text-buffer-wrapper.cc @@ -387,7 +387,11 @@ static Local encode_ranges(const vector &ranges) { auto length = ranges.size() * 4; auto buffer = v8::ArrayBuffer::New(v8::Isolate::GetCurrent(), length * sizeof(uint32_t)); auto result = v8::Uint32Array::New(buffer, 0, length); - auto data = buffer->GetContents().Data(); + #if (V8_MAJOR_VERSION < 8) + auto data = buffer->GetContents().Data(); + #else + auto data = buffer->GetBackingStore()->Data(); + #endif memcpy(data, ranges.data(), length * sizeof(uint32_t)); return result; } @@ -611,7 +615,11 @@ void TextBufferWrapper::find_words_with_subsequence_in_range(const Nan::Function } auto positions_buffer = v8::ArrayBuffer::New(v8::Isolate::GetCurrent(), positions_buffer_size); - uint32_t *positions_data = reinterpret_cast(positions_buffer->GetContents().Data()); + #if (V8_MAJOR_VERSION < 8) + uint32_t *positions_data = reinterpret_cast(positions_buffer->GetContents().Data()); + #else + uint32_t *positions_data = reinterpret_cast(positions_buffer->GetBackingStore()->Data()); + #endif uint32_t positions_array_index = 0; for (size_t i = 0; i < result.size() && i < max_count; i++) { @@ -935,7 +943,11 @@ void TextBufferWrapper::load(const Nan::FunctionCallbackInfo &info) { if (!force && text_buffer.is_modified()) { Local argv[] = {Nan::Null(), Nan::Null()}; auto callback = info[0].As(); - Nan::Call(callback, callback->CreationContext()->Global(), 2, argv); + #if (V8_MAJOR_VERSION > 9 || (V8_MAJOR_VERSION == 9 && V8_MINOR_VERION > 4)) + Nan::Call(callback, callback->GetCreationContext().ToLocalChecked()->Global(), 2, argv); + #else + Nan::Call(callback, callback->CreationContext()->Global(), 2, argv); + #endif return; } @@ -1039,7 +1051,12 @@ void TextBufferWrapper::base_text_matches_file(const Nan::FunctionCallbackInfo argv[] = {Nan::Null(), Nan::New(result)}; auto callback = info[0].As(); - Nan::Call(callback, callback->CreationContext()->Global(), 2, argv); + + #if (V8_MAJOR_VERSION > 9 || (V8_MAJOR_VERSION == 9 && V8_MINOR_VERION > 4)) + Nan::Call(callback, callback->GetCreationContext().ToLocalChecked()->Global(), 2, argv); + #else + Nan::Call(callback, callback->CreationContext()->Global(), 2, argv); + #endif } }