Giter Club home page Giter Club logo

droidscript-sdk's Introduction

Droidscript SDK

npm version CI

droidscript-sdk is a lightweight and modular alternative to the traditional app.js file used in DroidScript hybrid applications. This project allows you to import only the components you need, making your code more efficient and easier to maintain.

This is an unofficial alternative and does not have all the methods that the original API provides (for now)

Installation

You can install droidscript-sdk using npm:

npm install droidscript-sdk

Setup

You can import all the modules from droidscript-sdk using ES6 import syntax (recommend use a bundler like webpack):

import * as droid from 'droidscript-sdk'

droid.start();

droid.sendSMS('Sended from my Droidscript App!', '+1 23456789');
droid.showPopup('SMS sended');

if (droid.isAPK()) {
  ds.showPopup('You are in a compiled apk');
}

droidscript-sdk also includes a pre-built version of the library that can be imported directly into your HTML:

<script src="./droid.min.js"></script>

or

<script src="https://cdn.jsdelivr.net/npm/droidscript-sdk/dist/droid.min.js"></script>

This will expose a global droid variable that you can use to access the library's functionality.

Usage

All methods exposed by this API are similar to the original DroidScript methods, but they start with lowercase letters.

For example:

// after
app.WriteFile('/sdcard/Documents/example.txt', 'Hello world !');
app.ShowPopup('I am a popup');

// now in droidscript-sdk :)
droid.writeFile('/sdcard/Documents/example.txt', 'Hello world !');
droid.showPopup('I am a popup'); 

Contributing

There are still many methods to add. We welcome contributions to droidscript-sdk. Please submit a pull request with your proposed changes.

droidscript-sdk's People

Contributors

rodnye avatar

Stargazers

 avatar

Watchers

 avatar

droidscript-sdk's Issues

Unexpected Token Export Issue In Index.js File

When running in ds, following error occured:
/storage/emulated/0/Android/data/com.smartphoneremote.androidscriptfree/files/DroidScript/droidscript sdkTest/node_modules/droidscript-sdk/lib/index.js:4
export * from './utils/utils.js'
^^^^^^

SyntaxError: Unexpected token 'export'
at Object.compileFunction (node:vm:360:18)
at wrapSafe (node:internal/modules/cjs/loader:1055:15)
at Module._compile (node:internal/modules/cjs/loader:1090:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
at Module.load (node:internal/modules/cjs/loader:1004:32)
at Function.Module._load (node:internal/modules/cjs/loader:839:12)
at Module.require (node:internal/modules/cjs/loader:1028:19)
at require (node:internal/modules/cjs/helpers:102:18)
at globalThis.require (/data/data/com.smartphoneremote.androidscriptfree/app_node/node.js:13:44)
at /storage/emulated/0/Android/data/com.smartphoneremote.androidscriptfree/files/DroidScript/droidscript sdkTest/droidscript sdkTest.js:13:13'
ERROR: Unexpected token 'export', Line 4, index.js

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.