safaridriver 0.0.2 → 0.0.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.
@@ -0,0 +1,3 @@
1
+ declare const start: (options: never) => Promise<import("child_process").ChildProcess>;
2
+ declare const stop: () => Promise<void>;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cjs/index.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,KAAK,YAA4C,KAAK,kDAG3D,CAAA;AAED,QAAA,MAAM,IAAI,qBAGT,CAAA"}
@@ -0,0 +1,10 @@
1
+ const start = exports.start = async function (options) {
2
+ const driver = await import('../index.js');
3
+ return driver.start(options);
4
+ };
5
+ const stop = exports.stop = async function () {
6
+ const driver = await import('../index.js');
7
+ return driver.stop();
8
+ };
9
+ module.exports = { start, stop };
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cjs/index.ts"],"names":[],"mappings":"AAAA,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,GAAG,KAAK,WAAW,OAAc;IACxD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,CAAA;IAC1C,OAAO,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;AAChC,CAAC,CAAA;AAED,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,GAAG,KAAK;IAC7B,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,CAAA;IAC1C,OAAO,MAAM,CAAC,IAAI,EAAE,CAAA;AACxB,CAAC,CAAA;AAED,MAAM,CAAC,OAAO,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,CAAA"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,41 @@
1
+ import cp from 'node:child_process';
2
+ export declare const DEFAULT_PATH = "/usr/bin/safaridriver";
3
+ export declare const DEFAULT_PORT = 4444;
4
+ interface SafaridriverOptions {
5
+ /**
6
+ * Specifies the port on which the HTTP server should listen for incoming connections.
7
+ * If the port is already in use or otherwise unavailable, Safaridriver will exit
8
+ * immediately with a non-zero return code.
9
+ * @default 4444
10
+ */
11
+ port?: number;
12
+ /**
13
+ * Path to Safaridriver binary.
14
+ * @default /usr/bin/safaridriver
15
+ */
16
+ path?: string;
17
+ /**
18
+ * Applies configuration changes so that subsequent WebDriver sessions will run without
19
+ * further authentication. This includes checking "Enable Remote Automation" in Safari's
20
+ * `Develop` menu. The user must authenticate via password for the changes to be applied.
21
+ *
22
+ * When this option is specified, safaridriver exits immediately without starting up the
23
+ * REST API service. If the changes were successful or already applied, safaridriver exits 0;
24
+ * otherwise, safaridriver exits >0 and prints an error message to stderr.
25
+ * @default false
26
+ */
27
+ enable?: boolean;
28
+ /**
29
+ * Enables diagnostic logging for all sessions hosted by this safaridriver instance.
30
+ * @default false
31
+ */
32
+ diagnose?: boolean;
33
+ }
34
+ export declare const start: (options?: SafaridriverOptions) => cp.ChildProcess;
35
+ export declare const stop: () => void;
36
+ declare const _default: {
37
+ start: (options?: SafaridriverOptions) => cp.ChildProcess;
38
+ stop: () => void;
39
+ };
40
+ export default _default;
41
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,MAAM,oBAAoB,CAAA;AAE1D,eAAO,MAAM,YAAY,0BAA0B,CAAA;AACnD,eAAO,MAAM,YAAY,OAAO,CAAA;AAEhC,UAAU,mBAAmB;IACzB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;;;;;;;OASG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;CACrB;AAID,eAAO,MAAM,KAAK,aAAa,mBAAmB,oBAoBjD,CAAA;AAED,eAAO,MAAM,IAAI,YAKhB,CAAA;;;;;AAED,wBAA8B"}
package/dist/index.js ADDED
@@ -0,0 +1,30 @@
1
+ import cp from 'node:child_process';
2
+ export const DEFAULT_PATH = '/usr/bin/safaridriver';
3
+ export const DEFAULT_PORT = 4444;
4
+ let instance;
5
+ let instanceOptions;
6
+ export const start = (options = {}) => {
7
+ const port = typeof options.port === 'number' ? options.port : DEFAULT_PORT;
8
+ const args = [`--port=${port}`];
9
+ const driverPath = options.path || DEFAULT_PATH;
10
+ if (options.enable) {
11
+ args.push('--enable');
12
+ }
13
+ if (options.diagnose) {
14
+ args.push('--diagnose');
15
+ }
16
+ if (instance) {
17
+ throw new Error(`There is already a Safaridriver instance running on port ${instanceOptions.port}!`);
18
+ }
19
+ instanceOptions = options;
20
+ instance = cp.execFile(driverPath, args);
21
+ return instance;
22
+ };
23
+ export const stop = () => {
24
+ if (instance) {
25
+ instance.kill();
26
+ instance = undefined;
27
+ }
28
+ };
29
+ export default { start, stop };
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,MAAM,oBAAoB,CAAA;AAE1D,MAAM,CAAC,MAAM,YAAY,GAAG,uBAAuB,CAAA;AACnD,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAA;AAiChC,IAAI,QAAsB,CAAA;AAC1B,IAAI,eAAoC,CAAA;AACxC,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,UAA+B,EAAE,EAAE,EAAE;IACvD,MAAM,IAAI,GAAG,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAA;IAC3E,MAAM,IAAI,GAAa,CAAC,UAAU,IAAI,EAAE,CAAC,CAAA;IACzC,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,IAAI,YAAY,CAAA;IAE/C,IAAI,OAAO,CAAC,MAAM,EAAE;QAChB,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;KACxB;IAED,IAAI,OAAO,CAAC,QAAQ,EAAE;QAClB,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;KAC1B;IAED,IAAI,QAAQ,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,4DAA4D,eAAe,CAAC,IAAI,GAAG,CAAC,CAAA;KACvG;IAED,eAAe,GAAG,OAAO,CAAA;IACzB,QAAQ,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;IACxC,OAAO,QAAQ,CAAA;AACnB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,IAAI,GAAG,GAAG,EAAE;IACrB,IAAI,QAAQ,EAAE;QACV,QAAQ,CAAC,IAAI,EAAE,CAAA;QACf,QAAQ,GAAG,SAAS,CAAA;KACvB;AACL,CAAC,CAAA;AAED,eAAe,EAAE,KAAK,EAAE,IAAI,EAAE,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "safaridriver",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "author": "Christian Bromann <mail@bromann.dev>",
5
5
  "license": "MIT",
6
6
  "description": "An NPM wrapper for handling the Safaridriver binary.",