@webos-tools/cli 3.1.1 → 3.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/CHANGELOG.md +173 -157
  2. package/LICENSES/342/200/216/LicenseRef-3rd_party_licenses.txt +1355 -0
  3. package/README.md +21 -19
  4. package/bin/ares-config.js +6 -3
  5. package/bin/ares-device.js +2 -2
  6. package/bin/ares-log.js +6 -2
  7. package/bin/ares-pull.js +1 -1
  8. package/bin/ares-push.js +1 -1
  9. package/bin/ares-setup-device.js +573 -528
  10. package/bin/ares-shell.js +1 -1
  11. package/bin/ares.js +1 -1
  12. package/files/conf/ares.json +5 -5
  13. package/files/conf/novacom-devices.json +18 -1
  14. package/files/conf-base/env/sdk-apollo.json +8 -0
  15. package/files/conf-base/profile/config-apollo.json +29 -0
  16. package/files/conf-base/profile/config-ose.json +1 -1
  17. package/files/conf-base/template-conf/apollo-sdk-templates.json +56 -0
  18. package/files/help/ares-config.help +6 -1
  19. package/files/help/ares-device.help +15 -0
  20. package/files/help/ares-generate.help +27 -1
  21. package/files/help/ares-inspect.help +6 -0
  22. package/files/help/ares-install.help +5 -0
  23. package/files/help/ares-launch.help +5 -0
  24. package/files/help/ares-server.help +5 -0
  25. package/files/help/ares-setup-device.help +40 -0
  26. package/files/help/ares.help +5 -0
  27. package/files/schema/NovacomDevices.schema +2 -1
  28. package/files/templates/apollo-sdk-templates/appinfo/appinfo.json +10 -0
  29. package/files/templates/apollo-sdk-templates/bootplate-web/index.html +88 -0
  30. package/files/templates/apollo-sdk-templates/hosted-webapp/index.html +14 -0
  31. package/files/templates/apollo-sdk-templates/icon/icon.png +0 -0
  32. package/files/templates/apollo-sdk-templates/js-service/helloclient.js +31 -0
  33. package/files/templates/apollo-sdk-templates/js-service/helloworld_webos_service.js +188 -0
  34. package/files/templates/apollo-sdk-templates/native-service/CMakeLists.txt +72 -0
  35. package/files/templates/apollo-sdk-templates/native-service/services.json +11 -0
  36. package/files/templates/apollo-sdk-templates/native-service/src/main.c +144 -0
  37. package/files/templates/apollo-sdk-templates/serviceinfo/package.json +11 -0
  38. package/files/templates/apollo-sdk-templates/serviceinfo/services.json +8 -0
  39. package/lib/base/novacom.js +1 -1
  40. package/lib/base/setup-device.js +338 -335
  41. package/lib/device.js +1 -1
  42. package/lib/generator.js +408 -377
  43. package/lib/package.js +3 -1
  44. package/lib/shell.js +1 -1
  45. package/npm-shrinkwrap.json +9242 -9242
  46. package/package.json +100 -100
  47. package/sbom-info.yaml +1758 -0
  48. package/spec/jsSpecs/ares-config.spec.js +10 -0
  49. package/spec/jsSpecs/ares-generate.spec.js +4 -4
  50. package/spec/jsSpecs/ares-log.spec.js +1 -1
  51. package/spec/test_data/ares-generate.json +18 -1
  52. package/spec/test_data/ares.json +17 -0
  53. package/webos-tools-cli-3.1.3.tgz +0 -0
package/bin/ares-shell.js CHANGED
@@ -54,7 +54,7 @@ log.level = argv.level || 'warn';
54
54
  log.verbose("argv", argv);
55
55
 
56
56
  const curConfigData = appdata.getConfig(true);
