Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
8d4e419
init optimization
wenxi-zeng Feb 2, 2023
a236f70
add json element support
wenxi-zeng Feb 3, 2023
d5e3e05
add JSParamters and JSResult
wenxi-zeng Feb 3, 2023
3222d5f
segregate conversions
wenxi-zeng Feb 6, 2023
56bf5fe
reorg files
wenxi-zeng Feb 6, 2023
1d5b13a
remove js executor
wenxi-zeng Feb 7, 2023
a46f226
safe v8 + unit tests fix
wenxi-zeng Feb 7, 2023
ab97a6f
update export method to be more readable
wenxi-zeng Feb 8, 2023
9a3aa87
update settings.gradle
wenxi-zeng Feb 16, 2024
8029d74
Squashed 'quickjs/quickjs/' content from commit 3bb2ca3
wenxi-zeng Feb 16, 2024
ea9a2c0
Merge commit '8029d740e34a4f76040b64a4d9cd26f0a649b904' as 'quickjs/q…
wenxi-zeng Feb 16, 2024
307a203
init setup of jni
wenxi-zeng Feb 16, 2024
5688b8e
Merge branch 'wenxi/optimization' of https://github.com/segmentio/sub…
wenxi-zeng Feb 20, 2024
185f3a5
draft conversion and memory management
wenxi-zeng Feb 27, 2024
2383a27
draft array, object, and function
wenxi-zeng Feb 27, 2024
505d688
finalize Conversions.kt and JSContext.kt
wenxi-zeng Feb 28, 2024
afd4a18
draft engine
wenxi-zeng Feb 29, 2024
b5f719c
draft jni
wenxi-zeng Mar 1, 2024
7f54037
bug fix
wenxi-zeng Mar 14, 2024
3e76d13
use delegation on jsobject and jsarray
wenxi-zeng Mar 16, 2024
bb08d33
add support for json element
wenxi-zeng Mar 16, 2024
c10e0c1
json array bug fix
wenxi-zeng Mar 18, 2024
a21cc7a
add test for json array
wenxi-zeng Mar 18, 2024
c2be83c
bug fix
wenxi-zeng Mar 19, 2024
93102e4
make JSConvertible also Releasable
wenxi-zeng Mar 19, 2024
c719573
memory manager optimization
wenxi-zeng Mar 19, 2024
f8d559a
add delegation for JSNull and JSUndefined
wenxi-zeng Mar 19, 2024
cabd7cc
implement JSFunction
wenxi-zeng Mar 19, 2024
cd44535
remove unnecessary code
wenxi-zeng Mar 20, 2024
777157c
export function
wenxi-zeng Mar 21, 2024
3219cc2
implement extend
wenxi-zeng Mar 21, 2024
5392259
add console
wenxi-zeng Mar 22, 2024
8814c76
fix crash when atom hash returns 0
wenxi-zeng Mar 22, 2024
37da1d8
clean up
wenxi-zeng Mar 25, 2024
ec89ba6
draft exporting class
wenxi-zeng Mar 27, 2024
2540e85
bug fix
wenxi-zeng Mar 28, 2024
f9facbf
bug fix
wenxi-zeng Mar 28, 2024
276cfe7
bug fix for JSClass function with parameters
wenxi-zeng Apr 1, 2024
7214ff3
implement exporting property, replace java reflection with kotlin ref…
wenxi-zeng Apr 1, 2024
b2c3596
bug fix
wenxi-zeng Apr 2, 2024
9417b87
bug fix for prototype instance method
wenxi-zeng Apr 3, 2024
af9b9d1
clean up JSFunctionBody
wenxi-zeng Apr 3, 2024
18a9a2c
memory leak fix
wenxi-zeng Apr 4, 2024
5f47b2d
revert changes made to quickjs.c
wenxi-zeng Apr 4, 2024
50bfdb8
add launch
wenxi-zeng Apr 4, 2024
7ce5a02
clean up
wenxi-zeng Apr 4, 2024
2966206
make exception handler easier to use
wenxi-zeng Apr 4, 2024
1f7e724
add completion closure to loadBundle
wenxi-zeng Apr 4, 2024
cdd0563
fix jsCallback always return undefine instead of null for actual null…
wenxi-zeng Apr 4, 2024
bb0d0bb
update env
wenxi-zeng Apr 5, 2024
557918c
clean up
wenxi-zeng Apr 5, 2024
4ef1ab3
Downgrade Gradle to get ./gradlew publishToSonatype to work
didiergarcia Apr 14, 2024
3034313
Bump version of io.github.gradle-nexus.publish-plugin to 2.0.0
didiergarcia Apr 14, 2024
d13f54d
Adding github workflows for build, release, and snapshot.
didiergarcia Apr 14, 2024
22893fe
Uncommit the MainActivity.
didiergarcia Apr 14, 2024
e724e7d
Remove unused old imports.
didiergarcia Apr 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:

