Skip to content

Commit

Permalink
Use napi features
Browse files Browse the repository at this point in the history
  • Loading branch information
noClaps committed Jan 3, 2025
1 parent 3c6571a commit adbc66f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
napi = "3.0.0-alpha.24"
napi-derive = "3.0.0-alpha.22"
napi = { version = "3.0.0-alpha.24", default-features = false, features = [
"napi8",
] }
napi-derive = { version = "3.0.0-alpha.22", default-features = false, features = [
"type-def",
] }
tree-sitter-agda = "1.3.3"
tree-sitter-bash = "0.23.3"
tree-sitter-c = "0.23.4"
Expand Down
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
// @ts-nocheck
/* auto-generated by NAPI-RS */

const { createRequire } = require('node:module')
require = createRequire(__filename)
import { createRequire } from 'node:module'
const require = createRequire(import.meta.url)
const __dirname = new URL('.', import.meta.url).pathname

const { readFileSync } = require('node:fs')
let nativeBinding = null
Expand Down Expand Up @@ -364,4 +365,5 @@ if (!nativeBinding) {
throw new Error(`Failed to load native binding`)
}

module.exports.highlight = nativeBinding.highlight
const { highlight } = nativeBinding
export { highlight }
4 changes: 1 addition & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use napi_derive::napi;
use tree_sitter_highlight::{Highlight, HighlightConfiguration, Highlighter, HtmlRenderer};

#[macro_use]
extern crate napi_derive;

fn get_highlight_query(language: String) -> String {
let cpp = format!(
"{}\n{}",
Expand Down

0 comments on commit adbc66f

Please sign in to comment.