mockaton 8.11.7 → 8.11.8

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/README.md CHANGED
@@ -497,11 +497,8 @@ config.corsExposedHeaders = [] // headers you need to access in client-side JS
497
497
 
498
498
  ### `onReady?: (dashboardUrl: string) => void`
499
499
  By default, it will open the dashboard in your default browser on macOS and
500
- Windows. But for a more cross-platform utility, you could `npm install open` and pass it.
501
- ```js
502
- import open from 'open'
503
- config.onReady = open
504
- ```
500
+ Windows. But for a more cross-platform utility you could `npm install open` and
501
+ Mockaton will use that implementation instead.
505
502
 
506
503
  If you don’t want to open a browser, pass a noop:
507
504
  ```js
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "mockaton",
3
3
  "description": "A deterministic server-side for developing and testing frontend clients",
4
4
  "type": "module",
5
- "version": "8.11.7",
5
+ "version": "8.11.8",
6
6
  "main": "index.js",
7
7
  "types": "index.d.ts",
8
8
  "license": "MIT",
@@ -15,6 +15,7 @@
15
15
  "outdated": "npm outdated --parseable | awk -F: '{ printf \"npm i %-30s ;# %s\\n\", $4, $2 }'"
16
16
  },
17
17
  "optionalDependencies": {
18
+ "open": "^10.0.0",
18
19
  "pixaton": ">=1.0.2",
19
20
  "puppeteer": ">=24.1.1"
20
21
  }
package/src/config.js CHANGED
@@ -34,7 +34,7 @@ export const config = Object.seal({
34
34
  corsCredentials: true,
35
35
  corsMaxAge: 0,
36
36
 
37
- onReady: openInBrowser
37
+ onReady: await openInBrowser
38
38
  })
39
39
 
40
40
 
@@ -1,7 +1,16 @@
1
1
  import { exec } from 'node:child_process'
2
2
 
3
3
 
4
- export function openInBrowser(address) {
4
+ export const openInBrowser = (async () => {
5
+ try {
6
+ return (await import('open')).default
7
+ }
8
+ catch (error) {
9
+ return _openInBrowser
10
+ }
11
+ })()
12
+
13
+ function _openInBrowser(address) {
5
14
  switch (process.platform) {
6
15
  case 'darwin':
7
16
  exec(`open ${address}`)