cancel_previous:
permissions: write-all
runs-on: ubuntu-latest
steps:
- uses: styfle/[email protected]
with:
workflow_id: ${{ github.event.workflow.id }}

build:

needs: cancel_previous
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: cache gradle dependencies
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Run Tests
run: ./gradlew check
55 changes: 55 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Release

on:
push:
tags:
- '*.*.*'

jobs:
release:
permissions: write-all
runs-on: ubuntu-latest
environment: deployment
steps:
- uses: actions/checkout@v2
- name: Get tag
id: vars
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
- name: Verify tag
run: |
VERSION=$(grep VERSION_NAME gradle.properties | awk -F= '{ print $2 }' | sed "s/-SNAPSHOT//")
if [ "${{ steps.vars.outputs.tag }}" != "$VERSION" ]; then {
echo "Tag ${{ steps.vars.outputs.tag }} does not match the package version ($VERSION)"
exit 1
} fi

- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: cache gradle dependencies
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-core-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-core-
- name: Publush release to sonatype
run: ./gradlew publishToSonatype -Prelease closeAndReleaseSonatypeStagingRepository
env:
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.NEXUS_PASSWORD }}
SIGNING_PRIVATE_KEY_BASE64: ${{ secrets.SIGNING_PRIVATE_KEY_BASE64 }}

- name: create release
run: |
curl \
-X POST \
-H "Authorization: token $GITHUB_TOKEN" \
https://api.github.com/repos/${{github.repository}}/releases \
-d '{"tag_name": "${{ env.RELEASE_VERSION }}", "name": "${{ env.RELEASE_VERSION }}", "body": "Release of version ${{ env.RELEASE_VERSION }}", "draft": false, "prerelease": false, "generate_release_notes": true}'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}
31 changes: 31 additions & 0 deletions .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Snapshot

on:
push:
branches: [ main ]

jobs:
snapshot:
runs-on: ubuntu-latest
environment: deployment
steps:
- uses: actions/checkout@v2
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: cache gradle dependencies
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-core-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-core-
- name: Publush snapshot to sonatype
run: ./gradlew publishToSonatype
env:
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.NEXUS_PASSWORD }}
SIGNING_PRIVATE_KEY_BASE64: ${{ secrets.SIGNING_PRIVATE_KEY_BASE64 }}
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ plugins {
}