57
- if (curConfigData.profile !== "ose") {
57
+ if (!["ose", "apollo"].includes(curConfigData.profile)) {
58
58
  return finish(errHndl.getErrMsg("NOT_SUPPORT_COMMOND", curConfigData.profile));
59
59
  }
60
60
 
package/bin/ares.js CHANGED
@@ -119,7 +119,7 @@ function display (next) {
119
119
  for (const arg in argv) {
120
120
  if (Object.hasOwnProperty.call(commandsList, 'ares-'+ arg) && fs.existsSync(path.join(__dirname, 'ares-'+ arg + '.js'))) {
121
121
  if (commandsList['ares-'+ arg].profile && !commandsList['ares-'+ arg].profile.includes(profile)) {
122
- return next(errHndl.getErrMsg("NOT_SUPPORT_COMMOND", profile));
122
+ return next(errHndl.getErrMsg("NOT_SUPPORT_COMMOND", profile));
123
123
  } else {
124
124
  help.display('ares-'+arg, appdata.getConfig(true).profile);
125
125
  found = true;
@@ -18,7 +18,7 @@
18
18
  "description": "Launch or close the app"
19
19
  },
20
20
  "ares-log": {
21
- "profile": ["ose"],
21
+ "profile": ["ose", "apollo"],
22
22
  "description": "Show or save logs of webOS apps and services"
23
23
  },
24
24
  "ares-novacom": {
@@ -29,11 +29,11 @@
29
29
  "description": "Create or analyze a package containing a webOS app or service"
30
30
  },
31
31
  "ares-pull": {
32
- "profile": ["ose"],
32
+ "profile": ["ose","apollo"],
33
33
  "description": "Pull the file from the device"
34
34
  },
35
35
  "ares-push": {
36
- "profile": ["ose"],
36
+ "profile": ["ose","apollo"],
37
37
  "description": "Push the file to the device"
38
38
  },
39
39
  "ares-server": {
@@ -43,7 +43,7 @@
43
43
  "description": "Add or modify the information of the devices to use"
44
44
  },
45
45
  "ares-shell": {
46
- "profile": ["ose"],
46
+ "profile": ["ose","apollo"],
47
47
  "description": "Open a device terminal or run a command"
48
48
  }
49
- }
49
+ }
@@ -31,5 +31,22 @@
31
31
  "files":"sftp",
32
32
  "noPortForwarding":false,
33
33
  "indelible": true
34
+ },
35
+ {
36
+ "order":"0",
37
+ "default": true,
38
+ "profile": "apollo",
39
+ "name": "emulator",
40
+ "type": "starfish",
41
+ "description": "LG webOS Apollo Emulator",
42
+ "host": "127.0.0.1",
43
+ "port": 6622,
44
+ "username": "developer",
45
+ "privateKey": {
46
+ "openSsh": "webos_emul"
47
+ },
48
+ "files":"sftp",
49
+ "noPortForwarding":false,
50
+ "indelible": true
34
51
  }
35
- ]
52
+ ]
@@ -0,0 +1,8 @@
1
+ {
2
+ "SDKPATH_ENV_NAME": "LG_WEBOS_APOLLO_SDK_HOME",
3
+ "BROWSER_PATH_IN_SDK": {
4
+ "win32": "/IDE/chromium/chrome.exe",
5
+ "darwin": "/IDE/chromium/Chromium.app",
6
+ "linux": "/IDE/chromium/chrome"
7
+ }
8
+ }
@@ -0,0 +1,29 @@
1
+ {
2
+ "profile": "apollo",
3
+ "defaultAppInfo": {
4
+ "id": "com.yourdomain.app",
5
+ "type": "web",
6
+ "title": "new app",
7
+ "version": "1.0.0",
8
+ "main": {
9
+ "web": "index.html",
10
+ "native": "executable"
11
+ }
12
+ },
13
+ "defaultDeviceInfo": {
14
+ "ipAddress": "127.0.0.1",
15
+ "port": "22",
16
+ "user": "root",
17
+ "description": "new device description",
18
+ "files": "stream",
19
+ "default": false
20
+ },
21
+ "logFilePath": "/media/developer/log/devlog",
22
+ "install": {
23
+ "tempDirForIpk": "/media/developer/temp",
24
+ "changeTempDir": true,
25
+ "removeIpkAfterInst": true
26
+ },
27
+ "dataDir":".webos/apollo",
28
+ "logDaemon": "journald"
29
+ }
@@ -10,7 +10,7 @@
10
10
  "native": "executable"
11
11
  }
12
12
  },
