@unitn-asa/deliveroo-js-sdk 1.2.3 → 1.2.6

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.
package/LICENSE.md ADDED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unitn-asa/deliveroo-js-sdk",
3
- "version": "1.2.3",
3
+ "version": "1.2.6",
4
4
  "description": "Software development kit for Deliveroo.js",
5
5
  "author": "Marco Robol <marco.robol@unitn.it>",
6
6
  "type": "module",
@@ -24,9 +24,6 @@
24
24
  "scripts": {
25
25
  "test": "node test/DeliveroojsApiClient.test.js"
26
26
  },
27
- "dependencies": {
28
- "args-parser": "^1.3.0"
29
- },
30
27
  "peerDependencies": {
31
28
  "socket.io": "^4.7.2",
32
29
  "socket.io-client": "^4.7.2"
@@ -34,5 +31,8 @@
34
31
  "publishConfig": {
35
32
  "access": "public"
36
33
  },
37
- "gitHead": "66b8c3ba9a75eb7c81e08a500fd3c216c5791f8c"
34
+ "gitHead": "aafc2442cb50b860033f5196e4a30b410b9959fd",
35
+ "dependencies": {
36
+ "getopts": "^2.3.0"
37
+ }
38
38
  }
@@ -1,24 +1,33 @@
1
1
  import { io } from "socket.io-client";
2
- import { default as argsparser } from "args-parser";
3
2
  import { DjsClientSocket } from "./DjsClientSocket.js";
4
-
5
-
6
-
7
3
  /**
8
- * Takes the following arguments from console:
9
- * token or name
10
- * e.g:
11
- * $ node index.js -token=... -name=marco
12
- * $ npm start -- -token=... -name=marco
4
+ * Get command-line arguments for token and name (Node.js only)
5
+ * Usage: npm run dev -- -token=... -name=... -host=...
13
6
  */
14
- const args = argsparser(process? process?.argv : []);
7
+ function getArgs() {
8
+ if (typeof process !== 'undefined' && process?.argv) {
9
+ // Dynamic import only in Node.js environment
10
+ try {
11
+ const getopts = require('getopts');
12
+ return getopts(process.argv, {
13
+ string: ['token', 'name', 'host'],
14
+ });
15
+ } catch {
16
+ // Fallback if require doesn't work (e.g., in bundler)
17
+ return { token: undefined, name: undefined, host: undefined };
18
+ }
19
+ }
20
+ return { token: undefined, name: undefined, host: undefined };
21
+ }
22
+
23
+ const args = getArgs();
15
24
 
16
25
 
17
26
 
18
27
  /**
19
28
  * @returns { DjsClientSocket }
20
29
  */
21
- export function DjsConnect ( host, token = args['token'], name = args['name'], autoconnect = true ) {
30
+ export function DjsConnect ( host = args['host'] || process.env.HOST, token = args['token'] || process.env.TOKEN, name = args['name'] || process.env.NAME, autoconnect = true ) {
22
31
 
23
32
  let opts = {
24
33
  autoConnect: false,