Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit

Permalink
Setup npm-publish.
Browse files Browse the repository at this point in the history
  • Loading branch information
Animeshz committed Mar 28, 2021
1 parent a7e637e commit ab15b8d
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ __Notice: Project is on hold till about one month or somewhat longer (I'm busy).

## What is KeyboardMouse.kt

KeyboardMouse.kt is a lightweight, coroutine-based multiplatform kotlin library for idiomatically interacting with Keyboard and Mouse (receiving and sending global events) from Kotlin and Java.
KeyboardMouse.kt is a lightweight, coroutine-based multiplatform kotlin library for idiomatically interacting with Keyboard and Mouse (receiving and sending global events) from Kotlin, Java and NodeJS.

We aim to provide high-level as well as high-performant low-level access to such APIs. See the documentation below to
know more!
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {

allprojects {
this.group = "com.github.animeshz"
this.version = "0.2.5"
this.version = "0.3.0"

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class PublishingPlugin : Plugin<Project> {
target.apply(plugin = "maven-publish")

target.afterEvaluate {
val repository = ext.repository ?: error("publishingConfig.repository must not be null")
val repository = ext.repository ?: return@afterEvaluate println("publishingConfig.repository is missing, skipping...")

target.extensions.configure<PublishingExtension>("publishing") {
repositories {
Expand Down
31 changes: 31 additions & 0 deletions keyboard-kt/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

import com.github.animeshz.keyboard_mouse.native_compile.Target
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile

plugins {
kotlin("multiplatform")
id("keyboard-mouse-native-compile")
id("keyboard-mouse-publishing")
id("lt.petuska.npm.publish") version "1.1.1"
id("org.jlleitschuh.gradle.ktlint") version "9.4.1"
}

Expand Down Expand Up @@ -89,6 +91,31 @@ publishingConfig {
password = System.getenv("BINTRAY_KEY")
}

npmPublishing {
repositories {
repository("npmjs") {
registry = uri("https://registry.npmjs.org")
authToken = System.getenv("NPM_TOKEN")
}
}

publications {
val js by getting {
files {
from(project.file("build/napi"))
}

bundleKotlinDependencies = false
shrinkwrapBundledDependencies = false
packageJsonTemplateFile = project.file("src/jsMain/package.template.json")
packageJson {
version = project.version as String
readme = rootProject.file("README.md")
}
}
}
}

nativeCompilation {
jni {
headers {
Expand Down Expand Up @@ -133,6 +160,10 @@ tasks.withType<AbstractTestTask> {
tasks.withType<KotlinJvmCompile> {
kotlinOptions.jvmTarget = "1.8"
}
tasks.withType<KotlinJsCompile> {
kotlinOptions.sourceMap = false
}

tasks.getByName<Test>("jvmTest") {
useJUnitPlatform()
}
Expand Down
4 changes: 2 additions & 2 deletions keyboard-kt/src/jsMain/cpp/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ cmake_minimum_required(VERSION 3.10)
project(KeyboardKt)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s -fdata-sections -ffunction-sections -Wl,--gc-sections")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s -fdata-sections -ffunction-sections -Wl,--gc-sections")

option(ARCH "architecture")

Expand Down
4 changes: 2 additions & 2 deletions keyboard-kt/src/jsMain/cpp/windows/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ cmake_minimum_required(VERSION 3.10)
project(KeyboardKt)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s -static-libgcc -fdata-sections -ffunction-sections -Wl,--gc-sections")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s -static-libgcc -static-libstdc++ -fdata-sections -ffunction-sections -Wl,--gc-sections")

option(ARCH "architecture")

Expand Down
4 changes: 2 additions & 2 deletions keyboard-kt/src/jsMain/cpp/windows/JsKeyboardHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ void EmitEventToJs(Napi::Env env, Napi::Function callback, std::nullptr_t* conte
}

if (data != NULL) {
delete data;
free(data);
}
}

void EmitEventToTSCallback(int scanCode, bool isPressed) {
EventData* data = new EventData;
EventData* data = (EventData *) malloc(sizeof(EventData));
data->scanCode = scanCode;
data->isPressed = isPressed;

Expand Down
33 changes: 33 additions & 0 deletions keyboard-kt/src/jsMain/package.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "keyboard-kt",
"description": "A lightweight multiplatform library for interacting with global keyboard and mouse events and states from Kotlin, Java and NodeJS.",
"keywords": [
"kotlin",
"kotlin",
"java",
"keyboard",
"mouse",
"java-native-interface",
"hotkey",
"multiplatform",
"keyboard-listeners",
"global-events",
"keyboard-events",
"mouse-events",
"keyboard-hooks",
"keyboard-state",
"multiplatform-kotlin-library"
],
"homepage": "https://animeshz.github.io/keyboard-mouse-kt",
"licence": "MIT",
"author": {
"name": "Animesh Sahu",
"email": "animeshsahu19@yahoo.com"
},
"repository": {
"url": "git+https://animeshz.github.io/keyboard-mouse-kt.git"
},
"bugs": {
"url": "https://animeshz.github.io/keyboard-mouse-kt/issues"
}
}
4 changes: 2 additions & 2 deletions keyboard-kt/src/jvmMain/cpp/windows/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ cmake_minimum_required(VERSION 3.10)
project(KeyboardKt)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s -fdata-sections -ffunction-sections -Wl,--gc-sections")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s -fdata-sections -ffunction-sections -Wl,--gc-sections")

option(ARCH "architecture")

Expand Down
2 changes: 1 addition & 1 deletion keyboard-kt/src/nativeCommon/linux/X11KeyboardHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class X11KeyboardHandler : BaseKeyboardHandler {

Window root = XDefaultRootWindow(display);
int maskLen = XIMaskLen(XI_LASTEVENT);
unsigned char mask[maskLen];
unsigned char mask[maskLen] = { 0 };

XIEventMask xiMask;
xiMask.deviceid = XIAllMasterDevices;
Expand Down

0 comments on commit ab15b8d

Please sign in to comment.