13
- "defaultDeviceInfo":{
13
+ "defaultDeviceInfo": {
14
14
  "ipAddress": "127.0.0.1",
15
15
  "port": "22",
16
16
  "user": "root",
@@ -0,0 +1,56 @@
1
+ {
2
+ "webapp": {
3
+ "type": "webapp",
4
+ "path": "$cli-root/files/templates/apollo-sdk-templates/bootplate-web",
5
+ "description": "web app for Apollo",
6
+ "metadata": {
7
+ "id": "webappinfo"
8
+ },
9
+ "deps": [
10
+ "icon"
11
+ ],
12
+ "default": true
13
+ },
14
+ "hosted_webapp": {
15
+ "type": "webapp",
16
+ "path": "$cli-root/files/templates/apollo-sdk-templates/hosted-webapp",
17
+ "description": "hosted web app for Apollo",
18
+ "metadata": {
19
+ "id": "webappinfo"
20
+ },
21
+ "deps": [
22
+ "icon"
23
+ ]
24
+ },
25
+ "webappinfo": {
26
+ "type": "webappinfo",
27
+ "path": "$cli-root/files/templates/apollo-sdk-templates/appinfo/appinfo.json",
28
+ "description": "appinfo.json for web app"
29
+ },
30
+ "js_service": {
31
+ "type": "jsservice",
32
+ "path": "$cli-root/files/templates/apollo-sdk-templates/js-service",
33
+ "description": "js service for Apollo",
34
+ "metadata": {
35
+ "id": "jsserviceinfo"
36
+ }
37
+ },
38
+ "jsserviceinfo": {
39
+ "type": "jsserviceinfo",
40
+ "path": [
41
+ "$cli-root/files/templates/apollo-sdk-templates/serviceinfo/services.json",
42
+ "$cli-root/files/templates/apollo-sdk-templates/serviceinfo/package.json"
43
+ ],
44
+ "description": "services.json, package.json for JS service"
45
+ },
46
+ "native_service": {
47
+ "type": "nativeservice",
48
+ "path": "$cli-root/files/templates/apollo-sdk-templates/native-service",
49
+ "description": "native service for Apollo"
50
+ },
51
+ "icon": {
52
+ "type": "icon",
53
+ "path": "$cli-root/files/templates/apollo-sdk-templates/icon",
54
+ "description": "app icon files [80x80]"
55
+ }
56
+ }
@@ -13,11 +13,15 @@
13
13
  "This command used for configuring the webOS devices profile setting to work with CLI.",
14
14
  "",
15
15
  "DEVICE_PROFILE is the profile of a target device.",
16
- "This parameter can be \"ose\" and \"tv\". \"tv\" is default."
16
+ "This parameter can be \"ose\", \"tv\" and \"apollo\". \"tv\" is default."
17
17
  ],
18
18
  "ose" : [
19
19
  "",
20
20
  "LEVEL is priority of logs. (e.g., silly, verbose, info, warn, error)"
21
+ ],
22
+ "apollo" : [
23
+ "",
24
+ "LEVEL is priority of logs. (e.g., silly, verbose, info, warn, error)"
21
25
  ]
22
26
  }
23
27
  ],
@@ -33,6 +37,7 @@
33
37
  "cmdOpt":"option",
34
38
  "default" : ["profile", "profile-details", "help", "version", "verbose"],
35
39
  "ose" : ["level"],
40
+ "apollo" : ["level"],
36
41
  "profile" : "-p, --profile <DEVICE_PROFILE> @TAB@ Specify a device profile to configure for CLI",
37
42
  "profile-details" : "-c, --profile-details @TAB@ Display current configured profile",
38
43
  "help" : "-h, --help @TAB@ Display this help",
@@ -26,12 +26,22 @@
26
26
  "The file format can be \".png\", \".jpg\" and \".bmp\". \".png\" is default.",
27
27
  "",
28
28
  "LEVEL is priority of logs. (e.g., silly, verbose, info, warn, error)"
29
+ ],
30
+ "apollo" : [
31
+ "",
32
+ "And This command supports screen capture.",
33
+ "",
34
+ "CAPTURE_FILE is file name or file path of capture file.",
35
+ "The file format can be \".png\", \".jpg\" and \".bmp\". \".png\" is default.",
36
+ "",
37
+ "LEVEL is priority of logs. (e.g., silly, verbose, info, warn, error)"
29
38
  ]
30
39
  },
