Skip to content

Commit

Permalink
Merge pull request #20 from uros-5/nodejs
Browse files Browse the repository at this point in the history
updated Nodejs bindings
  • Loading branch information
uros-5 authored Jun 11, 2024
2 parents adfefde + 522fc2d commit 7ac930d
Show file tree
Hide file tree
Showing 38 changed files with 1,049 additions and 73 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/CI-nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ permissions:
'on':
push:
branches:
- npm
- nodejs
tags-ignore:
- '**'
paths-ignore:
Expand Down Expand Up @@ -190,6 +190,7 @@ jobs:
# name: bindings-freebsd
# path: jinja-lsp-nodejs/${{ env.APP_NAME }}.*.node
# if-no-files-found: error

test-macOS-windows-binding:
defaults:
run:
Expand Down
23 changes: 14 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions act_script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

# act -j show -P macos-latest=sickcodes/docker-osx -P windows-latest=dockurr/windows
act --env-file .env -W .github/workflows/CI-nodejs.yaml -P macos-latest=sickcodes/docker-osx -P windows-latest=dockurr/windows
13 changes: 11 additions & 2 deletions jinja-lsp-nodejs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
[package]
edition = "2021"
name = "uros_jinja-lsp-nodejs"
version = "0.0.0"
name = "jinja-lsp-nodejs"
version = "0.1.80"
license = "MIT"
authors = ["uros-5"]
description = "Bindings for jinja-lsp"

[lib]
crate-type = ["cdylib"]
Expand All @@ -10,10 +13,16 @@ crate-type = ["cdylib"]
# Default enable napi4 feature, see https://nodejs.org/api/n-api.html#node-api-version-matrix
napi = { version = "2.12.2", default-features = false, features = ["napi4"] }
napi-derive = "2.12.2"
jinja-lsp-queries = { path = "../jinja-lsp-queries", version = "0.1.80"}
jinja-lsp = { path = "../jinja-lsp", version = "0.1.80"}
tree-sitter = "0.21.0"
tower-lsp = { version = "0.20.0", features = ["proposed"] }
ropey = "1.5.0"

[build-dependencies]
napi-build = "2.0.1"

[profile.release]
lto = true
strip = "symbols"
opt-level = 3
6 changes: 3 additions & 3 deletions jinja-lsp-nodejs/__test__/index.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import test from 'ava'

import { sum } from '../index.js'
import { NodejsLspFiles } from '../index.js'

