You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by er...@apache.org on 2022/03/31 03:32:37 UTC
[cordova-plugin-device] branch master updated: feat(electron): add support (#135)
This is an automated email from the ASF dual-hosted git repository.
erisu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-plugin-device.git
The following commit(s) were added to refs/heads/master by this push:
new f6cf8a6 feat(electron): add support (#135)
f6cf8a6 is described below
commit f6cf8a6b98ce39fe53a0771d0fd58cd7837cba40
Author: エリス <er...@users.noreply.github.com>
AuthorDate: Thu Mar 31 12:32:32 2022 +0900
feat(electron): add support (#135)
* feat(electron): add support
* style(lint): ignore electron/src/node_modules
* chore: git & npm ignore electron/src/{node_modules|package-lock.json}
* chore: add electron to cordova.platforms list in package.json
* chore(electron): bump systeminformation@5.11.9
---
.eslintignore | 1 +
.gitignore | 8 +-------
.npmignore | 2 ++
package.json | 5 ++++-
plugin.xml | 9 +++++++++
src/electron/index.js | 42 ++++++++++++++++++++++++++++++++++++++++++
src/electron/package.json | 20 ++++++++++++++++++++
7 files changed, 79 insertions(+), 8 deletions(-)
diff --git a/.eslintignore b/.eslintignore
new file mode 100644
index 0000000..567f152
--- /dev/null
+++ b/.eslintignore
@@ -0,0 +1 @@
+src/electron/node_modules
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 6964ea0..9b56d82 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,10 +14,4 @@ Thumbs.db
node_modules
-
-
-
-
-
-
-
\ No newline at end of file
+src/electron/package-lock.json
\ No newline at end of file
diff --git a/.npmignore b/.npmignore
index 2657abf..f652a7c 100644
--- a/.npmignore
+++ b/.npmignore
@@ -1,2 +1,4 @@
.*
tests
+src/electron/node_modules
+src/electron/package-lock.json
\ No newline at end of file
diff --git a/package.json b/package.json
index 1840947..426f005 100644
--- a/package.json
+++ b/package.json
@@ -7,6 +7,7 @@
"id": "cordova-plugin-device",
"platforms": [
"android",
+ "electron",
"ios",
"windows",
"browser",
@@ -20,6 +21,7 @@
"device",
"ecosystem:cordova",
"cordova-android",
+ "cordova-electron",
"cordova-ios",
"cordova-windows",
"cordova-browser",
@@ -34,7 +36,8 @@
"engines": {
"cordovaDependencies": {
"3.0.0": {
- "cordova": ">100"
+ "cordova": ">100",
+ "cordova-electron": ">=3.0.0"
}
}
},
diff --git a/plugin.xml b/plugin.xml
index 7dbfd01..04a0a03 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -30,6 +30,10 @@
<repo>https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git</repo>
<issue>https://issues.apache.org/jira/browse/CB/component/12320648</issue>
+ <engines>
+ <engine name="cordova-electron" version=">=3.0.0" />
+ </engines>
+
<js-module src="www/device.js" name="device">
<clobbers target="device" />
</js-module>
@@ -57,6 +61,11 @@
<source-file src="src/ios/CDVDevice.m" />
</platform>
+ <!-- electron -->
+ <platform name="electron">
+ <framework src="src/electron" />
+ </platform>
+
<!-- windows -->
<platform name="windows">
<js-module src="src/windows/DeviceProxy.js" name="DeviceProxy">
diff --git a/src/electron/index.js b/src/electron/index.js
new file mode 100644
index 0000000..1d922a3
--- /dev/null
+++ b/src/electron/index.js
@@ -0,0 +1,42 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+const { system, osInfo } = require('systeminformation');
+
+module.exports = {
+ getDeviceInfo: async () => {
+ try {
+ const { manufacturer, model, uuid } = await system();
+ const { platform, distro, codename, build: version } = await osInfo();
+
+ return {
+ manufacturer,
+ model,
+ platform: platform === 'darwin' ? codename : distro,
+ version,
+ uuid,
+ isVirtual: false
+ };
+ } catch (e) {
+ console.log(e);
+ }
+ }
+};
diff --git a/src/electron/package.json b/src/electron/package.json
new file mode 100644
index 0000000..490bd70
--- /dev/null
+++ b/src/electron/package.json
@@ -0,0 +1,20 @@
+{
+ "name": "cordova-plugin-device-electron",
+ "version": "1.0.0",
+ "description": "Electron Native Supprot for Cordova Device Plugin",
+ "main": "index.js",
+ "keywords": [
+ "cordova",
+ "electron",
+ "device",
+ "native"
+ ],
+ "author": "Apache Software Foundation",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "systeminformation": "^5.11.9"
+ },
+ "cordova": {
+ "serviceName": "Device"
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org