├── .gitignore
├── LICENSE
├── NOTICE
├── README.md
├── app
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── assets
│ └── app
│ │ ├── index.html
│ │ ├── index.js
│ │ └── subdirectory
│ │ └── index.js
│ ├── java
│ └── io
│ │ └── nodekit
│ │ └── nodekitandroid
│ │ └── MainActivity.java
│ └── res
│ ├── layout
│ └── web_container.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxxhdpi
│ └── ic_launcher.png
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── apptest
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── co
│ │ │ └── synchealth
│ │ │ └── apptest
│ │ │ ├── JavaScriptBridge.java
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ └── content_main.xml
│ │ ├── menu
│ │ └── menu_main.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── co
│ └── synchealth
│ └── apptest
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── nkcore
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── assets
│ └── lib-core
│ │ ├── _nodekit_bootstrapper.js
│ │ ├── _nodekit_third_party_main.js
│ │ ├── bindings
│ │ ├── _delegates
│ │ │ ├── filesystem
│ │ │ │ ├── _browser_filesystem.js
│ │ │ │ ├── _filesystem.js
│ │ │ │ ├── binding.js
│ │ │ │ ├── descriptor.js
│ │ │ │ ├── directory.js
│ │ │ │ ├── error.js
│ │ │ │ ├── file.js
│ │ │ │ ├── item.js
│ │ │ │ └── symlink.js
│ │ │ ├── stream
│ │ │ │ └── _stream_wrap.js
│ │ │ ├── tcp
│ │ │ │ └── _tcp_wrap.js
│ │ │ ├── udp
│ │ │ │ └── _udp_wrap.js
│ │ │ └── zlib
│ │ │ │ └── pako
│ │ │ │ ├── LICENSE
│ │ │ │ └── lib
│ │ │ │ ├── utils
│ │ │ │ ├── common.js
│ │ │ │ └── strings.js
│ │ │ │ └── zlib
│ │ │ │ ├── adler32.js
│ │ │ │ ├── constants.js
│ │ │ │ ├── crc32.js
│ │ │ │ ├── deflate.js
│ │ │ │ ├── gzheader.js
│ │ │ │ ├── inffast.js
│ │ │ │ ├── inflate.js
│ │ │ │ ├── inftrees.js
│ │ │ │ ├── messages.js
│ │ │ │ ├── trees.js
│ │ │ │ └── zstream.js
│ │ ├── buffer.js
│ │ ├── cares_wrap.js
│ │ ├── constants.js
│ │ ├── contextify.js
│ │ ├── fs.js
│ │ ├── fs_event_wrap.js
│ │ ├── handle_wrap.js
│ │ ├── http_parser copy.js
│ │ ├── http_parser.js
│ │ ├── index.js
│ │ ├── natives.js
│ │ ├── os.js
│ │ ├── pipe_wrap.js
│ │ ├── process_wrap.js
│ │ ├── signal_wrap.js
│ │ ├── smalloc.js
│ │ ├── spawn_sync.js
│ │ ├── stream_wrap.js
│ │ ├── tcp_wrap.js
│ │ ├── timer_wrap.js
│ │ ├── tty_wrap.js
│ │ ├── udp_wrap.js
│ │ ├── uv.js
│ │ ├── v8.js
│ │ └── zlib.js
│ │ ├── builtin-additions
│ │ ├── asap.js
│ │ └── promise.js
│ │ ├── builtin-nodekit
│ │ ├── electro.js
│ │ ├── electro_protocol.js
│ │ └── platform.js
│ │ ├── builtin-replacements
│ │ ├── buffer.js
│ │ ├── crypto.js
│ │ ├── dns.js
│ │ └── timers.js
│ │ ├── node.js
│ │ ├── node
│ │ ├── LICENSE-NODEJS-0.12.9
│ │ ├── _debugger.js
│ │ ├── _http_agent.js
│ │ ├── _http_client.js
│ │ ├── _http_common.js
│ │ ├── _http_incoming.js
│ │ ├── _http_outgoing.js
│ │ ├── _http_server.js
│ │ ├── _linklist.js
│ │ ├── _stream_duplex.js
│ │ ├── _stream_passthrough.js
│ │ ├── _stream_readable.js
│ │ ├── _stream_transform.js
│ │ ├── _stream_writable.js
│ │ ├── _tls_common.js
│ │ ├── _tls_legacy.js
│ │ ├── _tls_wrap.js
│ │ ├── assert.js
│ │ ├── buffer.js
│ │ ├── child_process.js
│ │ ├── cluster.js
│ │ ├── console.js
│ │ ├── constants.js
│ │ ├── crypto.js
│ │ ├── dgram.js
│ │ ├── dns.js
│ │ ├── domain.js
│ │ ├── events.js
│ │ ├── freelist.js
│ │ ├── fs.js
│ │ ├── http.js
│ │ ├── https.js
│ │ ├── module.js
│ │ ├── net.js
│ │ ├── os.js
│ │ ├── path.js
│ │ ├── punycode.js
│ │ ├── querystring.js
│ │ ├── readline.js
│ │ ├── repl.js
│ │ ├── smalloc.js
│ │ ├── stream.js
│ │ ├── string_decoder.js
│ │ ├── sys.js
│ │ ├── timers.js
│ │ ├── tls.js
│ │ ├── tty.js
│ │ ├── url.js
│ │ ├── util.js
│ │ ├── vm.js
│ │ └── zlib.js
│ │ └── platform
│ │ ├── console.js
│ │ ├── crypto.js
│ │ ├── fs.js
│ │ ├── process.js
│ │ ├── tcp.js
│ │ ├── timer.js
│ │ └── udp.js
│ └── res
│ └── values
│ └── strings.xml
├── nkelectro
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── assets
│ └── lib_electro
│ │ ├── _nke_main.js
│ │ ├── _nke_renderer.js
│ │ ├── app.js
│ │ ├── browserwindow.js
│ │ ├── electro.js
│ │ ├── ipcMain.js
│ │ ├── ipcRenderer.js
│ │ ├── menu-item.js
│ │ ├── menu.js
│ │ ├── protocol.js
│ │ └── webcontents.js
│ ├── java
│ └── io
│ │ └── nodekit
│ │ └── nkelectro
│ │ ├── NKE_App.java
│ │ ├── NKE_BrowserWindow.java
│ │ ├── NKE_Event.java
│ │ ├── NKE_IpcMain.java
│ │ ├── NKE_IpcRenderer.java
│ │ ├── NKE_Protocol.java
│ │ ├── NKE_WebContents.java
│ │ ├── NKE_WebContents_AndroidWebView.java
│ │ └── NKElectro.java
│ └── res
│ └── values
│ └── strings.xml
├── nkscripting
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── assets
│ └── lib-scripting
│ │ ├── init_androidwebview.js
│ │ ├── native_module.js
│ │ ├── nkscripting.js
│ │ ├── promise.js
│ │ └── timer.js
│ ├── java
│ └── io
│ │ └── nodekit
│ │ └── nkscripting
│ │ ├── NKApplication.java
│ │ ├── NKScriptContext.java
│ │ ├── NKScriptContextFactory.java
│ │ ├── NKScriptExport.java
│ │ ├── NKScriptSource.java
│ │ ├── NKScriptValue.java
│ │ ├── channelbridge
│ │ ├── NKScriptChannel.java
│ │ ├── NKScriptInvocation.java
│ │ ├── NKScriptMessage.java
│ │ ├── NKScriptTypeInfo.java
│ │ └── NKScriptValueNative.java
│ │ ├── engines
│ │ └── androidwebview
│ │ │ └── NKEngineAndroidWebView.java
│ │ └── util
│ │ ├── NKArchiveReader.java
│ │ ├── NKDisposable.java
│ │ ├── NKEventEmitter.java
│ │ ├── NKEventHandler.java
│ │ ├── NKLogging.java
│ │ ├── NKSerialize.java
│ │ ├── NKStorage.java
│ │ ├── NKTimer.java
│ │ └── NKTimerTask.java
│ └── res
│ └── values
│ └── strings.xml
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the ART/Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 | out/
15 |
16 | # Gradle files
17 | .gradle/
18 | build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Android Studio Navigation editor temp files
30 | .navigation/
31 |
32 | # Android Studio captures folder
33 | captures/
34 |
35 | # IntelliJ and BuildShip
36 | *.iml
37 | .idea/
38 | .project
39 | .classpath
40 |
41 | # Keystore files
42 | # Uncomment the following line if you do not want to check your keystore files in.
43 | #*.jks
44 |
45 | # External native build folder generated in Android Studio 2.2 and later
46 | .externalNativeBuild
47 |
48 | # Google Services (e.g. APIs or Firebase)
49 | google-services.json
50 |
51 | # Freeline
52 | freeline.py
53 | freeline/
54 | freeline_project_description.json
55 |
56 | # fastlane
57 | fastlane/report.xml
58 | fastlane/Preview.html
59 | fastlane/screenshots
60 | fastlane/test_output
61 | fastlane/readme.md
62 |
63 | .cxx/
64 | org.eclipse.buildship.core.prefs
65 |
66 | node_modules/
67 | unused/
--------------------------------------------------------------------------------
/NOTICE:
--------------------------------------------------------------------------------
1 | NodeKit
2 | Copyright (c) 2016-9 OffGrid Networks. All Rights Reserved
3 |
4 | This product includes software developed at OffGrid Networks
5 | for NodeKit (http://nodekit.io/).
6 |
7 | Portions Copyright (c) Guy Barnard 2016-7
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion rootProject.compileSdkVersion
5 | buildToolsVersion rootProject.buildToolsVersion
6 |
7 | defaultConfig {
8 | applicationId "io.nodekit.nodekitandroid"
9 | minSdkVersion rootProject.minSdkVersion
10 | targetSdkVersion rootProject.targetSdkVersion
11 | versionCode rootProject.versionCode
12 | versionName rootProject.versionName
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | api fileTree(dir: 'libs', include: ['*.jar'])
24 | testImplementation 'junit:junit:4.12'
25 | api "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
26 | api project(":nkscripting")
27 | api project(":nkelectro")
28 | }
29 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:\Users\Guy\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/assets/app/index.html:
--------------------------------------------------------------------------------
1 |
2 | HELLO WORLD
3 |
--------------------------------------------------------------------------------
/app/src/main/assets/app/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2016 OffGrid Networks. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | const nodekit = require('electro').app,
18 | BrowserWindow = require('electro').BrowserWindow,
19 | protocol = require('electro').protocol;
20 |
21 | console.log("STARTING SAMPLE ELECTRO APPLICATION");
22 |
23 | protocol.interceptInternalProtocol("internal");
24 |
25 | const functionExport = require("./subdirectory")
26 |
27 | functionExport()
28 |
29 | const secondFunction = require("./subdirectory/index")
30 |
31 | secondFunction()
32 |
33 | var last = now()
34 | var counter = 0
35 | var timerId = setInterval(function() {
36 | const newTime = now()
37 | console.error("delta :" + (newTime - last))
38 | last = newTime
39 | counter += 1
40 | if (counter == 5) {
41 | clearTimeout(timerId)
42 | }
43 | }, 2500)
44 |
45 | setTimeout(function() {
46 | console.log("single timer fire")
47 | setTimeout(function() {
48 | console.log("second timer fire")
49 | }, 2000)
50 | }, 15000)
51 |
52 | console.log("variadic", "args", "test", {}, new Date())
53 | console.warn("variadic", "args", "test")
54 | console.error("variadic", "args", "test")
55 | console.info("variadic", "args", "test")
56 | console.dir("variadic", "args", "test")
57 |
58 | nodekit.on("ready", function() {
59 |
60 | var p = new BrowserWindow({ 'preloadURL': 'internal://localhost/app/index.html',
61 | 'nk.allowCustomProtocol': true,
62 | 'nk.taskBarPopup': true,
63 | 'nk.taskBarIcon': 'MenuIcon',
64 | 'width': 300,
65 | 'height': 600
66 | });
67 |
68 | console.log("Server running");
69 | });
70 |
71 | function now() {
72 | return new Date().getTime()
73 | }
--------------------------------------------------------------------------------
/app/src/main/assets/app/subdirectory/index.js:
--------------------------------------------------------------------------------
1 |
2 |
3 | module.exports = function() {
4 | console.log("function export")
5 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/web_container.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
17 |
18 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nodekit-io/nodekit-android/5974a7ed6ad7f088980d48e878e9a8e644715d3f/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nodekit-io/nodekit-android/5974a7ed6ad7f088980d48e878e9a8e644715d3f/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nodekit-io/nodekit-android/5974a7ed6ad7f088980d48e878e9a8e644715d3f/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nodekit-io/nodekit-android/5974a7ed6ad7f088980d48e878e9a8e644715d3f/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nodekit-io/nodekit-android/5974a7ed6ad7f088980d48e878e9a8e644715d3f/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | NodeKitAndroid
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/apptest/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion rootProject.compileSdkVersion
5 | buildToolsVersion rootProject.buildToolsVersion
6 |
7 | defaultConfig {
8 | applicationId "io.nodekit.apptest"
9 | minSdkVersion rootProject.minSdkVersion
10 | targetSdkVersion rootProject.targetSdkVersion
11 | versionCode rootProject.versionCode
12 | versionName rootProject.versionName
13 | }
14 |
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 | }
22 |
23 | dependencies {
24 |
25 | implementation project(':nkscripting')
26 |
27 | implementation fileTree(dir: 'libs', include: ['*.jar'])
28 | implementation 'com.android.support:appcompat-v7:27.1.1'
29 | implementation 'com.android.support.constraint:constraint-layout:1.1.3'
30 | implementation 'com.android.support:design:27.1.1'
31 | testImplementation 'junit:junit:4.12'
32 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
33 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
34 | }
35 |
36 | configurations.all {
37 | resolutionStrategy.eachDependency { DependencyResolveDetails details ->
38 | def requested = details.requested
39 | if (requested.group == "com.android.support") {
40 | if (!requested.name.startsWith("multidex")) {
41 | details.useVersion "27.+"
42 | }
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/apptest/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/apptest/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/apptest/src/main/java/co/synchealth/apptest/JavaScriptBridge.java:
--------------------------------------------------------------------------------
1 | package co.synchealth.apptest;
2 |
3 | import android.app.Activity;
4 | import android.widget.TextView;
5 | import android.webkit.JavascriptInterface;
6 |
7 | import java.util.List;
8 |
9 | import io.nodekit.nkscripting.NKScriptExport;
10 | import io.nodekit.nkscripting.NKScriptValue;
11 |
12 | public class JavaScriptBridge implements NKScriptExport {
13 |
14 | private Activity mainActivity;
15 |
16 | JavaScriptBridge(Activity main) {
17 | this.mainActivity = main;
18 | }
19 |
20 | @JavascriptInterface
21 | public void factorial(final int start, final NKScriptValue callback) {
22 |
23 | mainActivity.runOnUiThread(new Runnable() {
24 | @Override
25 | public void run() {
26 | int x = start;
27 | int factorial = 1;
28 | for (; x > 1; x--) {
29 | factorial *= x;
30 | }
31 | callback.callWithArguments(new Object[] { factorial }, null);
32 |
33 | }
34 | });
35 |
36 | }
37 |
38 | @JavascriptInterface
39 | public void updateTitle(final int result) {
40 |
41 | mainActivity.runOnUiThread(new Runnable() {
42 | @Override
43 | public void run() {
44 | TextView textView = mainActivity.findViewById(R.id.textView);
45 | textView.setText( Integer.toString(result));
46 | }
47 | });
48 |
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/apptest/src/main/java/co/synchealth/apptest/MainActivity.java:
--------------------------------------------------------------------------------
1 | package co.synchealth.apptest;
2 |
3 | import android.os.Bundle;
4 | import android.support.design.widget.FloatingActionButton;
5 | import android.support.design.widget.Snackbar;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.support.v7.widget.Toolbar;
8 | import android.view.View;
9 | import android.view.Menu;
10 | import android.view.MenuItem;
11 | import android.util.Log;
12 |
13 | import java.util.HashMap;
14 |
15 | import io.nodekit.nkscripting.NKScriptContext;
16 | import io.nodekit.nkscripting.NKApplication;
17 | import io.nodekit.nkscripting.NKScriptContextFactory;
18 | import io.nodekit.nkscripting.util.NKLogging;
19 |
20 | public class MainActivity extends AppCompatActivity implements NKScriptContext.NKScriptContextDelegate {
21 |
22 | private NKScriptContext context;
23 | private JavaScriptBridge bridge;
24 |
25 | @Override
26 | protected void onCreate(Bundle savedInstanceState) {
27 |
28 | super.onCreate(savedInstanceState);
29 | setContentView(R.layout.activity_main);
30 | NKApplication.setAppContext(this);
31 |
32 | Toolbar toolbar = findViewById(R.id.toolbar);
33 | setSupportActionBar(toolbar);
34 |
35 | FloatingActionButton fab = findViewById(R.id.fab);
36 | fab.setOnClickListener(new View.OnClickListener() {
37 | @Override
38 | public void onClick(View view) {
39 | Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
40 | .setAction("Action", null).show();
41 | }
42 | });
43 |
44 | try {
45 | NKScriptContextFactory.createContext(null, this);
46 | }
47 | catch (Exception e) {
48 | Log.v("NodeKitAndroid", e.toString());
49 | }
50 |
51 | }
52 |
53 | public void NKScriptEngineDidLoad(NKScriptContext context) {
54 | NKLogging.log("ScriptEngine Loaded");
55 | this.context = context;
56 |
57 | bridge = new JavaScriptBridge(this);
58 | HashMap options = new HashMap();
59 |
60 | try {
61 | context.loadPlugin(bridge, "myactivity", options);
62 |
63 | } catch (Exception e) {
64 | Log.e("MYAPP", "exception: " + e.getMessage());
65 | Log.e("MYAPP", "exception: " + e.toString());
66 | }
67 |
68 | }
69 |
70 | public void NKScriptEngineReady(NKScriptContext context) {
71 |
72 | NKLogging.log("ScriptEngine Ready");
73 |
74 | bootstrap();
75 | }
76 |
77 | void bootstrap() {
78 |
79 | try {
80 | String jsbuf = "myactivity.factorial(10, function(f) { myactivity.updateTitle(f); } ); ";
81 | context.evaluateJavaScript(jsbuf, null);
82 | } catch (Exception e) {
83 | NKLogging.log(e);
84 | }
85 | }
86 |
87 |
88 | @Override
89 | public boolean onCreateOptionsMenu(Menu menu) {
90 | // Inflate the menu; this adds items to the action bar if it is present.
91 | getMenuInflater().inflate(R.menu.menu_main, menu);
92 | return true;
93 | }
94 |
95 | @Override
96 | public boolean onOptionsItemSelected(MenuItem item) {
97 | // Handle action bar item clicks here. The action bar will
98 | // automatically handle clicks on the Home/Up button, so long
99 | // as you specify a parent activity in AndroidManifest.xml.
100 | int id = item.getItemId();
101 |
102 | //noinspection SimplifiableIfStatement
103 | if (id == R.id.action_settings) {
104 | return true;
105 | }
106 |
107 | return super.onOptionsItemSelected(item);
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/apptest/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/apptest/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
20 |
21 |
22 |
23 |
24 |
25 |
32 |
33 |
--------------------------------------------------------------------------------
/apptest/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
20 |
21 |
--------------------------------------------------------------------------------
/apptest/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
11 |
--------------------------------------------------------------------------------
/apptest/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/apptest/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/apptest/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nodekit-io/nodekit-android/5974a7ed6ad7f088980d48e878e9a8e644715d3f/apptest/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/apptest/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nodekit-io/nodekit-android/5974a7ed6ad7f088980d48e878e9a8e644715d3f/apptest/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/apptest/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nodekit-io/nodekit-android/5974a7ed6ad7f088980d48e878e9a8e644715d3f/apptest/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/apptest/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nodekit-io/nodekit-android/5974a7ed6ad7f088980d48e878e9a8e644715d3f/apptest/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/apptest/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nodekit-io/nodekit-android/5974a7ed6ad7f088980d48e878e9a8e644715d3f/apptest/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/apptest/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nodekit-io/nodekit-android/5974a7ed6ad7f088980d48e878e9a8e644715d3f/apptest/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/apptest/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nodekit-io/nodekit-android/5974a7ed6ad7f088980d48e878e9a8e644715d3f/apptest/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/apptest/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nodekit-io/nodekit-android/5974a7ed6ad7f088980d48e878e9a8e644715d3f/apptest/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/apptest/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nodekit-io/nodekit-android/5974a7ed6ad7f088980d48e878e9a8e644715d3f/apptest/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/apptest/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nodekit-io/nodekit-android/5974a7ed6ad7f088980d48e878e9a8e644715d3f/apptest/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/apptest/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #008577
4 | #00574B
5 | #D81B60
6 |
7 |
--------------------------------------------------------------------------------
/apptest/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 16dp
3 |
4 |
--------------------------------------------------------------------------------
/apptest/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | App Test
3 | Settings
4 |
5 |
--------------------------------------------------------------------------------
/apptest/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/apptest/src/test/java/co/synchealth/apptest/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package co.synchealth.apptest;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | google()
6 | jcenter()
7 |
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.5.0'
11 | classpath 'com.novoda:bintray-release:0.9.1'
12 |
13 | // NOTE: Do not place your application dependencies here; they belong
14 | // in the individual module build.gradle files
15 | }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | google()
21 | jcenter()
22 |
23 | }
24 | }
25 |
26 | task clean(type: Delete) {
27 | delete rootProject.buildDir
28 | }
29 |
30 | ext {
31 | versionCode = 230
32 | versionName = "2.3.1"
33 | buildToolsVersion = '29.0.2'
34 | minSdkVersion = 21
35 | compileSdkVersion = 27
36 | targetSdkVersion = 27
37 | supportLibraryVersion = "27.0.2"
38 | }
39 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 |
15 |
16 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nodekit-io/nodekit-android/5974a7ed6ad7f088980d48e878e9a8e644715d3f/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun Sep 29 09:02:00 BST 2019
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/nkcore/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/nkcore/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | group='com.github.jitpack'
4 |
5 | android {
6 | compileSdkVersion rootProject.compileSdkVersion
7 | buildToolsVersion rootProject.buildToolsVersion
8 |
9 | defaultConfig {
10 | minSdkVersion rootProject.minSdkVersion
11 | targetSdkVersion rootProject.targetSdkVersion
12 | versionCode rootProject.versionCode
13 | versionName rootProject.versionName
14 | }
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 | }
22 |
23 | dependencies {
24 | api fileTree(dir: 'libs', include: ['*.jar'])
25 | implementation "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
26 | }
27 |
--------------------------------------------------------------------------------
/nkcore/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:\Users\Guy\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/nkcore/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/_nodekit_third_party_main.js:
--------------------------------------------------------------------------------
1 | /*
2 | * nodekit.io
3 | *
4 | * Copyright (c) 2016 OffGrid Networks. All Rights Reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | module = require('module');
19 | var util = require('util');
20 | var path = require('path');
21 | util.isBuffer = Buffer.isBuffer;
22 | global.process.sources = [];
23 | var EventEmitter = require('events').EventEmitter;
24 |
25 | console.warn = console.log;
26 |
27 | DTRACE_NET_SERVER_CONNECTION = function(){};
28 | DTRACE_NET_STREAM_END= function(){};
29 | DTRACE_NET_SOCKET_READ = function(){};
30 | DTRACE_NET_SOCKET_WRITE = function(){};
31 | DTRACE_HTTP_SERVER_REQUEST = function(){};
32 | DTRACE_HTTP_SERVER_RESPONSE = function(){};
33 | DTRACE_HTTP_CLIENT_REQUEST = function(){};
34 | DTRACE_HTTP_CLIENT_RESPONSE = function(){};
35 | COUNTER_NET_SERVER_CONNECTION = function(){};
36 | COUNTER_NET_SERVER_CONNECTION_CLOSE = function(){};
37 | COUNTER_HTTP_SERVER_REQUEST = function(){};
38 | COUNTER_HTTP_SERVER_RESPONSE = function(){};
39 | COUNTER_HTTP_CLIENT_REQUEST = function(){};
40 | COUNTER_HTTP_CLIENT_RESPONSE = function(){};
41 |
42 |
43 | /**
44 | * Register javascript Module loader to add sourceURL to end of every file
45 | *
46 | */
47 |
48 | module._extensions['.js'] = function nodekit_module_jsread(module, filename) {
49 | var file = filename.replace(process.execPath, "");
50 |
51 | var append = "\r\n //" + "# source" + "URL=" + file + "\r\n";
52 |
53 | var content = require('fs').readFileSync(filename, 'utf8') + append;
54 | global.process.sources[file] = content;
55 | module._compile(stripBOM(content), filename);
56 | };
57 |
58 | function stripBOM(content) {
59 | if (content.charCodeAt(0) === 0xFEFF) {
60 | content = content.slice(1);
61 | }
62 | return content;
63 | }
64 |
65 | /*var dns = require('dns');
66 | dns.platform.name_servers = [
67 | {
68 | address: '8.8.8.8',
69 | port: 53
70 | },
71 | {
72 | address: '8.8.4.4',
73 | port: 53
74 | }
75 | ]; */
76 |
77 | if (Error.captureStackTrace === undefined) {
78 | Error.captureStackTrace = function (obj) {
79 | if (Error.prepareStackTrace) {
80 | var frame = {
81 | isEval: function () { return false; },
82 | getFileName: function () { return "filename"; },
83 | getLineNumber: function () { return 1; },
84 | getColumnNumber: function () { return 1; },
85 | getFunctionName: function () { return "functionName" }
86 | };
87 |
88 | obj.stack = Error.prepareStackTrace(obj, [frame, frame, frame]);
89 | } else {
90 | obj.stack = obj.stack || obj.name || "Error";
91 | }
92 | };
93 |
94 | }
95 |
96 | /**
97 | * NODEKIT INITIALIZATION
98 | * Load Application package.json file, register request/response server, and load debug application
99 | */
100 |
101 | console.log("Starting PACKAGE.JSON");
102 | // INVOKE MAIN APP
103 | process.package = module._load('package.json', null, false);
104 | process.argv = ["node", __dirname + "/" + process.package['main']]
105 | console.log("Starting" + process.package['main']);
106 | module._load(process.package['main'], null, true);
107 |
108 | process.nextTick(function(){
109 | process.native.emit("nk.jsApplicationReady", "");
110 | });
111 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/bindings/_delegates/filesystem/directory.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2016 OffGrid Networks; Portions Copyright 2014 Tim Schaub
3 | *
4 | * Licensed under the the MIT license (the "License");
5 | * you may not use this file except in compliance with the License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the “Software”), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in
15 | * all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 | * OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | var util = require('util');
27 |
28 | var Item = require('./item');
29 |
30 | var constants = process.binding('constants');
31 |
32 |
33 |
34 | /**
35 | * A directory.
36 | * @constructor
37 | */
38 | function Directory() {
39 | Item.call(this);
40 |
41 | /**
42 | * Items in this directory.
43 | * @type {Object.}
44 | */
45 | this._items = {};
46 |
47 | /**
48 | * Permissions.
49 | */
50 | this._mode = 0777;
51 | this._isFile = false;
52 | this._isDirectory = true;
53 |
54 | }
55 | util.inherits(Directory, Item);
56 |
57 |
58 | /**
59 | * Add an item to the directory.
60 | * @param {string} name The name to give the item.
61 | * @param {Item} item The item to add.
62 | * @return {Item} The added item.
63 | */
64 | Directory.prototype.addItem = function(name, item) {
65 | if (this._items.hasOwnProperty(name)) {
66 | throw new Error('Item with the same name already exists: ' + name);
67 | }
68 | this._items[name] = item;
69 | ++item.links;
70 | if (item instanceof Directory) {
71 | // for '.' entry
72 | ++item.links;
73 | // for subdirectory
74 | ++this.links;
75 | }
76 | this.setMTime(new Date());
77 | return item;
78 | };
79 |
80 |
81 | /**
82 | * Get a named item.
83 | * @param {string} name Item name.
84 | * @return {Item} The named item (or null if none).
85 | */
86 | Directory.prototype.getItem = function(name) {
87 | var item = null;
88 | if (this._items.hasOwnProperty(name)) {
89 | item = this._items[name];
90 | }
91 | return item;
92 | };
93 |
94 |
95 | /**
96 | * Remove an item.
97 | * @param {string} name Name of item to remove.
98 | * @return {Item} The orphan item.
99 | */
100 | Directory.prototype.removeItem = function(name) {
101 | if (!this._items.hasOwnProperty(name)) {
102 | throw new Error('Item does not exist in directory: ' + name);
103 | }
104 | var item = this._items[name];
105 | delete this._items[name];
106 | --item.links;
107 | if (item instanceof Directory) {
108 | // for '.' entry
109 | --item.links;
110 | // for subdirectory
111 | --this.links;
112 | }
113 | this.setMTime(new Date());
114 | return item;
115 | };
116 |
117 |
118 | /**
119 | * Get list of item names in this directory.
120 | * @return {Array.} Item names.
121 | */
122 | Directory.prototype.list = function() {
123 | return Object.keys(this._items).sort();
124 | };
125 |
126 |
127 | /**
128 | * Get directory stats.
129 | * @return {Object} Stats properties.
130 | */
131 | Directory.prototype.getStats = function() {
132 | var stats = Item.prototype.getStats.call(this);
133 | stats.mode = this.getMode() | constants.S_IFDIR;
134 | stats.size = 1;
135 | stats.blocks = 1;
136 | return stats;
137 | };
138 |
139 |
140 | /**
141 | * Export the constructor.
142 | * @type {function()}
143 | */
144 | exports = module.exports = Directory;
145 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/bindings/_delegates/filesystem/file.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2016 OffGrid Networks; Portions Copyright 2014 Tim Schaub
3 | *
4 | * Licensed under the the MIT license (the "License");
5 | * you may not use this file except in compliance with the License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the “Software”), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in
15 | * all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 | * OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | var Item = require('./item');
27 | var Buffer = require('buffer').Buffer;
28 | var EMPTY = Buffer(0);
29 | var util = require('util');
30 |
31 | var constants = process.binding('constants');
32 |
33 |
34 | /**
35 | * A directory.
36 | * @constructor
37 | */
38 | function File() {
39 | Item.call(this);
40 |
41 | /**
42 | * File content.
43 | * @type {Buffer}
44 | */
45 | this._content = EMPTY;
46 | this._isloaded = false;
47 |
48 | /**
49 | * path to source.
50 | * @type {string}
51 | */
52 | this._path = undefined;
53 | /**
54 | * size of content
55 | * @type {number}
56 | */
57 | this._size = 0;
58 |
59 | this._isFile = true;
60 | this._isDirectory = false;
61 | }
62 | util.inherits(File, Item);
63 |
64 |
65 | /**
66 | * Get the file contents.
67 | * @return {Buffer} File contents.
68 | */
69 | File.prototype.getContent = function () {
70 | this.setATime(new Date());
71 | return this._content;
72 | };
73 |
74 |
75 | /**
76 | * Get size
77 | * @return {number} Size.
78 | */
79 | File.prototype.getSize = function() {
80 | return this._size;
81 | };
82 |
83 | /**
84 | * Set the path to the source.
85 | * @param {string} pathname Path to source.
86 | */
87 | File.prototype.setPath = function(pathname) {
88 | this._path = pathname;
89 | };
90 |
91 |
92 | /**
93 | * Get the path to the source.
94 | * @return {string} Path to source.
95 | */
96 | File.prototype.getPath = function() {
97 | return this._path;
98 | };
99 |
100 |
101 |
102 | /**
103 | * Set size
104 | * @param {number} size Size.
105 | */
106 | File.prototype.setSize = function(size) {
107 | this._size = size;
108 | };
109 |
110 |
111 | /**
112 | * Set the file contents.
113 | * @param {string|Buffer} content File contents.
114 | */
115 | File.prototype.setContent = function (content) {
116 | this._isloaded = true;
117 | if (typeof content === 'string') {
118 | content = new Buffer(content);
119 | } else if (!Buffer.isBuffer(content)) {
120 |
121 |
122 | throw new Error('File content must be a string or buffer');
123 | }
124 | this._content = content;
125 | this._size = content.length;
126 |
127 | var now = Date.now();
128 | this.setCTime(new Date(now));
129 | this.setMTime(new Date(now));
130 | };
131 |
132 |
133 | /**
134 | * Get file stats.
135 | * @return {Object} Stats properties.
136 | */
137 | File.prototype.getStats = function() {
138 | var size = this._size; //_content.length;
139 |
140 | var stats = Item.prototype.getStats.call(this);
141 | stats.mode = this.getMode() | constants.S_IFREG;
142 | stats.size = size;
143 | stats.blocks = Math.ceil(size / 512);
144 | return stats;
145 | };
146 |
147 | /**
148 | * Get content is loaded.
149 | * @return {bool} Content has been loaded.
150 | */
151 | Item.prototype.getIsLoaded = function () {
152 | return this._isloaded;
153 | };
154 |
155 |
156 | /**
157 | * Export the constructor.
158 | * @type {function()}
159 | */
160 | exports = module.exports = File;
161 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/bindings/_delegates/filesystem/symlink.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2016 OffGrid Networks; Portions Copyright 2014 Tim Schaub
3 | *
4 | * Licensed under the the MIT license (the "License");
5 | * you may not use this file except in compliance with the License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the “Software”), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in
15 | * all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 | * OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | var util = require('util');
27 |
28 | var Item = require('./item');
29 |
30 | var constants = process.binding('constants');
31 |
32 |
33 |
34 | /**
35 | * A directory.
36 | * @constructor
37 | */
38 | function SymbolicLink() {
39 | Item.call(this);
40 |
41 | /**
42 | * Relative path to source.
43 | * @type {string}
44 | */
45 | this._path = undefined;
46 |
47 | }
48 | util.inherits(SymbolicLink, Item);
49 |
50 |
51 | /**
52 | * Set the path to the source.
53 | * @param {string} pathname Path to source.
54 | */
55 | SymbolicLink.prototype.setPath = function(pathname) {
56 | this._path = pathname;
57 | };
58 |
59 |
60 | /**
61 | * Get the path to the source.
62 | * @return {string} Path to source.
63 | */
64 | SymbolicLink.prototype.getPath = function() {
65 | return this._path;
66 | };
67 |
68 |
69 | /**
70 | * Get symbolic link stats.
71 | * @return {Object} Stats properties.
72 | */
73 | SymbolicLink.prototype.getStats = function() {
74 | var size = this._path.length;
75 | var stats = Item.prototype.getStats.call(this);
76 | stats.mode = this.getMode() | constants.S_IFLNK;
77 | stats.size = size;
78 | stats.blocks = Math.ceil(size / 512);
79 | return stats;
80 | };
81 |
82 |
83 | /**
84 | * Export the constructor.
85 | * @type {function()}
86 | */
87 | exports = module.exports = SymbolicLink;
88 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/bindings/_delegates/stream/_stream_wrap.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2016 OffGrid Networks. Portions copyright Red Hat, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | // PLATFORM: DARWIN
18 |
19 | "use strict";
20 |
21 | var util = require('util');
22 | var Handle = process.binding('handle_wrap').Handle;
23 |
24 | var Buffer = require('buffer').Buffer;
25 |
26 | function Stream(stream) {
27 | this._stream = stream;
28 | this._onStreamData = Stream.prototype._onData.bind(this);
29 | this._onStreamEnd = Stream.prototype._onEnd.bind(this);
30 |
31 | this._stream.on( 'data', this._onStreamData );
32 | this._stream.on( 'end', this._onStreamEnd );
33 | Handle.call( this, this._stream );
34 | }
35 |
36 | util.inherits(Stream, Handle);
37 |
38 | // ----------------------------------------
39 |
40 | Stream.prototype._onData = function(chunk) {
41 | var b = new Buffer( chunk, 'base64');
42 | this.onread( b.length, b );
43 | };
44 |
45 | Stream.prototype._onEnd = function() {
46 | if (this._stream)
47 | {
48 | this._stream.removeListener( 'data', this._onStreamData );
49 | this._stream.removeListener( 'end', this._onStreamEnd );
50 |
51 | this._onStreamData = null;
52 | this._onStreamEnd = null;
53 | this._stream = null;
54 | };
55 |
56 | if ( this.onread ) {
57 | this.onread( -1 );
58 | this.onread = null;
59 | }
60 |
61 | };
62 |
63 | // ----------------------------------------
64 |
65 | Stream.prototype.readStart = function() {
66 | this._stream.resume();
67 | };
68 |
69 | Stream.prototype.readStop = function() {
70 | this._stream.pause();
71 | };
72 |
73 | Stream.prototype.writeUtf8String = function(req, data) {
74 | this._stream.write(data, 'utf8');
75 | };
76 |
77 | Stream.prototype.writeAsciiString = function(req, data) {
78 | this._stream.write(data, 'ascii');
79 | };
80 |
81 | Stream.prototype.writeBinaryString = function(req, data) {
82 | this._stream.write(data, 'binary');
83 | };
84 |
85 | Stream.prototype.writeUcs2String = function(req, data) {
86 | this._stream.write(data, 'ucs2');
87 | };
88 |
89 | Stream.prototype.writeBuffer = function(req, data) {
90 | this._stream.write(data.toString('base64'), 'base64');
91 |
92 | //function afterWrite(status, handle, req, err)
93 | req.oncomplete(0, this, req , null);
94 | };
95 |
96 | Stream.prototype.shutdown = function(req) {
97 | if (this._stream)
98 | this._stream.close();
99 |
100 | //afterShutdown(status, handle, req)
101 | req.oncomplete( 0, this, req );
102 | };
103 |
104 | module.exports.Stream = Stream;
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/bindings/_delegates/udp/_udp_wrap.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2016 OffGrid Networks
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 |
18 | var Handle = process.binding('handle_wrap').Handle;
19 | var util = require('util');
20 | var EventEmitter = require('events').EventEmitter;
21 | var Buffer = require('buffer').Buffer;
22 | var nativeUDP = require('platform').UDP
23 |
24 | /* UDP Binding
25 | * Behaves like a EventEmitter and inherits handle_wrap
26 | *
27 | * Dependencies:
28 | * io.nodekit.platform.UDP() that inherits EventEmitter
29 | * _udp.bind(ip, port, flags)
30 | * _udp.recvStart()
31 | * _udp.send(buffer, offset, length, port, address)
32 | * _udp.recvStop()
33 | * _udp.localAddress returns {String address, int port}
34 | * _udp.remoteAddress returns {String address, int port}
35 | * _udp.addMembership(mcastAddr, ifaceAddr)
36 | * _udp.dropMembership(mcastAddr, ifaceAddr)
37 | * _udp.setMulticastTTL(ttl)
38 | * _udp.setMulticastLoopback(flag);
39 | * _udp.setBroadcast(flag);
40 | * _udp.setTTL(ttl);
41 | *
42 | * emits 'recv' (base64 chunk, host, port)
43 | *
44 | */
45 |
46 | var UDP = function() {
47 | if (!(this instanceof UDP))
48 | {
49 | return new UDP();
50 | }
51 | this._udp = new nativeUDP();
52 |
53 | Handle.call(this, this._udp);
54 | this._handle.on('recv', UDP.prototype._onRecv.bind(this));
55 | };
56 |
57 | util.inherits(UDP, Handle);
58 | module.exports.UDP = UDP;
59 |
60 | UDP.prototype._onRecv =function UDP_onReceive(chunk, host, port) {
61 |
62 | if (typeof this.onmessage === 'function') {
63 | var buf = new Buffer( chunk, 'base64');
64 | rinfo = {};
65 | rinfo.address = host;
66 | rinfo.port = port;
67 |
68 | this.onmessage(buf.length, this, buf, rinfo);
69 | }
70 | };
71 |
72 | UDP.prototype.bind = function(addr, port, flags) {
73 | var e = this._udp.bindSync(addr, port, flags);
74 | if (e !== 0) { throw new Error(e); }
75 | };
76 |
77 | UDP.prototype.bind6 = function(ip, port, flags) {
78 | return new Error( "ipv6 not supported" );
79 | };
80 |
81 | UDP.prototype.recvStart = function() {
82 | this._udp.recvStart();
83 | };
84 |
85 | UDP.prototype.send = function(req, buffer, offset, length, port, address) {
86 | var str = buffer.toString('base64', offset, length);
87 | this._udp.send(str, address, port);
88 |
89 | if (req.oncomplete) {
90 | req.oncomplete();
91 | }
92 | };
93 |
94 | UDP.prototype.send6 = function(req, buffer, offset, length, port, address) {
95 | return new Error( "ipv6 not supported" );
96 | };
97 |
98 | UDP.prototype.recvStop = function() {
99 | this._udp.recvStop();
100 | };
101 |
102 |
103 | UDP.prototype.getsockname = function(out) {
104 | var local = this._udp.localAddressSync();
105 | out.address = local.address;
106 | out.port = local.port;
107 | out.family ='IPv4';
108 | };
109 |
110 | UDP.prototype.addMembership = function(mcastAddr, ifaceAddr) {
111 | this._udp.addMembership(mcastAddr, ifaceAddr);
112 | };
113 |
114 | UDP.prototype.dropMembership = function(mcastAddr, ifaceAddr) {
115 | this._udp.dropMembership(mcastAddr, ifaceAddr);
116 | };
117 |
118 | UDP.prototype.setMulticastTTL = function(ttl) {
119 | this._udp.setMulticastTTL(ttl);
120 | };
121 |
122 | UDP.prototype.setMulticastLoopback = function(flag) {
123 | this._udp.setMulticastLoopback(flag);
124 | };
125 |
126 | UDP.prototype.setBroadcast = function(flag) {
127 | this._udp.setBroadcast(flag);
128 | };
129 |
130 | UDP.prototype.setTTL = function(ttl) {
131 | this._udp.setTTL(ttl);
132 | };
133 |
134 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/bindings/_delegates/zlib/pako/LICENSE:
--------------------------------------------------------------------------------
1 | (The MIT License)
2 |
3 | Copyright (C) 2014-2015 by Vitaly Puzrin
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/bindings/_delegates/zlib/pako/lib/utils/common.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 |
4 | var TYPED_OK = (typeof Uint8Array !== 'undefined') &&
5 | (typeof Uint16Array !== 'undefined') &&
6 | (typeof Int32Array !== 'undefined');
7 |
8 |
9 | exports.assign = function (obj /*from1, from2, from3, ...*/) {
10 | var sources = Array.prototype.slice.call(arguments, 1);
11 | while (sources.length) {
12 | var source = sources.shift();
13 | if (!source) { continue; }
14 |
15 | if (typeof source !== 'object') {
16 | throw new TypeError(source + 'must be non-object');
17 | }
18 |
19 | for (var p in source) {
20 | if (source.hasOwnProperty(p)) {
21 | obj[p] = source[p];
22 | }
23 | }
24 | }
25 |
26 | return obj;
27 | };
28 |
29 |
30 | // reduce buffer size, avoiding mem copy
31 | exports.shrinkBuf = function (buf, size) {
32 | if (buf.length === size) { return buf; }
33 | if (buf.subarray) { return buf.subarray(0, size); }
34 | buf.length = size;
35 | return buf;
36 | };
37 |
38 |
39 | var fnTyped = {
40 | arraySet: function (dest, src, src_offs, len, dest_offs) {
41 | if (src.subarray && dest.subarray) {
42 | dest.set(src.subarray(src_offs, src_offs+len), dest_offs);
43 | return;
44 | }
45 | // Fallback to ordinary array
46 | for (var i=0; i>> 16) & 0xffff) |0,
10 | n = 0;
11 |
12 | while (len !== 0) {
13 | // Set limit ~ twice less than 5552, to keep
14 | // s2 in 31-bits, because we force signed ints.
15 | // in other case %= will fail.
16 | n = len > 2000 ? 2000 : len;
17 | len -= n;
18 |
19 | do {
20 | s1 = (s1 + buf[pos++]) |0;
21 | s2 = (s2 + s1) |0;
22 | } while (--n);
23 |
24 | s1 %= 65521;
25 | s2 %= 65521;
26 | }
27 |
28 | return (s1 | (s2 << 16)) |0;
29 | }
30 |
31 |
32 | module.exports = adler32;
33 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/bindings/_delegates/zlib/pako/lib/zlib/constants.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 |
3 | /* Allowed flush values; see deflate() and inflate() below for details */
4 | Z_NO_FLUSH: 0,
5 | Z_PARTIAL_FLUSH: 1,
6 | Z_SYNC_FLUSH: 2,
7 | Z_FULL_FLUSH: 3,
8 | Z_FINISH: 4,
9 | Z_BLOCK: 5,
10 | Z_TREES: 6,
11 |
12 | /* Return codes for the compression/decompression functions. Negative values
13 | * are errors, positive values are used for special but normal events.
14 | */
15 | Z_OK: 0,
16 | Z_STREAM_END: 1,
17 | Z_NEED_DICT: 2,
18 | Z_ERRNO: -1,
19 | Z_STREAM_ERROR: -2,
20 | Z_DATA_ERROR: -3,
21 | //Z_MEM_ERROR: -4,
22 | Z_BUF_ERROR: -5,
23 | //Z_VERSION_ERROR: -6,
24 |
25 | /* compression levels */
26 | Z_NO_COMPRESSION: 0,
27 | Z_BEST_SPEED: 1,
28 | Z_BEST_COMPRESSION: 9,
29 | Z_DEFAULT_COMPRESSION: -1,
30 |
31 |
32 | Z_FILTERED: 1,
33 | Z_HUFFMAN_ONLY: 2,
34 | Z_RLE: 3,
35 | Z_FIXED: 4,
36 | Z_DEFAULT_STRATEGY: 0,
37 |
38 | /* Possible values of the data_type field (though see inflate()) */
39 | Z_BINARY: 0,
40 | Z_TEXT: 1,
41 | //Z_ASCII: 1, // = Z_TEXT (deprecated)
42 | Z_UNKNOWN: 2,
43 |
44 | /* The deflate compression method */
45 | Z_DEFLATED: 8
46 | //Z_NULL: null // Use -1 or null inline, depending on var type
47 | };
48 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/bindings/_delegates/zlib/pako/lib/zlib/crc32.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | // Note: we can't get significant speed boost here.
4 | // So write code to minimize size - no pregenerated tables
5 | // and array tools dependencies.
6 |
7 |
8 | // Use ordinary array, since untyped makes no boost here
9 | function makeTable() {
10 | var c, table = [];
11 |
12 | for (var n =0; n < 256; n++) {
13 | c = n;
14 | for (var k =0; k < 8; k++) {
15 | c = ((c&1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));
16 | }
17 | table[n] = c;
18 | }
19 |
20 | return table;
21 | }
22 |
23 | // Create table on load. Just 255 signed longs. Not a problem.
24 | var crcTable = makeTable();
25 |
26 |
27 | function crc32(crc, buf, len, pos) {
28 | var t = crcTable,
29 | end = pos + len;
30 |
31 | crc = crc ^ (-1);
32 |
33 | for (var i = pos; i < end; i++) {
34 | crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];
35 | }
36 |
37 | return (crc ^ (-1)); // >>> 0;
38 | }
39 |
40 |
41 | module.exports = crc32;
42 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/bindings/_delegates/zlib/pako/lib/zlib/gzheader.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 |
4 | function GZheader() {
5 | /* true if compressed data believed to be text */
6 | this.text = 0;
7 | /* modification time */
8 | this.time = 0;
9 | /* extra flags (not used when writing a gzip file) */
10 | this.xflags = 0;
11 | /* operating system */
12 | this.os = 0;
13 | /* pointer to extra field or Z_NULL if none */
14 | this.extra = null;
15 | /* extra field length (valid if extra != Z_NULL) */
16 | this.extra_len = 0; // Actually, we don't need it in JS,
17 | // but leave for few code modifications
18 |
19 | //
20 | // Setup limits is not necessary because in js we should not preallocate memory
21 | // for inflate use constant limit in 65536 bytes
22 | //
23 |
24 | /* space at extra (only when reading header) */
25 | // this.extra_max = 0;
26 | /* pointer to zero-terminated file name or Z_NULL */
27 | this.name = '';
28 | /* space at name (only when reading header) */
29 | // this.name_max = 0;
30 | /* pointer to zero-terminated comment or Z_NULL */
31 | this.comment = '';
32 | /* space at comment (only when reading header) */
33 | // this.comm_max = 0;
34 | /* true if there was or will be a header crc */
35 | this.hcrc = 0;
36 | /* true when done reading gzip header (not used when writing a gzip file) */
37 | this.done = false;
38 | }
39 |
40 | module.exports = GZheader;
41 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/bindings/_delegates/zlib/pako/lib/zlib/messages.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 | '2': 'need dictionary', /* Z_NEED_DICT 2 */
5 | '1': 'stream end', /* Z_STREAM_END 1 */
6 | '0': '', /* Z_OK 0 */
7 | '-1': 'file error', /* Z_ERRNO (-1) */
8 | '-2': 'stream error', /* Z_STREAM_ERROR (-2) */
9 | '-3': 'data error', /* Z_DATA_ERROR (-3) */
10 | '-4': 'insufficient memory', /* Z_MEM_ERROR (-4) */
11 | '-5': 'buffer error', /* Z_BUF_ERROR (-5) */
12 | '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */
13 | };
14 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/bindings/_delegates/zlib/pako/lib/zlib/zstream.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 |
4 | function ZStream() {
5 | /* next input byte */
6 | this.input = null; // JS specific, because we have no pointers
7 | this.next_in = 0;
8 | /* number of bytes available at input */
9 | this.avail_in = 0;
10 | /* total number of input bytes read so far */
11 | this.total_in = 0;
12 | /* next output byte should be put there */
13 | this.output = null; // JS specific, because we have no pointers
14 | this.next_out = 0;
15 | /* remaining free space at output */
16 | this.avail_out = 0;
17 | /* total number of bytes output so far */
18 | this.total_out = 0;
19 | /* last error message, NULL if no error */
20 | this.msg = ''/*Z_NULL*/;
21 | /* not visible by applications */
22 | this.state = null;
23 | /* best guess about the data type: binary or text */
24 | this.data_type = 2/*Z_UNKNOWN*/;
25 | /* adler32 value of the uncompressed data */
26 | this.adler = 0;
27 | }
28 |
29 | module.exports = ZStream;
30 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/bindings/buffer.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2016 OffGrid Networks
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | var Buffer = require('buffer');
18 |
19 | exports.compare = Buffer.compare;
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/bindings/contextify.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2016 OffGrid Networks
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | "use strict";
18 | var path = require('path');
19 |
20 | function ContextifyScript(script, options) {
21 |
22 | this._script = script;
23 | options = options || {};
24 |
25 | if (options.filename)
26 | this._filename = options.filename.replace(process.execPath, "");
27 |
28 | // this._filename = path.basename(options.filename)
29 | else
30 | {
31 | var i = script.indexOf("//# sourceURL=");
32 | if ( i>= 0)
33 | {
34 | i = i + 14;
35 | var i1 = script.indexOf("\n", i);
36 | if (i1 == -1)
37 | i1 = script.length;
38 | this._filename = script.substr(i, i1-i);
39 | this._filename = path.basename(this._filename.replace("});",""));
40 | }
41 | else
42 | this._filename = "";
43 | }
44 |
45 | /*
46 |
47 | var displayErrors = options.displayErrors || false;
48 |
49 | try {
50 | this._script = document.createElement('script');
51 | this._script.type = 'text/javascript';
52 | this._script.appendChild(document.createTextNode(script));
53 |
54 | } catch (e) {
55 | if (displayErrors)
56 | console.log(e.message + " - " + filename);
57 | }*/
58 | }
59 |
60 | ContextifyScript.prototype.runInThisContext = function() {
61 | return process.evalSync(this._script, this._filename);
62 | }
63 |
64 | ContextifyScript.prototype.runInContext = function(context) {
65 | return process.evalSync(this._script, this._filename);
66 |
67 | // document.head.appendChild(this._script);
68 | }
69 |
70 | ContextifyScript.prototype.runInNewContext = function() {
71 | return process.evalSync(this._script, this._filename);
72 | // document.head.appendChild(this._script);
73 | }
74 |
75 | module.exports.isContext = function isContext(ctx) {
76 | return (global.obj = ctx);
77 | }
78 |
79 | module.exports.makeContext = function makeContext(ctx) {
80 | global.obj = new {};
81 | global.obj._hiddenContextify = ctx;
82 | return global.obj;
83 | }
84 |
85 | module.exports.ContextifyScript = ContextifyScript;
86 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/bindings/fs_event_wrap.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2016 OffGrid Networks. Portions Copyright 2014 Red Hat, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | function FSEvent() {
18 | }
19 |
20 | module.exports.FSEvent = FSEvent;
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/bindings/handle_wrap.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2016 OffGrid Networks. Portions Copyright 2014 Red Hat, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | function Handle(handle) {
18 | this._handle = handle;
19 | }
20 |
21 | Handle.prototype.ref = function() {
22 | };
23 |
24 | Handle.prototype.unref = function() {
25 | };
26 |
27 | Handle.prototype.close = function(callback) {
28 | if (this._handle) {
29 | this._handle.close();
30 | this._handle = null;
31 | }
32 | if ( callback ) {
33 | process.nextTick(callback.bind(this));
34 | }
35 | };
36 |
37 | module.exports.Handle = Handle;
38 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/bindings/natives.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2016 OffGrid Networks. Portions Copyright Red Hat, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | "use strict";
18 |
19 | var getSource = require('native_module').getSource;
20 |
21 | var source = {};
22 |
23 | /* BUILT-IN UNMODIFIED NODE.JS SOURCES */
24 | [ '_debugger',
25 | '_http_agent',
26 | '_http_client',
27 | '_http_common',
28 | '_http_incoming',
29 | '_http_outgoing',
30 | '_http_server',
31 | '_linklist',
32 | '_stream_duplex',
33 | '_stream_passthrough',
34 | '_stream_readable',
35 | '_stream_transform',
36 | '_stream_writable',
37 | '_tls_common',
38 | '_tls_legacy',
39 | '_tls_wrap',
40 | 'assert',
41 | /* 'buffer', ** SEE REPLACEMENT SECTION BELOW ** */
42 | 'child_process',
43 | 'cluster',
44 | 'console',
45 | 'constants',
46 | /* 'crypto', ** SEE REPLACEMENT SECTION BELOW ** */
47 | 'dgram',
48 | 'dns', /** HANDLED BY cares_wrap ** */
49 | 'domain',
50 | 'events',
51 | 'freelist',
52 | 'fs',
53 | 'http',
54 | 'https',
55 | 'module',
56 | 'net',
57 | 'os',
58 | 'path',
59 | 'punycode',
60 | 'querystring',
61 | 'readline',
62 | 'repl',
63 | 'smalloc',
64 | 'stream',
65 | 'string_decoder',
66 | 'sys',
67 | 'timers',
68 | 'tls',
69 | 'tty',
70 | 'url',
71 | 'util',
72 | 'vm',
73 | 'zlib',
74 | ].forEach( function(name) {
75 | source[name] = getSource('lib/node/' + name);
76 | });
77 |
78 | /* CUSTOM NODE.JS API REPLACEMENTS*/
79 | [
80 | 'buffer', /* 'dns', alternative to cares_wrap */ 'crypto'
81 | ].forEach(function (name) {
82 | source[name] = getSource('lib/builtin-replacements/' + name );
83 | });
84 |
85 | /* CUSTOM NODE.JS API ADDITIONS*/
86 | [
87 | 'asap',
88 | 'promise',
89 | ].forEach(function (name) {
90 | source[name] = getSource('lib/builtin-additions/' + name );
91 | });
92 |
93 | /* CUSTOM NODE.JS API ADDITIONS*/
94 | [
95 | 'electro', 'electro_protocol', 'platform'
96 | ].forEach(function (name) {
97 | source[name] = getSource('lib/builtin-nodekit/' + name );
98 | });
99 |
100 | source['electron'] = source['electro'];
101 |
102 | /* CUSTOM NODE.JS API ADDITIONS*/
103 | source["_third_party_main"] = getSource('lib/_nodekit_third_party_main.js');
104 |
105 | source.config = "\\gyp\n{}";
106 |
107 |
108 | module.exports = source;
109 |
110 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/bindings/os.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2016 OffGrid Networks. Portions copyright (c) 2014 Drew Young
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | module.exports.endianness = function () { return 'LE' };
18 |
19 | module.exports.hostname = function () {
20 | if (typeof location !== 'undefined') {
21 | return location.hostname
22 | }
23 | else return '';
24 | };
25 |
26 | module.exports.loadavg = function () { return [] };
27 |
28 | module.exports.uptime = function () { return 0 };
29 |
30 | module.exports.freemem = function () {
31 | return Number.MAX_VALUE;
32 | };
33 |
34 | module.exports.totalmem = function () {
35 | return Number.MAX_VALUE;
36 | };
37 |
38 | module.exports.cpus = function () { return [] };
39 |
40 | module.exports.type = function () { return 'Browser' };
41 |
42 | module.exports.release = function () {
43 | if (typeof navigator !== 'undefined') {
44 | return navigator.appVersion;
45 | }
46 | return '';
47 | };
48 |
49 | module.exports.networkInterfaces
50 | = exports.getInterfaceAddresses
51 | = function () { return { lo0:
52 | [ { address: '::1',
53 | netmask: 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff',
54 | family: 'IPv6',
55 | mac: '00:00:00:00:00:00',
56 | scopeid: 0,
57 | internal: true },
58 | { address: '127.0.0.1',
59 | netmask: '255.0.0.0',
60 | family: 'IPv4',
61 | mac: '00:00:00:00:00:00',
62 | internal: true },
63 | { address: 'fe80::1',
64 | netmask: 'ffff:ffff:ffff:ffff::',
65 | family: 'IPv6',
66 | mac: '00:00:00:00:00:00',
67 | scopeid: 1,
68 | internal: true } ],
69 | en0:
70 | [ { address: 'fe80::4ad7:5ff:fee1:48b9',
71 | netmask: 'ffff:ffff:ffff:ffff::',
72 | family: 'IPv6',
73 | mac: '48:d7:05:e1:48:b9',
74 | scopeid: 4,
75 | internal: false },
76 | { address: '10.26.12.202',
77 | netmask: '255.255.192.0',
78 | family: 'IPv4',
79 | mac: '48:d7:05:e1:48:b9',
80 | internal: false } ],
81 | awdl0:
82 | [ { address: 'fe80::7c57:d8ff:fe31:4c82',
83 | netmask: 'ffff:ffff:ffff:ffff::',
84 | family: 'IPv6',
85 | mac: '7e:57:d8:31:4c:82',
86 | scopeid: 7,
87 | internal: false } ] };
88 |
89 | };
90 |
91 | module.exports.arch = function () { return 'javascript' };
92 |
93 | module.exports.platform = function () { return 'browser' };
94 |
95 | module.exports.tmpdir = exports.tmpDir = function () {
96 | return '/tmp';
97 | };
98 |
99 | module.exports.EOL = '\n';
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/bindings/pipe_wrap.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2016 OffGrid Networks
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | "use strict";
18 |
19 | var util = require('util');
20 | var Stream = process.binding('stream_wrap').Stream;
21 | var TCP = process.binding( 'tcp_wrap').TCP;
22 |
23 | function Pipe(ipc) {
24 | this._ipc = ipc;
25 | this._pipe = {};
26 | Stream.call( this, this._pipe );
27 | }
28 |
29 | util.inherits(Pipe, Stream);
30 |
31 | Pipe.prototype._onDataWithHandle = function(result) {
32 | return new Error("Not Implemented");
33 | }
34 |
35 | Pipe.prototype.closeDownstream = function() {
36 | return new Error("Not Implemented");
37 | }
38 |
39 | Pipe.prototype._create = function(downstreamFd) {
40 | return new Error("Not Implemented");
41 | }
42 |
43 | Pipe.prototype.bind = function() {
44 | return new Error("Not Implemented");
45 | };
46 |
47 | Pipe.prototype.listen = function() {
48 | return new Error("Not Implemented");
49 | };
50 |
51 | Pipe.prototype.connect = function() {
52 | return new Error("Not Implemented");
53 | };
54 |
55 | Pipe.prototype.open = function(fd) {
56 | return new Error("Not Implemented");
57 | };
58 |
59 | Pipe.prototype.writeUtf8String = function(req,data,handle) {
60 | return new Error("Not Implemented");
61 | };
62 |
63 | module.exports.Pipe = Pipe;
64 |
65 | module.exports.PipeConnectWrap = function PipeConnectWrap(){};
66 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/bindings/process_wrap.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2016 OffGrid Networks
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | function Process() {
18 | this._process = {};
19 | }
20 |
21 | Object.defineProperty( Process.prototype, 'pid', {
22 | get: function() {
23 | return new Error("Not Implemented");
24 | }
25 | });
26 |
27 | Process.prototype._onExit = function(result) {
28 | var exitCode = undefined;
29 | var signal =undefined;
30 | this.onexit( exitCode, signal );
31 | }
32 |
33 | Process.prototype.spawn = function(options) {
34 | return new Error("Not Implemented");
35 | }
36 |
37 | Process.prototype.close = function() {
38 | return new Error("Not Implemented");
39 | }
40 |
41 | Process.prototype.kill = function(signal) {
42 | return new Error("Not Implemented");
43 | }
44 |
45 | module.exports.Process = Process;
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/bindings/signal_wrap.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2016 OffGrid Networks
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | var util = require('util');
18 | var Handle = process.binding('handle_wrap').Handle;
19 |
20 | function Signal() {
21 | this._signal = {};
22 | Handle.call( this, this._signal );
23 | }
24 |
25 | util.inherits( Signal, Handle );
26 |
27 | Signal.prototype.start = function(signum) {
28 | }
29 |
30 | module.exports.Signal = Signal;
31 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/bindings/smalloc.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2016 OffGrid Networks
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | module.exports.alloc = function (obj, len, type) {
18 | return obj;
19 | }
20 |
21 | module.exports.truncate = function(obj, len) {
22 | return obj;
23 | }
24 |
25 | module.exports.sliceOnto = function (src, dest, start, end) {
26 |
27 | for (var i = start; i < end; i++) {
28 | dest[i] = src[i];
29 | }
30 |
31 | return src;
32 | }
33 |
34 | module.exports.kMaxLength = 64 * 1024;
35 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/bindings/spawn_sync.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2016 OffGrid Networks
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | console.log("ERROR: spawn not yet implemented");
18 |
19 | function spawn(options) {
20 | var result = {
21 | pid: null,
22 | output: [
23 | undefined,
24 | null,
25 | null,
26 | ],
27 | status: null,
28 | signal: undefined,
29 | error: undefined,
30 | };
31 |
32 | Object.defineProperty( result, 'stdout', {
33 | get: function() {
34 | return new Error("Not Implemented");
35 | },
36 | enumerable: true,
37 | });
38 |
39 | Object.defineProperty( result, 'stderr', {
40 | get: function() {
41 | return new Error("Not Implemented");
42 | },
43 | enumerable: true,
44 | });
45 |
46 | return result;
47 | }
48 |
49 | module.exports.spawn = spawn;
50 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/bindings/stream_wrap.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2016 OffGrid Networks; Portions Copyright 2014 Red Hat
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | "use strict";
18 |
19 | var _delegate = require('./_delegates/stream/_stream_wrap.js');
20 |
21 | exports.Stream = _delegate.Stream;
22 | exports.ShutdownWrap = function ShutdownWrap(){};
23 | exports.WriteWrap = function WriteWrap(){};
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/bindings/tcp_wrap.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2016 OffGrid Networks; Portions Copyright 2014 Red Hat
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | "use strict";
18 |
19 | var _delegate = require('./_delegates/tcp/_tcp_wrap.js');
20 |
21 | exports.TCP = _delegate.TCP;
22 | exports.TCPConnectWrap = function TCPConnectWrap(){};
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/bindings/timer_wrap.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2016 OffGrid Networks. Portions Copyright 2014 Red Hat, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | this.global = this;
17 |
18 | var NativeTimer = require('platform').Timer;
19 | var util = require('util');
20 | var Handle = process.binding('handle_wrap').Handle;
21 |
22 | var kOnTimeout = 0;
23 |
24 | function invokeTimeoutHandler() {
25 | return this[kOnTimeout].apply(this, arguments);
26 | }
27 |
28 | function Timer() {
29 | this._timer = new NativeTimer();
30 | this._timer.setOnTimeout(invokeTimeoutHandler.bind(this));
31 | Handle.call( this, this._timer );
32 | }
33 | util.inherits( Timer, Handle );
34 |
35 | Timer.kOnTimeout = kOnTimeout;
36 |
37 | Timer.prototype.start = function(msec, repeat) {
38 | this._timer.start(msec, repeat);
39 | }
40 |
41 | Timer.prototype.stop = function() {
42 | this._timer.stop();
43 | this._timer.dispose();
44 | }
45 |
46 | Timer.now = function() { var x = new Date().getTime(); return x }
47 |
48 | module.exports.Timer = Timer;
49 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/bindings/tty_wrap.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2016 OffGrid Networks. Portions Copyright 2014 Red Hat, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | "use strict";
18 |
19 | var util = require('util');
20 | //var Stream = process.binding('stream_wrap').Stream;
21 |
22 | function guessHandleType(fd) {
23 | if ( fd <= 2 ) {
24 | // if ( process.isatty( fd ) ) {
25 | return 'TTY';
26 | // }
27 | // return 'PIPE';
28 | }
29 |
30 | return 'FILE';
31 | }
32 |
33 | function isTTY(fd) {
34 | return false;
35 | return guessHandleType(fd) == 'TTY';
36 | }
37 |
38 | function TTY(fd, readable) {
39 | }
40 |
41 | //util.inherits(TTY,Stream);
42 |
43 | TTY.prototype.getWindowSize = function(out) {
44 | out[0] = 80;
45 | out[1] = 25;
46 | }
47 |
48 | TTY.prototype.setRawMode = function(rawMode) {
49 | this._stream.setRawMode( rawMode );
50 | }
51 |
52 | TTY.prototype.writeUtf8String = function(req,data) {
53 | io.nodekit.platform.console.log("TTY:" + data);
54 | req.oncomplete(0, this, req);
55 | };
56 |
57 | module.exports.guessHandleType = guessHandleType;
58 | module.exports.isTTY = isTTY;
59 | module.exports.TTY = TTY;
60 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/bindings/udp_wrap.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2016 OffGrid Networks
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | var _delegate = require('./_delegates/udp/_udp_wrap.js');
18 |
19 | exports.UDP = _delegate.UDP;
20 | exports.SendWrap = function SendWrap(){};
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/bindings/uv.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2016 OffGrid Networks; portions Copyright 2014 Red Hat
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | "use strict";
18 |
19 | var UV = {};
20 |
21 | UV.errname = function(err) {
22 | if ( err == UV.EAI_NODATA ) {
23 | return "EAI_NODATA";
24 | }
25 | }
26 |
27 | UV.UV_EOF = -1;
28 |
29 | UV.UV_EAI_ADDRFAMILY = -3000;
30 | UV.UV_EAI_AGAIN = -3001;
31 | UV.UV_EAI_BADFLAGS = -3002;
32 | UV.UV_EAI_CANCELED = -3003;
33 | UV.UV_EAI_FAIL = -3004;
34 | UV.UV_EAI_FAMILY = -3005;
35 | UV.UV_EAI_MEMORY = -3006;
36 | UV.UV_EAI_NODATA = -3007;
37 | UV.UV_EAI_NONAME = -3008;
38 | UV.UV_EAI_OVERFLOW = -3009;
39 | UV.UV_EAI_SERVICE = -3010;
40 | UV.UV_EAI_SOCKTYPE = -3011;
41 | UV.UV_EAI_BADHINTS = -3013;
42 | UV.UV_EAI_PROTOCOL = -3014;
43 |
44 | UV.UV_EAGAIN = -4088;
45 | UV.UV_EMFILE = -4066;
46 | UV.UV_ENFILE = -4061;
47 | UV.UV_ENOENT = -4058;
48 |
49 | module.exports = UV;
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/bindings/v8.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2016 OffGrid Networks
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | "use strict";
18 |
19 | var V8 = {};
20 |
21 | V8.getHeapStatistics = function() {
22 | return [];
23 | }
24 |
25 | module.exports = V8;
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/builtin-nodekit/electro.js:
--------------------------------------------------------------------------------
1 | /*
2 | * nodekit.io
3 | *
4 | * Copyright (c) 2016 OffGrid Networks. All Rights Reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | var electro = {
20 | 'app': io.nodekit.electro.app,
21 | 'autoUpdater': "not implemented",
22 | 'BrowserWindow': io.nodekit.electro.BrowserWindow,
23 | 'contentTracing': "not implemented",
24 | 'dialog': io.nodekit.electro.dialog,
25 | 'ipcMain': io.nodekit.electro.ipcMain,
26 | 'Menu': io.nodekit.electro.Menu,
27 | 'MenuItem': io.nodekit.electro.MenuItem,
28 | 'powerMonitor': "not implemented",
29 | 'powerSaveBlocker': "not implemented",
30 | 'protocol': io.nodekit.electro.protocol || {},
31 | 'session': "not implemented",
32 | 'WebContents': io.nodekit.electro.WebContents,
33 | 'Tray': "not implemented"
34 | }
35 |
36 | electro.protocol.createServer = require('electro_protocol').createServer
37 |
38 | module.exports = electro
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/builtin-nodekit/platform.js:
--------------------------------------------------------------------------------
1 | /*
2 | * nodekit.io
3 | *
4 | * Copyright (c) 2016 OffGrid Networks. All Rights Reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 |
20 | var platform = {
21 | 'console': io.nodekit.platform.console,
22 | 'crypto': io.nodekit.platform.crypto,
23 | 'fs': io.nodekit.platform.fs,
24 | 'process': io.nodekit.platform.process,
25 | 'TCP': io.nodekit.platform.TCP,
26 | 'Timer': io.nodekit.platform.Timer,
27 | 'UDP': io.nodekit.platform.UDP
28 | }
29 |
30 | module.exports = platform
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/builtin-replacements/timers.js:
--------------------------------------------------------------------------------
1 | /*
2 | * nodekit.io
3 | *
4 | * Copyright (c) 2016 OffGrid Networks. All Rights Reserved.
5 | * Portions Copyright © 2012 J. Ryan Stinnett
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 |
20 | this.global = this;
21 | var nextTick = process.nextTick;
22 | var apply = Function.prototype.apply;
23 | var slice = Array.prototype.slice;
24 | var immediateIds = {};
25 | var nextImmediateId = 0;
26 | var nativeTimeout = io.nodekit.platform.process.setTimeout;
27 |
28 | exports.setTimeout = function() {
29 |
30 | return new Timeout(apply.call(nativeTimeout, global, arguments), clearTimeout);
31 | };
32 | exports.setInterval2 = function() {
33 | return new Timeout(apply.call(setInterval, global, arguments), clearInterval);
34 | };
35 | exports.clearTimeout =
36 | exports.clearInterval = function(timeout) { if (timeout) timeout.close(); };
37 |
38 | function Timeout(id, clearFn) {
39 | this._id = id;
40 | this._clearFn = clearFn;
41 | }
42 | Timeout.prototype.unref = Timeout.prototype.ref = function() {};
43 | Timeout.prototype.close = function() {
44 | this._clearFn.call(global, this._id);
45 | };
46 |
47 | exports.enroll = function(item, msecs) {
48 | clearTimeout(item._idleTimeoutId);
49 | item._idleTimeout = msecs;
50 | };
51 |
52 | exports.unenroll = function(item) {
53 | clearTimeout(item._idleTimeoutId);
54 | item._idleTimeout = -1;
55 | };
56 |
57 | exports._unrefActive = exports.active = function(item) {
58 | clearTimeout(item._idleTimeoutId);
59 |
60 | var msecs = item._idleTimeout;
61 | if (msecs >= 0) {
62 | item._idleTimeoutId = nativeTimeout(function onTimeout() {
63 | if (item._onTimeout)
64 | item._onTimeout();
65 | }, msecs);
66 | }
67 | };
68 |
69 | exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) {
70 | var id = nextImmediateId++;
71 | var args = arguments.length < 2 ? false : slice.call(arguments, 1);
72 |
73 | immediateIds[id] = true;
74 |
75 | nextTick(function onNextTick() {
76 | if (immediateIds[id]) {
77 | if (args) {
78 | fn.apply(null, args);
79 | } else {
80 | fn.call(null);
81 | }
82 | exports.clearImmediate(id);
83 | }
84 | });
85 |
86 | return id;
87 | };
88 |
89 | exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) {
90 | delete immediateIds[id];
91 | };
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/node/_linklist.js:
--------------------------------------------------------------------------------
1 | // Copyright Joyent, Inc. and other Node contributors.
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a
4 | // copy of this software and associated documentation files (the
5 | // "Software"), to deal in the Software without restriction, including
6 | // without limitation the rights to use, copy, modify, merge, publish,
7 | // distribute, sublicense, and/or sell copies of the Software, and to permit
8 | // persons to whom the Software is furnished to do so, subject to the
9 | // following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included
12 | // in all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 | // USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
22 | function init(list) {
23 | list._idleNext = list;
24 | list._idlePrev = list;
25 | }
26 | exports.init = init;
27 |
28 |
29 | // show the most idle item
30 | function peek(list) {
31 | if (list._idlePrev == list) return null;
32 | return list._idlePrev;
33 | }
34 | exports.peek = peek;
35 |
36 |
37 | // remove the most idle item from the list
38 | function shift(list) {
39 | var first = list._idlePrev;
40 | remove(first);
41 | return first;
42 | }
43 | exports.shift = shift;
44 |
45 |
46 | // remove a item from its list
47 | function remove(item) {
48 | if (item._idleNext) {
49 | item._idleNext._idlePrev = item._idlePrev;
50 | }
51 |
52 | if (item._idlePrev) {
53 | item._idlePrev._idleNext = item._idleNext;
54 | }
55 |
56 | item._idleNext = null;
57 | item._idlePrev = null;
58 | }
59 | exports.remove = remove;
60 |
61 |
62 | // remove a item from its list and place at the end.
63 | function append(list, item) {
64 | remove(item);
65 | item._idleNext = list._idleNext;
66 | list._idleNext._idlePrev = item;
67 | item._idlePrev = list;
68 | list._idleNext = item;
69 | }
70 | exports.append = append;
71 |
72 |
73 | function isEmpty(list) {
74 | return list._idleNext === list;
75 | }
76 | exports.isEmpty = isEmpty;
77 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/node/_stream_duplex.js:
--------------------------------------------------------------------------------
1 | // Copyright Joyent, Inc. and other Node contributors.
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a
4 | // copy of this software and associated documentation files (the
5 | // "Software"), to deal in the Software without restriction, including
6 | // without limitation the rights to use, copy, modify, merge, publish,
7 | // distribute, sublicense, and/or sell copies of the Software, and to permit
8 | // persons to whom the Software is furnished to do so, subject to the
9 | // following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included
12 | // in all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 | // USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
22 | // a duplex stream is just a stream that is both readable and writable.
23 | // Since JS doesn't have multiple prototypal inheritance, this class
24 | // prototypally inherits from Readable, and then parasitically from
25 | // Writable.
26 |
27 | module.exports = Duplex;
28 | var util = require('util');
29 | var Readable = require('_stream_readable');
30 | var Writable = require('_stream_writable');
31 |
32 | util.inherits(Duplex, Readable);
33 |
34 | var keys = Object.keys(Writable.prototype);
35 | for (var v = 0; v < keys.length; v++) {
36 | var method = keys[v];
37 | if (!Duplex.prototype[method])
38 | Duplex.prototype[method] = Writable.prototype[method];
39 | }
40 |
41 | function Duplex(options) {
42 | if (!(this instanceof Duplex))
43 | return new Duplex(options);
44 |
45 | Readable.call(this, options);
46 | Writable.call(this, options);
47 |
48 | if (options && options.readable === false)
49 | this.readable = false;
50 |
51 | if (options && options.writable === false)
52 | this.writable = false;
53 |
54 | this.allowHalfOpen = true;
55 | if (options && options.allowHalfOpen === false)
56 | this.allowHalfOpen = false;
57 |
58 | this.once('end', onend);
59 | }
60 |
61 | // the no-half-open enforcer
62 | function onend() {
63 | // if we allow half-open state, or if the writable side ended,
64 | // then we're ok.
65 | if (this.allowHalfOpen || this._writableState.ended)
66 | return;
67 |
68 | // no more data can be written.
69 | // But allow more writes to happen in this tick.
70 | process.nextTick(this.end.bind(this));
71 | }
72 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/node/_stream_passthrough.js:
--------------------------------------------------------------------------------
1 | // Copyright Joyent, Inc. and other Node contributors.
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a
4 | // copy of this software and associated documentation files (the
5 | // "Software"), to deal in the Software without restriction, including
6 | // without limitation the rights to use, copy, modify, merge, publish,
7 | // distribute, sublicense, and/or sell copies of the Software, and to permit
8 | // persons to whom the Software is furnished to do so, subject to the
9 | // following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included
12 | // in all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 | // USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
22 | // a passthrough stream.
23 | // basically just the most minimal sort of Transform stream.
24 | // Every written chunk gets output as-is.
25 |
26 | module.exports = PassThrough;
27 |
28 | var Transform = require('_stream_transform');
29 | var util = require('util');
30 | util.inherits(PassThrough, Transform);
31 |
32 | function PassThrough(options) {
33 | if (!(this instanceof PassThrough))
34 | return new PassThrough(options);
35 |
36 | Transform.call(this, options);
37 | }
38 |
39 | PassThrough.prototype._transform = function(chunk, encoding, cb) {
40 | cb(null, chunk);
41 | };
42 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/node/console.js:
--------------------------------------------------------------------------------
1 | // Copyright Joyent, Inc. and other Node contributors.
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a
4 | // copy of this software and associated documentation files (the
5 | // "Software"), to deal in the Software without restriction, including
6 | // without limitation the rights to use, copy, modify, merge, publish,
7 | // distribute, sublicense, and/or sell copies of the Software, and to permit
8 | // persons to whom the Software is furnished to do so, subject to the
9 | // following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included
12 | // in all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 | // USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
22 | var util = require('util');
23 |
24 | function Console(stdout, stderr) {
25 | if (!(this instanceof Console)) {
26 | return new Console(stdout, stderr);
27 | }
28 | if (!stdout || !util.isFunction(stdout.write)) {
29 | throw new TypeError('Console expects a writable stream instance');
30 | }
31 | if (!stderr) {
32 | stderr = stdout;
33 | }
34 | var prop = {
35 | writable: true,
36 | enumerable: false,
37 | configurable: true
38 | };
39 | prop.value = stdout;
40 | Object.defineProperty(this, '_stdout', prop);
41 | prop.value = stderr;
42 | Object.defineProperty(this, '_stderr', prop);
43 | prop.value = Object.create(null);
44 | Object.defineProperty(this, '_times', prop);
45 |
46 | // bind the prototype functions to this Console instance
47 | var keys = Object.keys(Console.prototype);
48 | for (var v = 0; v < keys.length; v++) {
49 | var k = keys[v];
50 | this[k] = this[k].bind(this);
51 | }
52 | }
53 |
54 | Console.prototype.log = function() {
55 | this._stdout.write(util.format.apply(this, arguments) + '\n');
56 | };
57 |
58 |
59 | Console.prototype.info = Console.prototype.log;
60 |
61 |
62 | Console.prototype.warn = function() {
63 | this._stderr.write(util.format.apply(this, arguments) + '\n');
64 | };
65 |
66 |
67 | Console.prototype.error = Console.prototype.warn;
68 |
69 |
70 | Console.prototype.dir = function(object, options) {
71 | this._stdout.write(util.inspect(object, util._extend({
72 | customInspect: false
73 | }, options)) + '\n');
74 | };
75 |
76 |
77 | Console.prototype.time = function(label) {
78 | this._times[label] = Date.now();
79 | };
80 |
81 |
82 | Console.prototype.timeEnd = function(label) {
83 | var time = this._times[label];
84 | if (!time) {
85 | throw new Error('No such label: ' + label);
86 | }
87 | var duration = Date.now() - time;
88 | this.log('%s: %dms', label, duration);
89 | };
90 |
91 |
92 | Console.prototype.trace = function trace() {
93 | // TODO probably can to do this better with V8's debug object once that is
94 | // exposed.
95 | var err = new Error;
96 | err.name = 'Trace';
97 | err.message = util.format.apply(this, arguments);
98 | Error.captureStackTrace(err, trace);
99 | this.error(err.stack);
100 | };
101 |
102 |
103 | Console.prototype.assert = function(expression) {
104 | if (!expression) {
105 | var arr = Array.prototype.slice.call(arguments, 1);
106 | require('assert').ok(false, util.format.apply(this, arr));
107 | }
108 | };
109 |
110 |
111 | module.exports = new Console(process.stdout, process.stderr);
112 | module.exports.Console = Console;
113 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/node/constants.js:
--------------------------------------------------------------------------------
1 | // Copyright Joyent, Inc. and other Node contributors.
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a
4 | // copy of this software and associated documentation files (the
5 | // "Software"), to deal in the Software without restriction, including
6 | // without limitation the rights to use, copy, modify, merge, publish,
7 | // distribute, sublicense, and/or sell copies of the Software, and to permit
8 | // persons to whom the Software is furnished to do so, subject to the
9 | // following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included
12 | // in all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 | // USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
22 | module.exports = process.binding('constants');
23 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/node/freelist.js:
--------------------------------------------------------------------------------
1 | // Copyright Joyent, Inc. and other Node contributors.
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a
4 | // copy of this software and associated documentation files (the
5 | // "Software"), to deal in the Software without restriction, including
6 | // without limitation the rights to use, copy, modify, merge, publish,
7 | // distribute, sublicense, and/or sell copies of the Software, and to permit
8 | // persons to whom the Software is furnished to do so, subject to the
9 | // following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included
12 | // in all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 | // USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
22 | // This is a free list to avoid creating so many of the same object.
23 | exports.FreeList = function(name, max, constructor) {
24 | this.name = name;
25 | this.constructor = constructor;
26 | this.max = max;
27 | this.list = [];
28 | };
29 |
30 |
31 | exports.FreeList.prototype.alloc = function() {
32 | //debug("alloc " + this.name + " " + this.list.length);
33 | return this.list.length ? this.list.shift() :
34 | this.constructor.apply(this, arguments);
35 | };
36 |
37 |
38 | exports.FreeList.prototype.free = function(obj) {
39 | //debug("free " + this.name + " " + this.list.length);
40 | if (this.list.length < this.max) {
41 | this.list.push(obj);
42 | return true;
43 | }
44 | return false;
45 | };
46 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/node/http.js:
--------------------------------------------------------------------------------
1 | // Copyright Joyent, Inc. and other Node contributors.
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a
4 | // copy of this software and associated documentation files (the
5 | // "Software"), to deal in the Software without restriction, including
6 | // without limitation the rights to use, copy, modify, merge, publish,
7 | // distribute, sublicense, and/or sell copies of the Software, and to permit
8 | // persons to whom the Software is furnished to do so, subject to the
9 | // following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included
12 | // in all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 | // USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
22 | var util = require('util');
23 | var EventEmitter = require('events').EventEmitter;
24 |
25 |
26 | exports.IncomingMessage = require('_http_incoming').IncomingMessage;
27 |
28 |
29 | var common = require('_http_common');
30 | exports.METHODS = util._extend([], common.methods).sort();
31 |
32 |
33 | exports.OutgoingMessage = require('_http_outgoing').OutgoingMessage;
34 |
35 |
36 | var server = require('_http_server');
37 | exports.ServerResponse = server.ServerResponse;
38 | exports.STATUS_CODES = server.STATUS_CODES;
39 |
40 |
41 | var agent = require('_http_agent');
42 | var Agent = exports.Agent = agent.Agent;
43 | exports.globalAgent = agent.globalAgent;
44 |
45 | var client = require('_http_client');
46 | var ClientRequest = exports.ClientRequest = client.ClientRequest;
47 |
48 | exports.request = function(options, cb) {
49 | return new ClientRequest(options, cb);
50 | };
51 |
52 | exports.get = function(options, cb) {
53 | var req = exports.request(options, cb);
54 | req.end();
55 | return req;
56 | };
57 |
58 | exports._connectionListener = server._connectionListener;
59 | var Server = exports.Server = server.Server;
60 |
61 | exports.createServer = function(requestListener) {
62 | return new Server(requestListener);
63 | };
64 |
65 |
66 | // Legacy Interface
67 |
68 | function Client(port, host) {
69 | if (!(this instanceof Client)) return new Client(port, host);
70 | EventEmitter.call(this);
71 |
72 | host = host || 'localhost';
73 | port = port || 80;
74 | this.host = host;
75 | this.port = port;
76 | this.agent = new Agent({ host: host, port: port, maxSockets: 1 });
77 | }
78 | util.inherits(Client, EventEmitter);
79 | Client.prototype.request = function(method, path, headers) {
80 | var self = this;
81 | var options = {};
82 | options.host = self.host;
83 | options.port = self.port;
84 | if (method[0] === '/') {
85 | headers = path;
86 | path = method;
87 | method = 'GET';
88 | }
89 | options.method = method;
90 | options.path = path;
91 | options.headers = headers;
92 | options.agent = self.agent;
93 | var c = new ClientRequest(options);
94 | c.on('error', function(e) {
95 | self.emit('error', e);
96 | });
97 | // The old Client interface emitted 'end' on socket end.
98 | // This doesn't map to how we want things to operate in the future
99 | // but it will get removed when we remove this legacy interface.
100 | c.on('socket', function(s) {
101 | s.on('end', function() {
102 | if (self._decoder) {
103 | var ret = self._decoder.end();
104 | if (ret)
105 | self.emit('data', ret);
106 | }
107 | self.emit('end');
108 | });
109 | });
110 | return c;
111 | };
112 |
113 | exports.Client = util.deprecate(Client,
114 | 'http.Client will be removed soon. Do not use it.');
115 |
116 | exports.createClient = util.deprecate(function(port, host) {
117 | return new Client(port, host);
118 | }, 'http.createClient is deprecated. Use `http.request` instead.');
119 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/node/https.js:
--------------------------------------------------------------------------------
1 | // Copyright Joyent, Inc. and other Node contributors.
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a
4 | // copy of this software and associated documentation files (the
5 | // "Software"), to deal in the Software without restriction, including
6 | // without limitation the rights to use, copy, modify, merge, publish,
7 | // distribute, sublicense, and/or sell copies of the Software, and to permit
8 | // persons to whom the Software is furnished to do so, subject to the
9 | // following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included
12 | // in all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 | // USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
22 | var tls = require('tls');
23 | var url = require('url');
24 | var http = require('http');
25 | var util = require('util');
26 | var inherits = require('util').inherits;
27 | var debug = util.debuglog('https');
28 |
29 | function Server(opts, requestListener) {
30 | if (!(this instanceof Server)) return new Server(opts, requestListener);
31 |
32 | if (process.features.tls_npn && !opts.NPNProtocols) {
33 | opts.NPNProtocols = ['http/1.1', 'http/1.0'];
34 | }
35 |
36 | tls.Server.call(this, opts, http._connectionListener);
37 |
38 | this.httpAllowHalfOpen = false;
39 |
40 | if (requestListener) {
41 | this.addListener('request', requestListener);
42 | }
43 |
44 | this.addListener('clientError', function(err, conn) {
45 | conn.destroy();
46 | });
47 |
48 | this.timeout = 2 * 60 * 1000;
49 | }
50 | inherits(Server, tls.Server);
51 | exports.Server = Server;
52 |
53 | Server.prototype.setTimeout = http.Server.prototype.setTimeout;
54 |
55 | exports.createServer = function(opts, requestListener) {
56 | return new Server(opts, requestListener);
57 | };
58 |
59 |
60 | // HTTPS agents.
61 |
62 | function createConnection(port, host, options) {
63 | if (util.isObject(port)) {
64 | options = port;
65 | } else if (util.isObject(host)) {
66 | options = host;
67 | } else if (util.isObject(options)) {
68 | options = options;
69 | } else {
70 | options = {};
71 | }
72 |
73 | if (util.isNumber(port)) {
74 | options.port = port;
75 | }
76 |
77 | if (util.isString(host)) {
78 | options.host = host;
79 | }
80 |
81 | debug('createConnection', options);
82 | return tls.connect(options);
83 | }
84 |
85 |
86 | function Agent(options) {
87 | http.Agent.call(this, options);
88 | this.defaultPort = 443;
89 | this.protocol = 'https:';
90 | }
91 | inherits(Agent, http.Agent);
92 | Agent.prototype.createConnection = createConnection;
93 |
94 | Agent.prototype.getName = function(options) {
95 | var name = http.Agent.prototype.getName.call(this, options);
96 |
97 | name += ':';
98 | if (options.ca)
99 | name += options.ca;
100 |
101 | name += ':';
102 | if (options.cert)
103 | name += options.cert;
104 |
105 | name += ':';
106 | if (options.ciphers)
107 | name += options.ciphers;
108 |
109 | name += ':';
110 | if (options.key)
111 | name += options.key;
112 |
113 | name += ':';
114 | if (options.pfx)
115 | name += options.pfx;
116 |
117 | name += ':';
118 | if (!util.isUndefined(options.rejectUnauthorized))
119 | name += options.rejectUnauthorized;
120 |
121 | return name;
122 | };
123 |
124 | var globalAgent = new Agent();
125 |
126 | exports.globalAgent = globalAgent;
127 | exports.Agent = Agent;
128 |
129 | exports.request = function(options, cb) {
130 | if (util.isString(options)) {
131 | options = url.parse(options);
132 | } else {
133 | options = util._extend({}, options);
134 | }
135 | options._defaultAgent = globalAgent;
136 | return http.request(options, cb);
137 | };
138 |
139 | exports.get = function(options, cb) {
140 | var req = exports.request(options, cb);
141 | req.end();
142 | return req;
143 | };
144 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/node/os.js:
--------------------------------------------------------------------------------
1 | // Copyright Joyent, Inc. and other Node contributors.
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a
4 | // copy of this software and associated documentation files (the
5 | // "Software"), to deal in the Software without restriction, including
6 | // without limitation the rights to use, copy, modify, merge, publish,
7 | // distribute, sublicense, and/or sell copies of the Software, and to permit
8 | // persons to whom the Software is furnished to do so, subject to the
9 | // following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included
12 | // in all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 | // USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
22 | var binding = process.binding('os');
23 | var util = require('util');
24 | var isWindows = process.platform === 'win32';
25 |
26 | exports.endianness = binding.getEndianness;
27 | exports.hostname = binding.getHostname;
28 | exports.loadavg = binding.getLoadAvg;
29 | exports.uptime = binding.getUptime;
30 | exports.freemem = binding.getFreeMem;
31 | exports.totalmem = binding.getTotalMem;
32 | exports.cpus = binding.getCPUs;
33 | exports.type = binding.getOSType;
34 | exports.release = binding.getOSRelease;
35 | exports.networkInterfaces = binding.getInterfaceAddresses;
36 |
37 | exports.arch = function() {
38 | return process.arch;
39 | };
40 |
41 | exports.platform = function() {
42 | return process.platform;
43 | };
44 |
45 | exports.tmpdir = function() {
46 | if (isWindows) {
47 | return process.env.TEMP ||
48 | process.env.TMP ||
49 | (process.env.SystemRoot || process.env.windir) + '\\temp';
50 | } else {
51 | return process.env.TMPDIR ||
52 | process.env.TMP ||
53 | process.env.TEMP ||
54 | '/tmp';
55 | }
56 | };
57 |
58 | exports.tmpDir = exports.tmpdir;
59 |
60 | exports.getNetworkInterfaces = util.deprecate(function() {
61 | return exports.networkInterfaces();
62 | }, 'getNetworkInterfaces is now called `os.networkInterfaces`.');
63 |
64 | exports.EOL = isWindows ? '\r\n' : '\n';
65 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/node/smalloc.js:
--------------------------------------------------------------------------------
1 | // Copyright Joyent, Inc. and other Node contributors.
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a
4 | // copy of this software and associated documentation files (the
5 | // "Software"), to deal in the Software without restriction, including
6 | // without limitation the rights to use, copy, modify, merge, publish,
7 | // distribute, sublicense, and/or sell copies of the Software, and to permit
8 | // persons to whom the Software is furnished to do so, subject to the
9 | // following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included
12 | // in all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 | // USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
22 | var smalloc = process.binding('smalloc');
23 | var kMaxLength = smalloc.kMaxLength;
24 | var util = require('util');
25 |
26 | exports.alloc = alloc;
27 | exports.copyOnto = smalloc.copyOnto;
28 | exports.dispose = dispose;
29 | exports.hasExternalData = smalloc.hasExternalData;
30 |
31 | // don't allow kMaxLength to accidentally be overwritten. it's a lot less
32 | // apparent when a primitive is accidentally changed.
33 | Object.defineProperty(exports, 'kMaxLength', {
34 | enumerable: true, value: kMaxLength, writable: false
35 | });
36 |
37 | // enumerated values for different external array types
38 | var Types = {};
39 |
40 | // Must match enum v8::ExternalArrayType.
41 | Object.defineProperties(Types, {
42 | 'Int8': { enumerable: true, value: 1, writable: false },
43 | 'Uint8': { enumerable: true, value: 2, writable: false },
44 | 'Int16': { enumerable: true, value: 3, writable: false },
45 | 'Uint16': { enumerable: true, value: 4, writable: false },
46 | 'Int32': { enumerable: true, value: 5, writable: false },
47 | 'Uint32': { enumerable: true, value: 6, writable: false },
48 | 'Float': { enumerable: true, value: 7, writable: false },
49 | 'Double': { enumerable: true, value: 8, writable: false },
50 | 'Uint8Clamped': { enumerable: true, value: 9, writable: false }
51 | });
52 |
53 | Object.defineProperty(exports, 'Types', {
54 | enumerable: true, value: Types, writable: false
55 | });
56 |
57 |
58 | // usage: obj = alloc(n[, obj][, type]);
59 | function alloc(n, obj, type) {
60 | n = n >>> 0;
61 |
62 | if (util.isUndefined(obj))
63 | obj = {};
64 |
65 | if (util.isNumber(obj)) {
66 | type = obj >>> 0;
67 | obj = {};
68 | } else if (util.isPrimitive(obj)) {
69 | throw new TypeError('obj must be an Object');
70 | }
71 |
72 | // 1 == v8::kExternalUint8Array, 9 == v8::kExternalUint8ClampedArray
73 | if (type < 1 || type > 9)
74 | throw new TypeError('unknown external array type: ' + type);
75 | if (util.isArray(obj))
76 | throw new TypeError('Arrays are not supported');
77 | if (n > kMaxLength)
78 | throw new RangeError('n > kMaxLength');
79 |
80 | return smalloc.alloc(obj, n, type);
81 | }
82 |
83 |
84 | function dispose(obj) {
85 | if (util.isPrimitive(obj))
86 | throw new TypeError('obj must be an Object');
87 | if (util.isBuffer(obj))
88 | throw new TypeError('obj cannot be a Buffer');
89 | if (smalloc.isTypedArray(obj))
90 | throw new TypeError('obj cannot be a typed array');
91 | if (!smalloc.hasExternalData(obj))
92 | throw new Error('obj has no external array data');
93 |
94 | smalloc.dispose(obj);
95 | }
96 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/node/stream.js:
--------------------------------------------------------------------------------
1 | // Copyright Joyent, Inc. and other Node contributors.
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a
4 | // copy of this software and associated documentation files (the
5 | // "Software"), to deal in the Software without restriction, including
6 | // without limitation the rights to use, copy, modify, merge, publish,
7 | // distribute, sublicense, and/or sell copies of the Software, and to permit
8 | // persons to whom the Software is furnished to do so, subject to the
9 | // following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included
12 | // in all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 | // USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
22 | module.exports = Stream;
23 |
24 | var EE = require('events').EventEmitter;
25 | var util = require('util');
26 |
27 | util.inherits(Stream, EE);
28 | Stream.Readable = require('_stream_readable');
29 | Stream.Writable = require('_stream_writable');
30 | Stream.Duplex = require('_stream_duplex');
31 | Stream.Transform = require('_stream_transform');
32 | Stream.PassThrough = require('_stream_passthrough');
33 |
34 | // Backwards-compat with node 0.4.x
35 | Stream.Stream = Stream;
36 |
37 |
38 |
39 | // old-style streams. Note that the pipe method (the only relevant
40 | // part of this class) is overridden in the Readable class.
41 |
42 | function Stream() {
43 | EE.call(this);
44 | }
45 |
46 | Stream.prototype.pipe = function(dest, options) {
47 | var source = this;
48 |
49 | function ondata(chunk) {
50 | if (dest.writable) {
51 | if (false === dest.write(chunk) && source.pause) {
52 | source.pause();
53 | }
54 | }
55 | }
56 |
57 | source.on('data', ondata);
58 |
59 | function ondrain() {
60 | if (source.readable && source.resume) {
61 | source.resume();
62 | }
63 | }
64 |
65 | dest.on('drain', ondrain);
66 |
67 | // If the 'end' option is not supplied, dest.end() will be called when
68 | // source gets the 'end' or 'close' events. Only dest.end() once.
69 | if (!dest._isStdio && (!options || options.end !== false)) {
70 | source.on('end', onend);
71 | source.on('close', onclose);
72 | }
73 |
74 | var didOnEnd = false;
75 | function onend() {
76 | if (didOnEnd) return;
77 | didOnEnd = true;
78 |
79 | dest.end();
80 | }
81 |
82 |
83 | function onclose() {
84 | if (didOnEnd) return;
85 | didOnEnd = true;
86 |
87 | if (util.isFunction(dest.destroy)) dest.destroy();
88 | }
89 |
90 | // don't leave dangling pipes when there are errors.
91 | function onerror(er) {
92 | cleanup();
93 | if (EE.listenerCount(this, 'error') === 0) {
94 | throw er; // Unhandled stream error in pipe.
95 | }
96 | }
97 |
98 | source.on('error', onerror);
99 | dest.on('error', onerror);
100 |
101 | // remove all the event listeners that were added.
102 | function cleanup() {
103 | source.removeListener('data', ondata);
104 | dest.removeListener('drain', ondrain);
105 |
106 | source.removeListener('end', onend);
107 | source.removeListener('close', onclose);
108 |
109 | source.removeListener('error', onerror);
110 | dest.removeListener('error', onerror);
111 |
112 | source.removeListener('end', cleanup);
113 | source.removeListener('close', cleanup);
114 |
115 | dest.removeListener('close', cleanup);
116 | }
117 |
118 | source.on('end', cleanup);
119 | source.on('close', cleanup);
120 |
121 | dest.on('close', cleanup);
122 |
123 | dest.emit('pipe', source);
124 |
125 | // Allow for unix-like usage: A.pipe(B).pipe(C)
126 | return dest;
127 | };
128 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/node/sys.js:
--------------------------------------------------------------------------------
1 | // Copyright Joyent, Inc. and other Node contributors.
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a
4 | // copy of this software and associated documentation files (the
5 | // "Software"), to deal in the Software without restriction, including
6 | // without limitation the rights to use, copy, modify, merge, publish,
7 | // distribute, sublicense, and/or sell copies of the Software, and to permit
8 | // persons to whom the Software is furnished to do so, subject to the
9 | // following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included
12 | // in all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 | // USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
22 | // the sys module was renamed to 'util'.
23 | // this shim remains to keep old programs working.
24 | module.exports = require('util');
25 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/node/tty.js:
--------------------------------------------------------------------------------
1 | // Copyright Joyent, Inc. and other Node contributors.
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a
4 | // copy of this software and associated documentation files (the
5 | // "Software"), to deal in the Software without restriction, including
6 | // without limitation the rights to use, copy, modify, merge, publish,
7 | // distribute, sublicense, and/or sell copies of the Software, and to permit
8 | // persons to whom the Software is furnished to do so, subject to the
9 | // following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included
12 | // in all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 | // USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
22 | var inherits = require('util').inherits;
23 | var net = require('net');
24 | var TTY = process.binding('tty_wrap').TTY;
25 | var isTTY = process.binding('tty_wrap').isTTY;
26 | var util = require('util');
27 |
28 | var errnoException = util._errnoException;
29 |
30 |
31 | exports.isatty = function(fd) {
32 | return isTTY(fd);
33 | };
34 |
35 |
36 | // backwards-compat
37 | exports.setRawMode = util.deprecate(function(flag) {
38 | if (!process.stdin.isTTY) {
39 | throw new Error('can\'t set raw mode on non-tty');
40 | }
41 | process.stdin.setRawMode(flag);
42 | }, 'tty.setRawMode: Use `process.stdin.setRawMode()` instead.');
43 |
44 |
45 | function ReadStream(fd, options) {
46 | if (!(this instanceof ReadStream))
47 | return new ReadStream(fd, options);
48 |
49 | options = util._extend({
50 | highWaterMark: 0,
51 | readable: true,
52 | writable: false,
53 | handle: new TTY(fd, true)
54 | }, options);
55 |
56 | net.Socket.call(this, options);
57 |
58 | this.isRaw = false;
59 | this.isTTY = true;
60 | }
61 | inherits(ReadStream, net.Socket);
62 |
63 | exports.ReadStream = ReadStream;
64 |
65 | ReadStream.prototype.setRawMode = function(flag) {
66 | flag = !!flag;
67 | this._handle.setRawMode(flag);
68 | this.isRaw = flag;
69 | };
70 |
71 |
72 |
73 | function WriteStream(fd) {
74 | if (!(this instanceof WriteStream)) return new WriteStream(fd);
75 | net.Socket.call(this, {
76 | handle: new TTY(fd, false),
77 | readable: false,
78 | writable: true
79 | });
80 |
81 | var winSize = [];
82 | var err = this._handle.getWindowSize(winSize);
83 | if (!err) {
84 | this.columns = winSize[0];
85 | this.rows = winSize[1];
86 | }
87 | }
88 | inherits(WriteStream, net.Socket);
89 | exports.WriteStream = WriteStream;
90 |
91 |
92 | WriteStream.prototype.isTTY = true;
93 |
94 |
95 | WriteStream.prototype._refreshSize = function() {
96 | var oldCols = this.columns;
97 | var oldRows = this.rows;
98 | var winSize = [];
99 | var err = this._handle.getWindowSize(winSize);
100 | if (err) {
101 | this.emit('error', errnoException(err, 'getWindowSize'));
102 | return;
103 | }
104 | var newCols = winSize[0];
105 | var newRows = winSize[1];
106 | if (oldCols !== newCols || oldRows !== newRows) {
107 | this.columns = newCols;
108 | this.rows = newRows;
109 | this.emit('resize');
110 | }
111 | };
112 |
113 |
114 | // backwards-compat
115 | WriteStream.prototype.cursorTo = function(x, y) {
116 | require('readline').cursorTo(this, x, y);
117 | };
118 | WriteStream.prototype.moveCursor = function(dx, dy) {
119 | require('readline').moveCursor(this, dx, dy);
120 | };
121 | WriteStream.prototype.clearLine = function(dir) {
122 | require('readline').clearLine(this, dir);
123 | };
124 | WriteStream.prototype.clearScreenDown = function() {
125 | require('readline').clearScreenDown(this);
126 | };
127 | WriteStream.prototype.getWindowSize = function() {
128 | return [this.columns, this.rows];
129 | };
130 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/node/vm.js:
--------------------------------------------------------------------------------
1 | // Copyright Joyent, Inc. and other Node contributors.
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a
4 | // copy of this software and associated documentation files (the
5 | // "Software"), to deal in the Software without restriction, including
6 | // without limitation the rights to use, copy, modify, merge, publish,
7 | // distribute, sublicense, and/or sell copies of the Software, and to permit
8 | // persons to whom the Software is furnished to do so, subject to the
9 | // following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included
12 | // in all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 | // USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
22 | var binding = process.binding('contextify');
23 | var Script = binding.ContextifyScript;
24 | var util = require('util');
25 |
26 | // The binding provides a few useful primitives:
27 | // - ContextifyScript(code, { filename = "evalmachine.anonymous",
28 | // displayErrors = true } = {})
29 | // with methods:
30 | // - runInThisContext({ displayErrors = true } = {})
31 | // - runInContext(sandbox, { displayErrors = true, timeout = undefined } = {})
32 | // - makeContext(sandbox)
33 | // - isContext(sandbox)
34 | // From this we build the entire documented API.
35 |
36 | Script.prototype.runInNewContext = function(sandbox, options) {
37 | var context = exports.createContext(sandbox);
38 | return this.runInContext(context, options);
39 | };
40 |
41 | exports.Script = Script;
42 |
43 | exports.createScript = function(code, options) {
44 | return new Script(code, options);
45 | };
46 |
47 | exports.createContext = function(sandbox) {
48 | if (util.isUndefined(sandbox)) {
49 | sandbox = {};
50 | } else if (binding.isContext(sandbox)) {
51 | return sandbox;
52 | }
53 |
54 | binding.makeContext(sandbox);
55 | return sandbox;
56 | };
57 |
58 | exports.runInDebugContext = function(code) {
59 | return binding.runInDebugContext(code);
60 | };
61 |
62 | exports.runInContext = function(code, contextifiedSandbox, options) {
63 | var script = new Script(code, options);
64 | return script.runInContext(contextifiedSandbox, options);
65 | };
66 |
67 | exports.runInNewContext = function(code, sandbox, options) {
68 | var script = new Script(code, options);
69 | return script.runInNewContext(sandbox, options);
70 | };
71 |
72 | exports.runInThisContext = function(code, options) {
73 | var script = new Script(code, options);
74 | return script.runInThisContext(options);
75 | };
76 |
77 | exports.isContext = binding.isContext;
78 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/platform/console.js:
--------------------------------------------------------------------------------
1 | /*
2 | * nodekit.io
3 | *
4 | * Copyright (c) 2016 OffGrid Networks. All Rights Reserved.
5 | * Portions Copyright (c) 2013 GitHub, Inc. under MIT License
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 |
20 | var consoleNative = io.nodekit.platform.console
21 |
22 | this.global = this;
23 |
24 | if (!global.console) {
25 | global.console = {}
26 | }
27 |
28 | global.console.log = function (msg) { consoleNative.log(msg); };
29 | global.console.error = function (msg) { consoleNative.error(msg); };
30 |
31 | global.console.navigateTo = function navigateTo(url, title) { }
32 | global.console.resize = function resize(width, height) { }
33 |
34 | io.nodekit.platform.console = global.console;
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/platform/crypto.js:
--------------------------------------------------------------------------------
1 | /*
2 | * nodekit.io
3 | *
4 | * Copyright (c) 2016 OffGrid Networks. All Rights Reserved.
5 | * Portions Copyright (c) 2013 GitHub, Inc. under MIT License
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 |
20 | var cryptoNative = io.nodekit.platform.crypto
21 |
22 | this.global = this;
23 |
24 | if (!global.crypto) {
25 | global.crypto = {}
26 | }
27 |
28 |
29 | if (!global.crypto.randomBytes) {
30 | global.crypto.randomBytes = function (size) {
31 | return new Buffer(cryptoNative.getRandomBytesSync(size));
32 | };
33 | }
34 |
35 | if (!global.crypto.getRandomValues) {
36 |
37 | // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
38 | global.crypto.getRandomValues = function (bytes) {
39 | var buf = new Buffer(cryptoNative.getRandomBytesSync(bytes.length))
40 | buf.copy(bytes);
41 | };
42 | }
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/platform/fs.js:
--------------------------------------------------------------------------------
1 | /*
2 | * nodekit.io
3 | *
4 | * Copyright (c) 2016 OffGrid Networks. All Rights Reserved.
5 | * Portions Copyright (c) 2013 GitHub, Inc. under MIT License
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 |
20 | var fs = io.nodekit.platform.fs
21 |
22 | fs._init = function() {}
23 |
24 |
25 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/platform/tcp.js:
--------------------------------------------------------------------------------
1 | /*
2 | * nodekit.io
3 | *
4 | * Copyright (c) 2016 OffGrid Networks. All Rights Reserved.
5 | * Portions Copyright (c) 2013 GitHub, Inc. under MIT License
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 |
20 | var Tcp = io.nodekit.platform.TCP
21 |
22 | Tcp.prototype._init = function() {
23 |
24 | // inherit core node Stream interface, if available
25 | if (io.nodekit.NativeStream)
26 | this.stream = new io.nodekit.NativeStream(this);
27 |
28 | };
29 |
30 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/platform/timer.js:
--------------------------------------------------------------------------------
1 | /*
2 | * nodekit.io
3 | *
4 | * Copyright (c) 2016 OffGrid Networks. All Rights Reserved.
5 | * Portions Copyright (c) 2013 GitHub, Inc. under MIT License
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 |
20 | var Timer = io.nodekit.platform.Timer
21 |
22 | this._windowTimeout = this.setTimeout
23 |
--------------------------------------------------------------------------------
/nkcore/src/main/assets/lib-core/platform/udp.js:
--------------------------------------------------------------------------------
1 | /*
2 | * nodekit.io
3 | *
4 | * Copyright (c) 2016 OffGrid Networks. All Rights Reserved.
5 | * Portions Copyright (c) 2013 GitHub, Inc. under MIT License
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 |
20 | var Udp = io.nodekit.platform.UDP
21 |
22 | Udp.prototype.close = function() {
23 | this.disconnect();
24 | this.dispose();
25 | }
--------------------------------------------------------------------------------
/nkcore/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | NKCore
3 |
4 |
--------------------------------------------------------------------------------
/nkelectro/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/nkelectro/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | group='com.github.nodekit-io'
4 |
5 | android {
6 | compileSdkVersion rootProject.compileSdkVersion
7 | buildToolsVersion rootProject.buildToolsVersion
8 |
9 | defaultConfig {
10 | minSdkVersion rootProject.minSdkVersion
11 | targetSdkVersion rootProject.targetSdkVersion
12 | versionCode rootProject.versionCode
13 | versionName rootProject.versionName
14 | }
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 | }
22 |
23 | dependencies {
24 | api fileTree(dir: 'libs', include: ['*.jar'])
25 | implementation "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
26 | implementation project(":nkscripting")
27 | }
--------------------------------------------------------------------------------
/nkelectro/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:\Users\Guy\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/nkelectro/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/nkelectro/src/main/assets/lib_electro/_nke_main.js:
--------------------------------------------------------------------------------
1 | /*
2 | * nodekit.io
3 | *
4 | * Copyright (c) 2016 OffGrid Networks. All Rights Reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | this.process = this.process || {}
20 | var process = this.process;
21 |
22 | process.platform = process.platform || "darwin"
23 | process.type = "main"
24 | process.versions = {}
25 |
26 | process.waitFor = function(signal) {
27 | window.prompt("nk.Signal", signal);
28 | }
29 |
30 | var appjs = process.bootstrap.NativeModule.getSource('lib_electro/electro.js');
31 | process.bootstrap.NativeModule.loadPreCacheSource('electro', appjs);
--------------------------------------------------------------------------------
/nkelectro/src/main/assets/lib_electro/_nke_renderer.js:
--------------------------------------------------------------------------------
1 | /*
2 | * nodekit.io
3 | *
4 | * Copyright (c) 2016 OffGrid Networks. All Rights Reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 |
20 | this.process = this.process || {}
21 | var process = this.process;
22 |
23 | process.platform = process.platform || "darwin"
24 | process.type = "renderer"
25 | process.versions = {}
26 |
27 | process.waitFor = function (signal) {
28 | window.prompt("nk.Signal", signal);
29 | }
30 |
31 | var _require = this.require || function(){}
32 | this.require = function(id){
33 | switch(id.toLowerCase()) {
34 | case "electro":
35 | case "electron":
36 | return io.nodekit.electro
37 | default:
38 | return _require(id);
39 | }
40 | }
--------------------------------------------------------------------------------
/nkelectro/src/main/assets/lib_electro/app.js:
--------------------------------------------------------------------------------
1 | /*
2 | * nodekit.io
3 | *
4 | * Copyright (c) 2016 OffGrid Networks. All Rights Reserved.
5 | * Portions Copyright (c) 2013 GitHub, Inc. under MIT License
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 |
20 | var app = io.nodekit.electro.app;
21 | var bindings = app;
22 |
23 | app.commandLine = {
24 | appendSwitch: bindings.appendSwitch,
25 | appendArgument: bindings.appendArgument
26 | };
27 |
28 | if (process.platform === 'darwin') {
29 | app.dock = {
30 | bounce: function(type) {
31 | if (type == null) {
32 | type = 'informational';
33 | }
34 | return bindings.dockBounce(type);
35 | },
36 | cancelBounce: bindings.dockCancelBounce,
37 | setBadge: bindings.dockSetBadgeText,
38 | getBadge: bindings.dockGetBadgeText,
39 | hide: bindings.dockHide,
40 | show: bindings.dockShow,
41 | setMenu: bindings.dockSetMenu
42 | };
43 | }
44 |
--------------------------------------------------------------------------------
/nkelectro/src/main/assets/lib_electro/browserwindow.js:
--------------------------------------------------------------------------------
1 | /*
2 | * nodekit.io
3 | *
4 | * Copyright (c) 2016 OffGrid Networks. All Rights Reserved.
5 | * Portions Copyright (c) 2013 GitHub, Inc. under MIT License
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 |
20 | var BrowserWindow = io.nodekit.electro.BrowserWindow
21 |
22 | var _browserWindows = {}
23 |
24 | BrowserWindow.prototype._init = function() {
25 | this._id = this.id;
26 | _browserWindows["w" + this._id] = this;
27 | };
28 |
29 | BrowserWindow.prototype._deinit = function() {
30 | delete _browserWindows["w" + this._id];
31 | this.webContents._deinit();
32 | this.webContents = nil;
33 | this._id = nil;
34 | };
35 |
36 |
37 | BrowserWindow.fromId = function(id) {
38 | return _browserWindows["w" + id];
39 | };
40 |
41 | BrowserWindow.getAllWindows = function() {
42 | return Object.keys(_browserWindows).map(function (key) {return _browserWindows[key]});
43 | };
44 |
45 | BrowserWindow.getFocusedWindow = function() {
46 | var i, len, window, windows;
47 | windows = BrowserWindow.getAllWindows();
48 | for (i = 0, len = windows.length; i < len; i++) {
49 | window = windows[i];
50 | if (window.isFocused()) {
51 | return window;
52 | }
53 | }
54 | return null;
55 | };
56 |
57 | BrowserWindow.fromWebContents = function(webContents) {
58 | var i, len, ref1, window, windows;
59 | windows = BrowserWindow.getAllWindows();
60 | for (i = 0, len = windows.length; i < len; i++) {
61 | window = windows[i];
62 | if ((ref1 = window.webContents) != null ? ref1.equal(webContents) : void 0) {
63 | return window;
64 | }
65 | }
66 | };
67 |
68 | /* Helpers. */
69 |
70 | BrowserWindow.prototype.loadURL = function() {
71 | return this.webContents.loadURL.apply(this.webContents, arguments);
72 | };
73 |
74 | BrowserWindow.prototype.getURL = function() {
75 | return this.webContents.getURL();
76 | };
77 |
78 | BrowserWindow.prototype.reload = function() {
79 | return this.webContents.reload.apply(this.webContents, arguments);
80 | };
81 |
82 | BrowserWindow.prototype.send = function() {
83 | return this.webContents.send.apply(this.webContents, arguments);
84 | };
85 |
86 | BrowserWindow.prototype.openDevTools = function() {
87 | return this.webContents.openDevTools.apply(this.webContents, arguments);
88 | };
89 |
90 | BrowserWindow.prototype.closeDevTools = function() {
91 | return this.webContents.closeDevTools();
92 | };
93 |
94 | BrowserWindow.prototype.isDevToolsOpened = function() {
95 | return this.webContents.isDevToolsOpened();
96 | };
97 |
98 | BrowserWindow.prototype.isDevToolsFocused = function() {
99 | return this.webContents.isDevToolsFocused();
100 | };
101 |
102 | BrowserWindow.prototype.toggleDevTools = function() {
103 | return this.webContents.toggleDevTools();
104 | };
105 |
106 | BrowserWindow.prototype.inspectElement = function() {
107 | return this.webContents.inspectElement.apply(this.webContents, arguments);
108 | };
109 |
110 | BrowserWindow.prototype.inspectServiceWorker = function() {
111 | return this.webContents.inspectServiceWorker();
112 | };
113 |
--------------------------------------------------------------------------------
/nkelectro/src/main/assets/lib_electro/electro.js:
--------------------------------------------------------------------------------
1 | /*
2 | * nodekit.io
3 | *
4 | * Copyright (c) 2016 OffGrid Networks. All Rights Reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | var electro = {
20 | 'app': io.nodekit.electro.app,
21 | 'autoUpdater': "not implemented",
22 | 'BrowserWindow': io.nodekit.electro.BrowserWindow,
23 | 'contentTracing': "not implemented",
24 | 'dialog': io.nodekit.electro.dialog || "not implemented",
25 | 'ipcMain': io.nodekit.electro.ipcMain,
26 | 'Menu': io.nodekit.electro.Menu || "not implemented",
27 | 'MenuItem': io.nodekit.electro.MenuItem || "not implemented",
28 | 'powerMonitor': "not implemented",
29 | 'powerSaveBlocker': "not implemented",
30 | 'protocol': io.nodekit.electro.protocol || "not implemented",
31 | 'session': "not implemented",
32 | 'WebContents': io.nodekit.electro.WebContents,
33 | 'Tray': io.nodekit.electro.Tray || "not implemented"
34 | }
35 |
36 | module.exports = electro
--------------------------------------------------------------------------------
/nkelectro/src/main/assets/lib_electro/ipcMain.js:
--------------------------------------------------------------------------------
1 | /*
2 | * nodekit.io
3 | *
4 | * Copyright (c) 2016 OffGrid Networks. All Rights Reserved.
5 | * Portions Copyright (c) 2013 GitHub, Inc. under MIT License
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 |
20 | // Binding Protocol
21 | // func ipcSend(channel: String, replyId: String, arg: [AnyObject]) -> Void
22 | // func ipcReply(dest: Int, channel: String, replyId: String, result: AnyObject) -> Void
23 | // event "NKE.IPCtoMain": item.sender, item.channel, item.replyId, item.arg
24 | // event "NKE.IPCReplytoMain": item.sender, item.channel, item.replyId, item.arg[0]
25 |
26 | var ipcMain = io.nodekit.electro.ipcMain
27 |
28 | ipcMain.on('NKE.IPCtoMain', function (sender, channel, replyId, arg) {
29 | var webContents = io.nodekit.electro.BrowserWindow.fromId(sender).webContents;
30 |
31 | var event = { 'sender': webContents }
32 |
33 | if ((replyId) !== "") {
34 | event.sendReply = function (result) {
35 | this.sender.ipcReply(0, channel, replyId, result);
36 | }
37 |
38 | Object.defineProperty(event, 'returnValue', {
39 | set: function (result) { this.sendReply(result); },
40 | enumerable: true,
41 | configurable: true,
42 | });
43 | }
44 |
45 | this.emit(channel, event, arg)
46 | });
47 |
48 | ipcMain.on('NKE.IPCReplytoMain', function (sender, channel, replyId, result) {
49 | var webContents = io.nodekit.electro.BrowserWindow.fromId(sender).webContents;
50 |
51 | var event = { 'sender': webContents }
52 |
53 | if ((replyId) !== "") {
54 | event.reply = function (result) {
55 | this.sender.ipcReply(0, channel, replyId, result);
56 | }
57 |
58 | Object.defineProperty(event, 'returnValue', {
59 | set: function (newValue) { this.reply(result); },
60 | enumerable: true,
61 | configurable: true,
62 | });
63 | }
64 |
65 | this.emit(channel, event, arg)
66 | });
--------------------------------------------------------------------------------
/nkelectro/src/main/assets/lib_electro/ipcRenderer.js:
--------------------------------------------------------------------------------
1 | /*
2 | * nodekit.io
3 | *
4 | * Copyright (c) 2016 OffGrid Networks. All Rights Reserved.
5 | * Portions Copyright (c) 2013 GitHub, Inc. under MIT License
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 |
20 | // Bindings
21 | // func ipcSend(channel: String, replyId: String, arg: [AnyObject]) -> Void {
22 | // func ipcReply(dest: Int, channel: String, replyId: String, result: AnyObject) -> Void {
23 | // event "emit", withArguments: ["NKE.IPCtoRenderer", item.sender, item.channel, item.replyId, item.arg], completionHandler: nil)
24 | // evet "emit", withArguments: ["NKE.IPCReplytoRenderer", item.sender, item.channel, item.replyId, item.arg[0]],
25 |
26 | var ipcRenderer = io.nodekit.electro.ipcRenderer;
27 |
28 | ipcRenderer._init = function() {
29 |
30 | this.callbacks = {};
31 | this.counter = 0;
32 |
33 | this.on('NKE.IPCReplytoRenderer', function(sender, channel, replyId, result) {
34 | this.callbacks[replyId].call(this, null, result);
35 | delete this.callbacks[replyId];
36 | });
37 |
38 | this.on('NKE.IPCtoRenderer', function(sender, channel, replyId, result) {
39 |
40 | var event = { 'sender': this }
41 |
42 | if ((replyId) !== "") {
43 | event.sendReply = function(result) {
44 | this.sender.ipcReply(0, channel, replyId, result);
45 | }
46 |
47 | Object.defineProperty(event, 'returnValue', {
48 | set: function(result) { this.sendReply(result); },
49 | enumerable: true,
50 | configurable: true
51 | });
52 | }
53 |
54 | this.emit(channel, event, arg)
55 |
56 | });
57 | }
58 |
59 | //send(channel [[,arg]...] [,callback])
60 | ipcRenderer.send = function() {
61 | var slice = Array.prototype.slice;
62 | var args, channel;
63 | channel = arguments[0]
64 |
65 | if (arguments.length < 2)
66 | {
67 | args = []
68 | callback = null;
69 | }
70 | else
71 | {
72 | args = slice.call(arguments, 1)
73 | if (typeof (args[args.length -1]) === "function")
74 | {
75 | callback = args[args.length -1]
76 | if (args.length > 1)
77 | args = slice.call(args, 0, args.length - 1)
78 | else
79 | args = []
80 | } else
81 | callback = null;
82 |
83 | }
84 |
85 | var replyId;
86 |
87 | if (callback) {
88 | replyId = "i" + this.counter++;
89 | this.callbacks[replyId] = callback;
90 | } else
91 | replyId = "";
92 |
93 | this.ipcSend(channel, replyId, args)
94 |
95 | // TO DO: expire callback table entry in case of non response
96 | };
97 |
98 | //ipcRenderer._init();
99 |
--------------------------------------------------------------------------------
/nkelectro/src/main/assets/lib_electro/webcontents.js:
--------------------------------------------------------------------------------
1 | /*
2 | * nodekit.io
3 | *
4 | * Copyright (c) 2016 OffGrid Networks. All Rights Reserved.
5 | * Portions Copyright (c) 2013 GitHub, Inc. under MIT License
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 |
20 | // Bindings
21 | // func ipcSend(channel: String, replyId: String, arg: [AnyObject]) -> Void {
22 | // event "emit", withArguments: ["NKE.IPCReplytoMain", item.sender, item.channel, item.replyId, item.arg[0]])
23 |
24 | var WebContents = io.nodekit.electro.WebContents
25 |
26 | WebContents.prototype._init = function () {
27 | this.callbacks = {};
28 | this.counter = 0;
29 |
30 | this.on('NKE.IPCReplytoMain', function(sender, channel, replyId, result) {
31 | callbacks[replyId].call(self, result);
32 | delete callbacks[replyId];
33 | });
34 | }
35 |
36 | WebContents.prototype._deinit = function () {
37 | this.removeAllListeners('NKE.IPCReplytoMain');
38 | }
39 |
40 | //send(channel [[,arg]...] [,callback])
41 | WebContents.prototype.send = function () {
42 | var slice = Array.prototype.slice;
43 | var args, channel;
44 | channel = arguments[0]
45 |
46 | if (arguments.length < 2)
47 | {
48 | args = []
49 | callback = null;
50 | }
51 | else
52 | {
53 | args = slice.call(arguments, 1)
54 | if (typeof (args[args.length -1]) === "function")
55 | {
56 | callback = args[args.length -1]
57 | if (args.length > 1)
58 | args = slice.call(args, 0, args.length - 1)
59 | else
60 | args = []
61 | } else
62 | callback = null;
63 |
64 | }
65 |
66 | var replyId;
67 |
68 | if (callback) {
69 | replyId = "i" + this.counter++;
70 | this.callbacks[replyId] = callback;
71 | } else
72 | replyId = "";
73 |
74 | this.ipcSend(channel, replyId, args)
75 |
76 | // TO DO: expire callback table entry in case of non response
77 | };
78 |
79 |
--------------------------------------------------------------------------------
/nkelectro/src/main/java/io/nodekit/nkelectro/NKE_Event.java:
--------------------------------------------------------------------------------
1 | /*
2 | * nodekit.io
3 | *
4 | * Copyright (c) 2016 OffGrid Networks. All Rights Reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | package io.nodekit.nkelectro;
20 |
21 | import android.webkit.JavascriptInterface;
22 |
23 | import java.util.HashMap;
24 | import java.util.Map;
25 |
26 | import io.nodekit.nkscripting.NKScriptExport;
27 |
28 | class NKE_Event extends HashMap
29 | {
30 | int getsender() {
31 | return (int)this.get("sender");
32 | }
33 |
34 | String getchannel() {
35 | return (String)this.get("channel");
36 | }
37 |
38 | String getreplyId() {
39 | return (String)this.get("replyId");
40 | }
41 |
42 | Object[] getarg() {
43 | return (Object[])this.get("arg");
44 | }
45 |
46 | NKE_Event(int sender, String channel, String replyId, Object[] arg) {
47 | this.put("sender", sender);
48 | this.put("channel", channel);
49 | this.put("replyId", replyId);
50 | this.put("arg", arg);
51 | }
52 |
53 | public NKE_Event(Map dict) {
54 | this.put("sender", dict.get("sender"));
55 | this.put("channel", dict.get("channel"));
56 | this.put("replyId", dict.get("replyId"));
57 | this.put("arg", dict.get("arg"));
58 | }
59 | }
--------------------------------------------------------------------------------
/nkelectro/src/main/java/io/nodekit/nkelectro/NKE_IpcMain.java:
--------------------------------------------------------------------------------
1 | /*
2 | * nodekit.io
3 | *
4 | * Copyright (c) 2016 OffGrid Networks. All Rights Reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | package io.nodekit.nkelectro;
20 |
21 | import android.webkit.JavascriptInterface;
22 |
23 | import java.util.HashMap;
24 | import java.util.Map;
25 |
26 | import io.nodekit.nkscripting.NKScriptValue;
27 | import io.nodekit.nkscripting.util.NKEventEmitter;
28 | import io.nodekit.nkscripting.NKScriptContext;
29 | import io.nodekit.nkscripting.util.NKEventHandler;
30 |
31 | final class NKE_IpcMain
32 | {
33 | public static void attachTo(NKScriptContext context, Map appOptions) throws Exception {
34 |
35 | HashMap options = new HashMap();
36 |
37 | options.put("js","lib_electro/ipcmain.js");
38 |
39 | NKE_IpcMain ipc = new NKE_IpcMain();
40 |
41 | NKScriptValue jsv = context.loadPlugin(ipc, "io.nodekit.electro.ipcMain", options);
42 |
43 | ipc.initWithJSValue(jsv);
44 | }
45 |
46 | private static NKEventEmitter globalEvents = NKEventEmitter.global;
47 |
48 | private NKScriptValue jsValue;
49 |
50 | private void initWithJSValue(NKScriptValue jsv) {
51 |
52 | this.jsValue = jsv;
53 |
54 | globalEvents.on("NK.IPCtoMain", new NKEventHandler() {
55 | protected void call(String event, NKE_Event item) {
56 | jsValue.invokeMethod("emit", new Object[]{"NKE.IPCtoMain", item.getsender(), item.getchannel(), item.getreplyId(), item.getarg() });
57 | }
58 | });
59 | }
60 |
61 | // Forward replies to renderer to the events queue for that renderer, using global queue since we may be cross process
62 | @JavascriptInterface
63 | public static void ipcReply(int dest, String channel, String replyId, Object result) {
64 | NKE_Event payload = new NKE_Event(0, channel, replyId, null);
65 | globalEvents.emit("NKE.IPCReplytoRenderer." + dest, payload, true);
66 | }
67 |
68 | public static void ipcSend(String channel, String replyId, Object[] arg) throws Exception {
69 | throw new UnsupportedOperationException("Event subscription only API. Sends are handled in WebContents API");
70 | }
71 |
72 | }
73 |
74 |
75 |
--------------------------------------------------------------------------------
/nkelectro/src/main/java/io/nodekit/nkelectro/NKE_IpcRenderer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * nodekit.io
3 | *
4 | * Copyright (c) 2016 OffGrid Networks. All Rights Reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | package io.nodekit.nkelectro;
20 |
21 | import android.webkit.JavascriptInterface;
22 |
23 | import java.util.HashMap;
24 | import java.util.Map;
25 |
26 | import io.nodekit.nkscripting.NKScriptValue;
27 | import io.nodekit.nkscripting.util.NKEventEmitter;
28 | import io.nodekit.nkscripting.NKScriptContext;
29 | import io.nodekit.nkscripting.util.NKEventHandler;
30 |
31 | final class NKE_IpcRenderer
32 | {
33 |
34 | static void attachTo(NKScriptContext context, Map appOptions) throws Exception {
35 |
36 | HashMap options = new HashMap();
37 |
38 | options.put("js","lib_electro/ipcrenderer.js");
39 |
40 | NKE_IpcRenderer principal = new NKE_IpcRenderer(context.id());
41 |
42 | NKScriptValue jsv = context.loadPlugin(principal, "io.nodekit.electro.ipcRenderer", options);
43 |
44 | principal.initWithJSValue(jsv);
45 | }
46 |
47 |
48 | private static NKEventEmitter globalEvents = NKEventEmitter.global;
49 | NKE_BrowserWindow _window;
50 | int _id;
51 |
52 | private NKScriptValue jsValue;
53 |
54 | private NKE_IpcRenderer(int id) throws Exception {
55 | _id = id;
56 |
57 | // IPC Renderer runs in same process as NKE BrowserWindow so can get actual host object
58 | _window = NKE_BrowserWindow.fromId(id);
59 |
60 | String ids = Integer.toString(id);
61 |
62 | }
63 |
64 | private void initWithJSValue(NKScriptValue jsv) {
65 |
66 | this.jsValue = jsv;
67 |
68 | String ids = Integer.toString(_id);
69 |
70 | _window.events.on("NKE.IPCtoRenderer", new NKEventHandler() {
71 | protected void call(String event, NKE_Event item) {
72 | jsValue.invokeMethod("emit", new Object[]{"NKE.IPCtoRenderer", item.getsender(), item.getchannel(), item.getreplyId(), item.getarg() });
73 | }
74 | });
75 |
76 | globalEvents.on("NKE.IPCReplytoRenderer." + ids, new NKEventHandler() {
77 | protected void call(String event, NKE_Event item) {
78 | jsValue.invokeMethod("emit", new Object[]{"NKE.IPCtoRenderer", item.getsender(), item.getchannel(), item.getreplyId(), item.getarg() });
79 | }
80 | });
81 |
82 | }
83 |
84 | // Messages to main are sent to the global events queue, potentially cross-process
85 | public void ipcSend(String channel, String replyId, Object[] arg) throws Exception {
86 | NKE_Event payload = new NKE_Event(0, channel, replyId, arg);
87 | globalEvents.emit("NKE.IPCtoMain", payload, true);
88 | }
89 |
90 | // Replies to main are sent directly to the webContents window in this local process that sent the original message
91 | public void ipcReply(int dest, String channel, String replyId, Object result) throws Exception {
92 | NKE_Event payload = new NKE_Event(0, channel, replyId, null);
93 | _window.events.emit("NKE.IPCReplytoMain", payload, false );
94 | }
95 |
96 | }
97 |
98 |
99 |
--------------------------------------------------------------------------------
/nkelectro/src/main/java/io/nodekit/nkelectro/NKE_WebContents.java:
--------------------------------------------------------------------------------
1 | /*
2 | * nodekit.io
3 | *
4 | * Copyright (c) 2016 OffGrid Networks. All Rights Reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | package io.nodekit.nkelectro;
20 |
21 | import java.util.HashMap;
22 | import java.util.Map;
23 |
24 | import io.nodekit.nkscripting.NKScriptContext;
25 | import io.nodekit.nkscripting.NKScriptValue;
26 | import io.nodekit.nkscripting.util.NKEventHandler;
27 |
28 | abstract class NKE_WebContents {
29 |
30 | NKE_BrowserWindow _browserWindow;
31 |
32 | int _id;
33 |
34 | NKE_WebContents() {}
35 |
36 | NKE_WebContents(NKE_BrowserWindow browserWindow)
37 | {
38 | this._browserWindow = browserWindow;
39 | this._id = browserWindow.id();
40 |
41 | // Event: 'did-fail-load'
42 | // Event: 'did-finish-load'
43 |
44 | _browserWindow.events.on("NKE.DidFinishLoad", new NKEventHandler() {
45 | protected void call(String event, String item) {
46 | NKScriptValue.invokeMethodForObject(this, "emit", new String[]{"did-finish-load"});
47 | }
48 | });
49 |
50 | _browserWindow.events.on("NKE.DidFailLoading", new NKEventHandler() {
51 | protected void call(String event, String item) {
52 | NKScriptValue.invokeMethodForObject(this, "emit", new String[]{"did-fail-loading"});
53 | }
54 | });
55 |
56 | }
57 |
58 | abstract public void createWebView(int id, HashMap options);
59 |
60 | void init_IPC()
61 | {
62 | _browserWindow.events.on("NKE.IPCReplytoMain", new NKEventHandler() {
63 | protected void call(String event, NKE_Event item) {
64 | NKScriptValue.invokeMethodForObject(this, "emit", new Object[]{"NKE.IPCReplytoMain", item.getsender(), item.getchannel(), item.getreplyId(), item.getarg()[0]});
65 | }
66 | });
67 | }
68 |
69 | // Messages to renderer are sent to the window events queue for that renderer which will be in same process as ipcRenderer
70 | public void ipcSend(String channel, String replyId, Object[] arg)
71 | {
72 | NKE_Event payload = new NKE_Event(0, channel, replyId, arg);
73 | _browserWindow.events.emit("NKE.IPCtoRenderer", payload);
74 | }
75 |
76 | // Replies to renderer to the window events queue for that renderer
77 | public void ipcReply(int dest, String channel, String replyId, Object result)
78 | {
79 | NKE_Event payload = new NKE_Event(0, channel, replyId, new Object[] { result });
80 | _browserWindow.events.emit("NKE.IPCReplytoRenderer", payload);
81 | }
82 |
83 | }
--------------------------------------------------------------------------------
/nkelectro/src/main/java/io/nodekit/nkelectro/NKElectro.java:
--------------------------------------------------------------------------------
1 | package io.nodekit.nkelectro;
2 |
3 | import io.nodekit.nkscripting.NKScriptSource;
4 | import io.nodekit.nkscripting.NKScriptContext;
5 | import java.util.HashMap;
6 | import java.util.Map;
7 | import io.nodekit.nkscripting.util.NKStorage;
8 |
9 | public class NKElectro {
10 |
11 | public static void addToContext(NKScriptContext context, Map options) throws Exception
12 | {
13 | String appjs = NKStorage.getResource("lib_electro/_nke_main.js");
14 | String script = "function loadbootstrap(){\n" + appjs + "\n}\n" + "loadbootstrap();" + "\n";
15 | NKScriptSource scriptsource = new NKScriptSource(script, "io.nodekit.electro/lib-electro/_nke_main.js", "io.nodekit.electro.main", null);
16 | context.injectJavaScript(scriptsource);
17 |
18 | NKE_App.attachTo(context, options);
19 | NKE_BrowserWindow.attachTo(context, options);
20 | NKE_WebContents_AndroidWebView.attachTo(context, options);
21 | // NKE_Dialog.attachTo(context, options);
22 | NKE_IpcMain.attachTo(context, options);
23 | NKE_Protocol.attachTo(context, options);
24 | }
25 |
26 |
27 | static void addToRendererContext(NKScriptContext context, Map options) throws Exception
28 | {
29 | String appjs = NKStorage.getResource("lib_electro/_nke_renderer.js");
30 | String script = "function loadbootstrap(){\n" + appjs + "\n}\n" + "loadbootstrap();" + "\n";
31 | NKScriptSource scriptsource = new NKScriptSource(script, "io.nodekit.electro/lib-electro/_nke_renderer.js", "io.nodekit.electro.renderer", null);
32 | context.injectJavaScript(scriptsource);
33 |
34 | HashMap optionsDefault = new HashMap();
35 |
36 | // NKE_IpcRenderer.attachTo(context, optionsDefault);
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/nkelectro/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | NKElectro
3 |
4 |
--------------------------------------------------------------------------------
/nkscripting/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/nkscripting/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.novoda.bintray-release'
3 |
4 | android {
5 | compileSdkVersion rootProject.compileSdkVersion
6 | buildToolsVersion rootProject.buildToolsVersion
7 |
8 | defaultConfig {
9 | minSdkVersion rootProject.minSdkVersion
10 | targetSdkVersion rootProject.targetSdkVersion
11 | versionCode rootProject.versionCode
12 | versionName rootProject.versionName
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | api fileTree(dir: 'libs', include: ['*.jar'])
24 | implementation "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
25 | }
26 |
27 | publish {
28 | userOrg = 'nodekit-io'
29 | groupId = 'io.nodekit'
30 | artifactId = project.name
31 | publishVersion = "$rootProject.versionName"
32 | desc = 'NodeKit NKScripting for Android'
33 | website = 'https://github.com/nodekit-io/nodekit-android'
34 | }
--------------------------------------------------------------------------------
/nkscripting/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:\Users\Guy\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/nkscripting/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/nkscripting/src/main/assets/lib-scripting/init_androidwebview.js:
--------------------------------------------------------------------------------
1 | /*
2 | * nodekit.io
3 | *
4 | * Copyright (c) 2016 OffGrid Networks. All Rights Reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | this.process = this.process || {}
20 | var process = this.process;
21 |
22 | process.platform = process.platform || "android"
23 | process.type = "main"
24 | process.versions = {}
25 |
26 | this.console = this.console || function () { };
27 |
28 | console.log = function () {
29 | const msg = Array.prototype.slice.call(arguments).join(" ");
30 | NKScriptingBridge.log(msg, "Info", {})
31 | };
32 | console.log.debug = function () {
33 | const msg = Array.prototype.slice.call(arguments).join(" ");
34 | NKScriptingBridge.log(msg, "Debug", {})
35 | };
36 | console.log.info = function () {
37 | const msg = Array.prototype.slice.call(arguments).join(" ");
38 | NKScriptingBridge.log(msg, "Info", {})
39 | };
40 | console.log.notice = function () {
41 | const msg = Array.prototype.slice.call(arguments).join(" ");
42 | NKScriptingBridge.log(msg, "Notice", {})
43 | };
44 | console.log.warning = function () {
45 | const msg = Array.prototype.slice.call(arguments).join(" ");
46 | NKScriptingBridge.log(msg, "Warning", {})
47 | };
48 | console.log.error = function () {
49 | const msg = Array.prototype.slice.call(arguments).join(" ");
50 | NKScriptingBridge.log(msg, "Error", {})
51 | };
52 | console.log.critical = function () {
53 | const msg = Array.prototype.slice.call(arguments).join(" ");
54 | NKScriptingBridge.log(msg, "Critical", {})
55 | };
56 | console.log.emergency = function () {
57 | const msg = Array.prototype.slice.call(arguments).join(" ");
58 | NKScriptingBridge.log(msg, "Emergency", {})
59 | };
60 | console.warn = console.log.warning;
61 | console.error = console.log.error;
62 | console.info = console.log.info;
63 | console.dir = console.log.debug;
64 |
65 | (function (con) {
66 | var prop, method;
67 | var empty = {};
68 | var dummy = function () { };
69 | var properties = "memory".split(",");
70 | var methods = ("assert,count,debug,dir,dirxml,error,exception,group,"
71 | + "groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,"
72 | + "time,timeEnd,trace,warn").split(",");
73 | while (prop = properties.pop()) {
74 | con[prop] = con[prop] || empty;
75 | }
76 | while (method = methods.pop()) {
77 | con[method] = con[method] || dummy;
78 | }
79 | })(console);
80 |
81 | NKScripting.serialize = true;
82 |
83 | NKScripting.getMessageHandlers = function (name) {
84 |
85 | return {
86 | 'postMessage': function (message) { NKScriptingBridge.didReceiveScriptMessage(name, JSON.stringify(message)); },
87 | 'postMessageSync': function (message) { return NKScriptingBridge.didReceiveScriptMessageSync(name, JSON.stringify(message)) }
88 | };
89 | }
90 |
91 | console.log("NKNodeKit WebView: Android JavaScript Engine Initialized");
--------------------------------------------------------------------------------
/nkscripting/src/main/assets/lib-scripting/timer.js:
--------------------------------------------------------------------------------
1 |
2 | function setTimeout(callback, ms) {
3 |
4 | return NodeKitTimer.setTimeoutSync(callback, ms)
5 | }
6 |
7 | function setInterval(callback, ms) {
8 |
9 | return NodeKitTimer.setIntervalSync(callback, ms)
10 | }
11 |
12 | function clearTimeout(indentifier) {
13 |
14 | NodeKitTimer.clearTimeoutSync(indentifier)
15 | }
--------------------------------------------------------------------------------
/nkscripting/src/main/java/io/nodekit/nkscripting/NKScriptContext.java:
--------------------------------------------------------------------------------
1 | /*
2 | * nodekit.io
3 | *
4 | * Copyright (c) 2016 OffGrid Networks. All Rights Reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | package io.nodekit.nkscripting;
20 |
21 | import io.nodekit.nkscripting.channelbridge.NKScriptMessage;
22 |
23 | import java.util.HashMap;
24 |
25 | public interface NKScriptContext
26 | {
27 | int id() throws Exception ;
28 |
29 | NKScriptValue loadPlugin(Object plugin, String ns, HashMap options) throws Exception ;
30 |
31 | void evaluateJavaScript(String javaScriptString, android.webkit.ValueCallback callback) throws Exception ;
32 |
33 | void injectJavaScript(NKScriptSource source) throws Exception ;
34 |
35 | String serialize(Object obj) throws Exception ;
36 |
37 | void tearDown();
38 |
39 | interface NKScriptContextDelegate {
40 |
41 | void NKScriptEngineDidLoad(NKScriptContext context);
42 |
43 | void NKScriptEngineReady(NKScriptContext context);
44 |
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/nkscripting/src/main/java/io/nodekit/nkscripting/NKScriptContextFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * nodekit.io
3 | *
4 | * Copyright (c) 2016 OffGrid Networks. All Rights Reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | package io.nodekit.nkscripting;
20 |
21 | import android.support.annotation.Nullable;
22 | import android.util.SparseArray;
23 | import java.util.HashMap;
24 |
25 | import io.nodekit.nkscripting.engines.androidwebview.NKEngineAndroidWebView;
26 |
27 | public class NKScriptContextFactory
28 | {
29 |
30 | public enum NKTypeEngine
31 | {
32 | WebView,
33 | // Native webview provided by Android OS
34 | CrossWalk
35 | // open source embedded V8 engine
36 | }
37 |
38 | public static SparseArray