test('sum from native', (t) => {
t.is(sum(1, 2), 3)
test('main class', (t) => {
t.is(new NodejsLspFiles().getVariables("id", 11), null);
})
82 changes: 81 additions & 1 deletion jinja-lsp-nodejs/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,84 @@

/* auto-generated by NAPI-RS */

export function sum(a: number, b: number): number
export function basic(content: string): number | null
export interface JsPosition {
line: number
character: number
}
export const enum JsIdentifierType {
ForLoopKey = 0,
ForLoopValue = 1,
ForLoopCount = 2,
SetVariable = 3,
WithVariable = 4,
MacroName = 5,
MacroParameter = 6,
TemplateBlock = 7,
BackendVariable = 8,
UndefinedVariable = 9,
JinjaTemplate = 10,
Link = 11
}
export interface JsIdentifier {
start: JsPosition
end: JsPosition
name: string
identifierType: JsIdentifierType
error?: string
}
export interface JsHover {
kind: string
value: string
range?: JsRange
label?: string
documentaion?: string
}
export interface JsRange {
start: JsPosition
end: JsPosition
}
export interface JsLocation {
uri: string
range: JsRange
isBackend: boolean
name: string
}
export interface JsCompletionItem {
completionType: JsCompletionType
label: string
kind: Kind2
description: string
newText?: string
insert?: JsRange
replace?: JsRange
}
export const enum Kind2 {
VARIABLE = 0,
FIELD = 1,
FUNCTION = 2,
MODULE = 3,
CONSTANT = 4,
FILE = 5,
TEXT = 6
}
export const enum JsCompletionType {
Filter = 0,
Identifier = 1,
Snippets = 2
}
export interface Action {
name: string
description: string
}
export class NodejsLspFiles {
constructor()
/** Actions can come from unsaved context. */
addGlobalContext(uri: string, actions?: Array<Action> | undefined | null): void
deleteAll(filename: string): void
addOne(id: number, filename: string, content: string, line: number): Array<JsIdentifier>
getVariables(id: string, line: number): Array<JsIdentifier> | null
hover(id: number, filename: string, line: number, position: JsPosition): JsHover | null
complete(id: number, filename: string, line: number, position: JsPosition): Array<JsCompletionItem> | null
gotoDefinition(id: number, filename: string, line: number, position: JsPosition): Array<JsLocation> | null
}
8 changes: 6 additions & 2 deletions jinja-lsp-nodejs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,10 @@ if (!nativeBinding) {
throw new Error(`Failed to load native binding`)
}

const { sum } = nativeBinding
const { basic, NodejsLspFiles, JsIdentifierType, Kind2, JsCompletionType } = nativeBinding

module.exports.sum = sum
module.exports.basic = basic
module.exports.NodejsLspFiles = NodejsLspFiles
module.exports.JsIdentifierType = JsIdentifierType
module.exports.Kind2 = Kind2
module.exports.JsCompletionType = JsCompletionType
2 changes: 1 addition & 1 deletion jinja-lsp-nodejs/npm/android-arm-eabi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jinja-lsp/functions-android-arm-eabi",
"version": "0.0.2",
"version": "0.0.3",
"os": [
"android"
],
Expand Down
2 changes: 1 addition & 1 deletion jinja-lsp-nodejs/npm/android-arm64/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jinja-lsp/functions-android-arm64",
"version": "0.0.2",
"version": "0.0.3",
"os": [
"android"
],
Expand Down
2 changes: 1 addition & 1 deletion jinja-lsp-nodejs/npm/darwin-arm64/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jinja-lsp/functions-darwin-arm64",
"version": "0.0.2",
"version": "0.0.3",
"os": [
"darwin"
],
Expand Down
2 changes: 1 addition & 1 deletion jinja-lsp-nodejs/npm/darwin-universal/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jinja-lsp/functions-darwin-universal",
"version": "0.0.2",
"version": "0.0.3",
"os": [
"darwin"
],
Expand Down
2 changes: 1 addition & 1 deletion jinja-lsp-nodejs/npm/freebsd-x64/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jinja-lsp/functions-freebsd-x64",
"version": "0.0.2",
"version": "0.0.3",
"os": [
"freebsd"
],
Expand Down
2 changes: 1 addition & 1 deletion jinja-lsp-nodejs/npm/gnu-linux/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jinja-lsp/functions-gnu-linux",
"version": "0.0.2",
"version": "0.0.3",
"os": [
"gnu",
"linux"
Expand Down
2 changes: 1 addition & 1 deletion jinja-lsp-nodejs/npm/linux-arm-gnueabihf/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jinja-lsp/functions-linux-arm-gnueabihf",
"version": "0.0.2",
"version": "0.0.3",
"os": [
"linux"
],
Expand Down
2 changes: 1 addition & 1 deletion jinja-lsp-nodejs/npm/linux-arm-musleabihf/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jinja-lsp/functions-linux-arm-musleabihf",
"version": "0.0.2",
"version": "0.0.3",
"os": [
"linux"
],
Expand Down
2 changes: 1 addition & 1 deletion jinja-lsp-nodejs/npm/linux-arm64-gnu/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jinja-lsp/functions-linux-arm64-gnu",
"version": "0.0.2",
"version": "0.0.3",
"os": [
"linux"
],
Expand Down
2 changes: 1 addition & 1 deletion jinja-lsp-nodejs/npm/linux-arm64-musl/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jinja-lsp/functions-linux-arm64-musl",
"version": "0.0.2",
"version": "0.0.3",
"os": [
"linux"
],
Expand Down
2 changes: 1 addition & 1 deletion jinja-lsp-nodejs/npm/linux-riscv64-gnu/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jinja-lsp/functions-linux-riscv64-gnu",
"version": "0.0.2",
"version": "0.0.3",
"os": [
"linux"
],
Expand Down
2 changes: 1 addition & 1 deletion jinja-lsp-nodejs/npm/linux-x64-gnu/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jinja-lsp/functions-linux-x64-gnu",
"version": "0.0.2",
"version": "0.0.3",
"os": [
"linux"
],
Expand Down
2 changes: 1 addition & 1 deletion jinja-lsp-nodejs/npm/linux-x64-musl/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jinja-lsp/functions-linux-x64-musl",
"version": "0.0.2",
"version": "0.0.3",
"os": [
"linux"
],
Expand Down
2 changes: 1 addition & 1 deletion jinja-lsp-nodejs/npm/win32-arm64-msvc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jinja-lsp/functions-win32-arm64-msvc",
"version": "0.0.2",
"version": "0.0.3",
"os": [
"win32"
],
Expand Down
2 changes: 1 addition & 1 deletion jinja-lsp-nodejs/npm/win32-ia32-msvc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jinja-lsp/functions-win32-ia32-msvc",
"version": "0.0.2",
"version": "0.0.3",
"os": [
"win32"
],
Expand Down
4 changes: 2 additions & 2 deletions jinja-lsp-nodejs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion jinja-lsp-nodejs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jinja-lsp/functions",
"version": "0.0.2",
"version": "0.0.3",
"main": "index.js",
"types": "index.d.ts",
"napi": {
Expand Down
Loading

0 comments on commit 7ac930d

Please sign in to comment.