31
40
  "options" : {
32
41
  "cmdOpt":"option",
33
42
  "default" : ["system", "resource", "list", "id-filter", "interval", "save"],
34
43
  "ose" : ["capture", "display", "device", "device-list", "help", "version", "verbose", "level"],
44
+ "apollo" : ["capture", "display", "device", "device-list", "help", "version", "verbose", "level"],
35
45
  "tv" : ["device", "device-list", "help", "version", "verbose"],
36
46
  "system" : "-i, --system-info @TAB@ Display the system information",
37
47
  "session" : "-se, --session-info @TAB@ Display the session information",
@@ -89,6 +99,11 @@
89
99
  "# Capture the screen of display 1 as screen.png",
90
100
  "ares-device -c screen.png -dp 1 -d DEVICE",
91
101
  ""
102
+ ],
103
+ "apollo" : [
104
+ "# Capture the screen of display as screen.png",
105
+ "ares-device -c screen.png -d DEVICE",
106
+ ""
92
107
  ]
93
108
  }
94
109
  }
@@ -23,12 +23,17 @@
23
23
  "ose" : [
24
24
  "",
25
25
  "LEVEL is priority of logs. (e.g., silly, verbose, info, warn, error)"
26
+ ],
27
+ "apollo" : [
28
+ "",
29
+ "LEVEL is priority of logs. (e.g., silly, verbose, info, warn, error)"
26
30
  ]
27
31
  }
28
32
  ],
29
33
  "examples" : [
30
34
  {
31
- "default" : [
35
+ "default":[],
36
+ "ose" : [
32
37
  "# Create a webOS app in ~/project/app and set the id, version, title",
33
38
  "ares-generate -t webapp -p \"{'id':'com.domain.app', 'version':'1.0.0', 'title':'First App'}\" ~/projects/app",
34
39
  " Or",
@@ -37,6 +42,26 @@
37
42
  "# Create a webOS service named 'com.domain.app.service'",
38
43
  "ares-generate -t js_service -s \"com.domain.app.service\" ~/projects/service",
39
44
  ""
45
+ ],
46
+ "apollo" : [
47
+ "# Create a webOS app in ~/project/app and set the id, version, title",
48
+ "ares-generate -t webapp -p \"{'id':'com.domain.app', 'version':'1.0.0', 'title':'First App'}\" ~/projects/app",
49
+ " Or",
50
+ "ares-generate -t webapp -p \"id=com.domain.app\" -p \"version=1.0.0\" -p \"title=First App\" ~/projects/app",
51
+ "",
52
+ "# Create a webOS service named 'com.domain.app.service'",
53
+ "ares-generate -t js_service -s \"com.domain.app.service\" ~/projects/service",
54
+ ""
55
+ ],
56
+ "tv" : [
57
+ "# Create a webOS app in ~/project/app and set the id, version, title",
58
+ "ares-generate -t basic -p \"{'id':'com.domain.app', 'version':'1.0.0', 'title':'First App'}\" ~/projects/app",
59
+ " Or",
60
+ "ares-generate -t basic -p \"id=com.domain.app\" -p \"version=1.0.0\" -p \"title=First App\" ~/projects/app",
61
+ "",
62
+ "# Create a webOS service named 'com.domain.app.service'",
63
+ "ares-generate -t js_service -s \"com.domain.app.service\" ~/projects/service",
64
+ ""
40
65
  ]
41
66
  }
42
67
  ],
@@ -44,6 +69,7 @@
44
69
  "cmdOpt":"option",
45
70
  "default" : ["template", "list", "property", "servicename", "overwrite", "help", "version", "verbose"],
46
71
  "ose" : ["level"],
72
+ "apollo" : ["level"],
47
73
  "template" : [
48
74
  "-t, --template <TEMPLATE> @TAB@ Use the template named TEMPLATE"
49
75
  ],
@@ -4,6 +4,7 @@
4
4
  "notab":["examples", "extraexample"],
5
5
  "name" : {
6
6
  "ose" : "ares-inspect - Enable Web Inspector or Node's Inspector for webOS web app or service",
7
+ "apollo" : "ares-inspect - Enable Web Inspector or Node's Inspector for webOS web app or service",
7
8
  "tv" : "ares-inspect - Provide URL to use Remote Web Inspector or Node Inspector"
8
9
  },
9
10
  "synopsis" : {
@@ -23,6 +24,10 @@
23
24
  "ose" : [
24
25
  "",
25
26
  "LEVEL is priority of logs. (e.g., silly, verbose, info, warn, error)"
27
+ ],
28
+ "apollo" : [
29
+ "",
30
+ "LEVEL is priority of logs. (e.g., silly, verbose, info, warn, error)"
26
31
  ]
27
32
  }
28
33
  ],