android {
compileSdk 31
compileSdk 34

defaultConfig {
applicationId "com.segment.analytics.substrata.kotlin.sample"
minSdk 21
targetSdk 31
targetSdk 34
versionCode 1
versionName "1.0"

Expand All @@ -29,12 +29,12 @@ android {
kotlinOptions {
jvmTarget = '1.8'
}
namespace 'com.segment.analytics.substrata.kotlin.sample'
}

dependencies {
// api 'com.segment.analytics.kotlin:substrata-kotlin:0.0.2'
api project(':substrata-kotlin')
implementation 'com.eclipsesource.j2v8:j2v8:6.2.0@aar'
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.segment.analytics.substrata.kotlin.sample">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<!-- Required for internet. -->
<uses-permission android:name="android.permission.INTERNET" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,101 +3,88 @@ package com.segment.analytics.substrata.kotlin.sample
import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import com.segment.analytics.substrata.kotlin.JSValue
import com.segment.analytics.substrata.kotlin.j2v8.J2V8Engine

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
Log.d("PRAY", "Starting")
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val engine = J2V8Engine()
Log.d("PRAY", "Created engine")
engine["foo"] = JSValue.JSString("")
val script1 = applicationContext.assets.open("sample.js")
val script2 = applicationContext.assets.open("sample2.js").bufferedReader().readText()
engine.bridge["foo"] = JSValue.JSString("bar")
engine.loadBundle(script1) { }
val res = engine.execute(
"""
function barFoo() {
return "Foo";
}
const foo = {x: "Test"};
const bar = [10, 2, "foo", true];
console.log("123");
console.log(1);
console.log(2.9);
console.log(true);
console.log(foo);
console.log(bar);
console.log(DataBridge["foo"]);
foo.y = 2.8;
foo

""".trimIndent()
)

Log.d("PRAY", res.toString())
val res2 = engine.call("fooBar")
Log.d("PRAY", res2.toString())
val res3 = engine.call("barFoo")
Log.d("PRAY", res3.toString())
engine.execute(script2)
// engine.exec(
// val engine = J2V8Engine()
// Log.d("PRAY", "Created engine")
// engine["foo"] = JSValue.JSString("")
// val script1 = applicationContext.assets.open("sample.js")
// val script2 = applicationContext.assets.open("sample2.js").bufferedReader().readText()
// engine.bridge["foo"] = JSValue.JSString("bar")
// engine.loadBundle(script1) { }
// val res = engine.execute(
// """
// pray
// """.trimIndent() // ReferenceError
// )
// engine.exec(
// """
// pray()
// """.trimIndent() // ReferenceError
// )
// engine.exec(
// """
// throw "pray-error"
// """.trimIndent() // String "pray-error"
// )
// engine.exec(
// """
// throw 'Parameter is not a number!';
// """.trimIndent() // String "pray-error"
// )
// engine.exec(
// """
// function
// """.trimIndent() // SyntaxError
// )
// engine.exec(
// """
// var x = ""
// var x = 2
// function barFoo() {
// return "Foo";
// }
// const foo = {x: "Test"};
// const bar = [10, 2, "foo", true];
// console.log("123");
// console.log(1);
// console.log(2.9);
// console.log(true);
// console.log(foo);
// console.log(bar);
// console.log(DataBridge["foo"]);
// foo.y = 2.8;
// foo
//
// """.trimIndent()
// )
// engine.exec(
// """
// const y = ""
// const y = 2
// """.trimIndent() // SyntaxError
// )
// try {
// engine.call("playa")
// } catch (ex: Exception) {
// ex.printStackTrace()
// Log.d("PRAY", ex.toString())
// }

}

fun J2V8Engine.exec(script: String) {
Log.d("PRAY-errorHandler", "Execing $script")
try {
execute(script)
} catch (ex: Exception) {
ex.printStackTrace()
}
Log.d("PRAY-errorHandler", "DONE Execing $script")
//
// Log.d("PRAY", res.toString())
// val res2 = engine.call("fooBar")
// Log.d("PRAY", res2.toString())
// val res3 = engine.call("barFoo")
// Log.d("PRAY", res3.toString())
// engine.execute(script2)
//// engine.exec(
//// """
//// pray
//// """.trimIndent() // ReferenceError
//// )
//// engine.exec(
//// """
//// pray()
//// """.trimIndent() // ReferenceError
//// )
//// engine.exec(
//// """
//// throw "pray-error"
//// """.trimIndent() // String "pray-error"
//// )
//// engine.exec(
//// """
//// throw 'Parameter is not a number!';
//// """.trimIndent() // String "pray-error"
//// )
//// engine.exec(
//// """
//// function
//// """.trimIndent() // SyntaxError
//// )
//// engine.exec(
//// """
//// var x = ""
//// var x = 2
//// """.trimIndent()
//// )
//// engine.exec(
//// """
//// const y = ""
//// const y = 2
//// """.trimIndent() // SyntaxError
//// )
//// try {
//// engine.call("playa")
//// } catch (ex: Exception) {
//// ex.printStackTrace()
//// Log.d("PRAY", ex.toString())
//// }
}
}
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ buildscript {
}

plugins {
id 'com.android.application' version '7.1.2' apply false
id 'com.android.library' version '7.1.2' apply false
id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
id 'io.github.gradle-nexus.publish-plugin' version "1.1.0"
id 'com.android.application' version '7.4.2' apply false
id 'com.android.library' version '7.4.2' apply false
id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
id 'io.github.gradle-nexus.publish-plugin' version "2.0.0"
}

task clean(type: Delete) {
Expand Down
8 changes: 5 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ android.nonTransitiveRClass=true

GROUP=com.segment.analytics.kotlin

VERSION_CODE=006
VERSION_NAME=0.0.6
VERSION_CODE=008
VERSION_NAME=0.0.8

POM_NAME=Substrata
POM_DESCRIPTION=The hassle-free way to add analytics to your Kotlin app.
Expand All @@ -43,4 +43,6 @@ POM_LICENCE_URL=http://opensource.org/licenses/MIT
POM_LICENCE_DIST=repo

POM_DEVELOPER_ID=segmentio
POM_DEVELOPER_NAME=Segment, Inc.
POM_DEVELOPER_NAME=Segment, Inc.
android.defaults.buildfeatures.buildconfig=true
android.nonFinalResIds=false
6 changes: 3 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Apr 06 14:54:34 PDT 2022
#Thu Apr 11 17:16:54 EDT 2024
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading