diff --git a/Makefile b/Makefile index 4af89e23..3ed191e2 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ all: build ./node_modules: - npm install --build-from-source + npm install --ignore-scripts build: ./node_modules ./node_modules/.bin/node-pre-gyp build -j max --loglevel=silent diff --git a/package-lock.json b/package-lock.json index 5e05e4d1..04d0e803 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "license": "MIT", "dependencies": { "@mapbox/node-pre-gyp": "^1.0.0", - "node-addon-api": "*", + "node-addon-api": "^7.0.0", "node-gyp": "^9.3.0" }, "devDependencies": { @@ -2110,9 +2110,9 @@ } }, "node_modules/node-addon-api": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-4.2.0.tgz", - "integrity": "sha512-eazsqzwG2lskuzBqCGPi7Ac2UgOoMz8JVOXVhTvvPDYhthvNpefx8jWD8Np7Gv+2Sz0FlPWZk0nJV0z598Wn8Q==" + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-7.0.0.tgz", + "integrity": "sha512-vgbBJTS4m5/KkE16t5Ly0WW9hz46swAstv0hYYwMtbG7AznRhNyfLRe8HZAiWIpcHzoO7HxhLuBQj9rJ/Ho0ZA==" }, "node_modules/node-fetch": { "version": "2.6.6", @@ -4768,9 +4768,9 @@ "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==" }, "node-addon-api": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-4.2.0.tgz", - "integrity": "sha512-eazsqzwG2lskuzBqCGPi7Ac2UgOoMz8JVOXVhTvvPDYhthvNpefx8jWD8Np7Gv+2Sz0FlPWZk0nJV0z598Wn8Q==" + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-7.0.0.tgz", + "integrity": "sha512-vgbBJTS4m5/KkE16t5Ly0WW9hz46swAstv0hYYwMtbG7AznRhNyfLRe8HZAiWIpcHzoO7HxhLuBQj9rJ/Ho0ZA==" }, "node-fetch": { "version": "2.6.6", diff --git a/package.json b/package.json index ba5c1e92..bbe1ba42 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "gypfile": true, "dependencies": { "@mapbox/node-pre-gyp": "^1.0.0", - "node-addon-api": "*", + "node-addon-api": "^7.0.0", "node-gyp": "^9.3.0" }, "binary": { diff --git a/src/statement.cpp b/src/statement.cpp index 42342c04..7b6baade 100644 --- a/src/statement.cpp +++ b/src/statement.cpp @@ -377,10 +377,10 @@ struct RunPreparedTask : public Task { // query results, the string data is owned by the QueryResult auto result_ref_ptr = new std::shared_ptr(result_ptr); - auto array_buffer = - Napi::ArrayBuffer::New(env, (void *)blob.GetData(), blob.GetSize(), deleter, result_ref_ptr); + auto array_buffer = Napi::Buffer::NewOrCopy(env, (char *)blob.GetData(), blob.GetSize(), + deleter, result_ref_ptr); - auto typed_array = Napi::Uint8Array::New(env, blob.GetSize(), array_buffer, 0); + auto typed_array = Napi::TypedArrayOf(env, array_buffer); // TODO we should handle this in duckdb probably if (is_header) { @@ -708,7 +708,7 @@ struct GetNextArrowIpcTask : public Task { delete static_cast *>(hint); }; auto array_buffer = - Napi::ArrayBuffer::New(env, (void *)blob.GetData(), blob.GetSize(), deleter, data_chunk_ptr); + Napi::Buffer::NewOrCopy(env, (char *)blob.GetData(), blob.GetSize(), deleter, data_chunk_ptr); deferred.Resolve(array_buffer); }