@@ -30,6 +35,7 @@
30
35
  "cmdOpt":"option",
31
36
  "default" : ["open", "device", "device-list", "help", "version", "verbose"],
32
37
  "ose" : ["display", "level"],
38
+ "apollo" : ["display", "level"],
33
39
  "open" : "-o, --open @TAB@ Open url with a web browser",
34
40
  "device" : [
35
41
  "-d, --device <DEVICE> @TAB@ Specify DEVICE to use",
@@ -19,6 +19,10 @@
19
19
  "ose" : [
20
20
  "",
21
21
  "LEVEL is priority of logs. (e.g., silly, verbose, info, warn, error)"
22
+ ],
23
+ "apollo" : [
24
+ "",
25
+ "LEVEL is priority of logs. (e.g., silly, verbose, info, warn, error)"
22
26
  ]
23
27
  }
24
28
  ],
@@ -40,6 +44,7 @@
40
44
  "cmdOpt":"option",
41
45
  "default" : ["device", "device-list", "list", "listfull", "type", "help", "version", "verbose"],
42
46
  "ose" : ["level"],
47
+ "apollo" : ["level"],
43
48
  "device" : [
44
49
  "-d, --device <DEVICE> @TAB@ Specify DEVICE to use",
45
50
  "@TAB@ If not specified, set to default device"
@@ -30,6 +30,10 @@
30
30
  "",
31
31
  "LEVEL is priority of logs. (e.g., silly, verbose, info, warn, error)"
32
32
  ],
33
+ "apollo" : [
34
+ "",
35
+ "LEVEL is priority of logs. (e.g., silly, verbose, info, warn, error)"
36
+ ],
33
37
  "tv" : [
34
38
  "",
35
39
  "If 'hosted' option does not work with network connection error,",
@@ -41,6 +45,7 @@
41
45
  "cmdOpt":"option",
42
46
  "default" : ["running", "close", "params"],
43
47
  "ose" : ["hosted", "display", "device", "device-list", "help", "version", "verbose", "level"],
48
+ "apollo" : ["hosted", "device", "device-list", "help", "version", "verbose", "level"],
44
49
  "tv" : ["device", "device-list", "help", "version", "verbose"],
45
50
  "device" : [
46
51
  "-d, --device <DEVICE> @TAB@ Specify DEVICE to use",
@@ -10,6 +10,7 @@
10
10
  "cmdOpt":"option",
11
11
  "default" : ["port", "open","help", "version", "verbose"],
12
12
  "ose" : ["level"],
13
+ "apollo" : ["level"],
13
14
  "port" : "-p, --port <PORT> @TAB@ Specify port to use [default:random]",
14
15
  "open" : "-o, --open @TAB@ Open localhost url with a web browser",
15
16
  "help" : "-h, --help @TAB@ Display this help",
@@ -25,6 +26,10 @@
25
26
  "ose" : [
26
27
  "",
27
28
  "LEVEL is priority of logs. (e.g., silly, verbose, info, warn, error)"
29
+ ],
30
+ "apollo" : [
31
+ "",
32
+ "LEVEL is priority of logs. (e.g., silly, verbose, info, warn, error)"
28
33
  ]
29
34
  }
30
35
  ],
@@ -32,6 +32,24 @@
32
32
  "",
33
33
  "LEVEL is priority of logs. (e.g., silly, verbose, info, warn, error)"
34
34
  ],
35
+ "apollo": [
36
+ "This command manages the information of the devices.",
37
+ "",
38
+ "** Attributes of DEVICE_INFO **",
39
+ " description [string] description of target device",
40
+ " host [string] ip address",
41
+ " port [string] port number",
42
+ " username [string] user name to connect ('developer')",
43
+ " privatekey [string] ssh private key file name",
44
+ " ssh private key should exist under $HOME/.ssh/",
45
+ " password [string] password for ssh connection",
46
+ " default [boolean] set default device with 'add' option",
47
+ "",
48
+ "This command can set a default device.",
49
+ "If you don't specify a target device, the default device is used as the target device.",
50
+ "",
51
+ "LEVEL is priority of logs. (e.g., silly, verbose, info, warn, error)"
52
+ ],
35
53
  "tv": [
36
54
  "This command manages the information of the devices.",
37
55
  "",
@@ -77,6 +95,28 @@
77
95
  "ares-setup-device -m DEVICE -i \"password=\"",
78
96
  ""
79
97
  ],
98
+ "apollo" : [
99
+ "",
100
+ "# Add a DEVICE and set the username, host, port",
101
+ "ares-setup-device -a DEVICE -i \"{'username':'root', 'host':'127.0.0.1','port':'22'}\"",
102
+ " Or",
103
+ "ares-setup-device -a DEVICE -i \"username=root\" -i \"host=127.0.0.1\" -i \"port=22\"",
104
+ "",
105
+ "# Modify the information of the DEVICE",
106
+ "ares-setup-device -m DEVICE -i \"{'username':'developer','host':'192.168.0.123'}\"",
107
+ " Or",
108
+ "ares-setup-device -m DEVICE -i \"username=developer\" -i \"host=192.168.0.123\"",
109
+ "",
110
+ "# Remove the DEVICE",
111
+ "ares-setup-device -r DEVICE",
112
+ "",
113
+ "# Set default the DEVICE",
114
+ "ares-setup-device -f DEVICE",
115
+ "",
116
+ "# Change the ssh password of the DEVICE as an empty value",
117
+ "ares-setup-device -m DEVICE -i \"password=\"",
118
+ ""
119
+ ],
80
120
  "tv" : [
81
121
  "",
82
122
  "# Add a DEVICE and set the username, host, port",
@@ -18,6 +18,10 @@
18
18
  "ose" : [
19
19
  "",
20
20
  "LEVEL is priority of logs. (e.g., silly, verbose, info, warn, error)"
21
+ ],
22
+ "apollo" : [
23
+ "",
24
+ "LEVEL is priority of logs. (e.g., silly, verbose, info, warn, error)"
21
25
  ]
22
26
  }
23
27
  ],
@@ -33,6 +37,7 @@
33
37
  "cmdOpt":"option",
34
38
  "default" : ["list", "<COMMAND>", "help", "version"],
35
39
  "ose" : ["verbose", "level"],
40
+ "apollo" : ["verbose", "level"],
36
41
  "list" : [
37
42
  "-l, --list @TAB@ List all the ares commands"
38
43
  ],
@@ -16,7 +16,8 @@
16
16
  "profile": {
17
17
  "enum": [
18
18
  "ose",
19
- "tv"
19
+ "tv",
20
+ "apollo"
20
21
  ],
21
22
  "description": "webOS Device Type"
22
23
  },
@@ -0,0 +1,10 @@
1
+ {
2
+ "id": "com.domain.app",
3
+ "version": "1.0.0",
4
+ "vendor": "My Company",
5
+ "type": "web",
6
+ "main": "index.html",
7
+ "title": "new app",
8
+ "icon": "icon.png",
9
+ "requiredPermissions": ["time.query", "activity.operation"]
10
+ }
@@ -0,0 +1,88 @@
1
+ <!--
2
+ Copyright (c) 2020-2024 LG Electronics Inc.
3
+
4
+ SPDX-License-Identifier: Apache-2.0
5
+ -->
6
+
7
+ <!DOCTYPE html>
8
+ <html>
9
+ <head>
10
+ <title>Example Web App</title>
11
+ <style type="text/css">
12
+ body {
13
+ width: 100%;
14
+ height: 100%;
15
+ background-color:#202020;
16
+ }
17
+ div {
18
+ position:absolute;
19
+ height:100%;
20
+ width:100%;
21
+ display: table;
22
+ }
23
+ h1 {
24
+ display: table-cell;
25
+ vertical-align: middle;
26
+ text-align:center;
27
+ color:#FFFFFF;
28
+ }
29
+ </style>
30
+ <script type="text/javascript">
31
+ window.onload = function() {
32
+ var bridge = new WebOSServiceBridge();
33
+ /*
34
+ * getTimeApi calls gettime of systemservice, a module in the platform.
35
+ */
36
+ var getTimeApi = 'luna://com.webos.service.systemservice/clock/getTime';
37
+ var getTimeParams = '{}';
38
+
39
+ /*
40
+ * helloApi calls the hello method of js_service template provided by CLI.
41
+ * In this case, the service name is used as default name "com.domain.app.service" is.
42
+ * If you change this service name, you need to change the service name of the following API.
43
+ *
44
+ * If you change the name to helloParmas as you want, the contents will be reflected on the screen.
45
+ */
46
+ var helloApi = 'luna://com.domain.app.service/hello';
47
+ var helloParams = '{"name":"webOS"}';
48
+
49
+ function getTime_callback(msg){
50
+ var arg = JSON.parse(msg);
51
+ if (arg.returnValue) {
52
+ console.log("[APP_NAME: example web app] GETTIME_SUCCESS UTC : " + arg.utc);
53
+ //webOSSystem.PmLogString(6, "GETTIME_SUCCESS", '{"APP_NAME": "example web app"}', "UTC : " + arg.utc);
54
+ }
55
+ else {
56
+ console.error("[APP_NAME: example web app] GETTIME_FAILED errorText : " + arg.errorText);
57
+ //webOSSystem.PmLogString(3, "GETTIME_FAILED", '{"APP_NAME": "example web app"}', "errorText : " + arg.errorText);
58
+ }
59
+ }
60
+
61
+ function hello_callback(msg){
62
+ var arg = JSON.parse(msg);
63
+ if (arg.returnValue) {
64
+ document.getElementById("txt_msg").innerHTML = arg.Response;
65
+ console.log("[APP_NAME: example web app] CALLHELLO_SUCCESS response : " + arg.Response);
66
+ //webOSSystem.PmLogString(6, "CALLHELLO_SUCCESS", '{"APP_NAME": "example web app"}', "response : " + arg.Response);
67
+ }
68
+ else {
69
+ console.error("[APP_NAME: example web app] CALLHELLO_FAILED errorText : " + arg.errorText);
70
+ //webOSSystem.PmLogString(3, "CALLHELLO_FAILED", '{"APP_NAME": "example web app"}', "errorText : " + arg.errorText);
71
+ }
72
+ }
73
+
74
+ bridge.onservicecallback = getTime_callback;
75
+ bridge.call(getTimeApi, getTimeParams);
76
+ document.getElementById("txt_msg").onclick = function() {
77
+ bridge.onservicecallback = hello_callback;
78
+ bridge.call(helloApi, helloParams);
79
+ };
80
+ }
81
+ </script>
82
+ </head>
83
+ <body>
84
+ <div>
85
+ <h1 id="txt_msg">Hello, Web Application!!</h1>
86
+ </div>
87
+ </body>
88
+ </html>
@@ -0,0 +1,14 @@
1
+ <!--
2
+ Copyright (c) 2020-2024 LG Electronics Inc.
3
+
4
+ SPDX-License-Identifier: Apache-2.0
5
+ -->
6
+
7
+ <!DOCTYPE html>
8
+ <html>
9
+ <head>
10
+ <script>location.href='http://webosose.org/';</script>
11
+ </head>
12
+ <body>
13
+ </body>
14
+ </html>
@@ -0,0 +1,31 @@
1
+ /*
2
+ * Copyright (c) 2020-2024 LG Electronics Inc.
3
+ *
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ // helloclient.js
8
+ // Subscribe & cancel subscription to helloService's heartbeat method
9
+ const Service = require('webos-service');
10
+
11
+ const service = new Service("com.example.helloclient"); // Register com.example.helloworld
12
+
13
+ console.log("simple call");
14
+ // Change @SERVICE-NAME@ to real service name
15
+ service.call("luna://@SERVICE-NAME@/hello", {}, function(message) {
16
+ console.log("call @SERVICE-NAME@/hello");
17
+ console.log("message payload: " + JSON.stringify(message.payload));
18
+ const sub = service.subscribe("luna://@SERVICE-NAME@/heartbeat", {subscribe: true});
19
+ const max = 10;
20
+ let count = 0;
21
+ sub.addListener("response", function(msg) {
22
+ console.log(JSON.stringify(msg.payload));
23
+ if (++count >= max) {
24
+ sub.cancel();
25
+ setTimeout(function() {
26
+ console.log(max+" responses received, exiting...");
27
+ process.exit(0);
28
+ }, 1000);
29
+ }
30
+ });
31
+ });