Skip to content

Commit 549c75f

Browse files
committed
docs: ✏️ update decomentation
1 parent fadc09d commit 549c75f

4 files changed

Lines changed: 49 additions & 2 deletions

File tree

website/docs/error-plugin.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,24 @@ When an error is thrown, the plugin does the following:
9898
```
9999
* [emit](/docs/event-emitter-plugin#emit) `ERROR` event with thrown error
100100
* Re-runs the function (if defined)
101+
102+
The error object is available everywhere in the widget, as well as to the host application.
103+
104+
## Limitations
105+
106+
The plugin can't handle errors occurring outside of lifecycle functions.
107+
108+
## Custom errors
109+
110+
You can throw custom errors by instantiating `GenericError` class or create custom error classes that extend `GenericError`.
111+
112+
`GenericError` class carries `status` param among with other params. This way error plugin can respond with adequate HTTP status and also include data for encountered error.
113+
114+
```javascript
115+
import { GenericError } from '@merkur/plugin-error';
116+
117+
throw new GenericError('Operation failed.', {
118+
status: 500,
119+
reason: 'api_error'
120+
})
121+
```

website/docs/integration-with-app.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,3 +347,30 @@ return (
347347
</MerkurSlot>
348348
)
349349
```
350+
351+
## Merkur Dev Client
352+
When integrating Merkur widgets into an existing application, developers often face challenges with the development workflow - particularly with hot module replacement (HMR). The Merkur Dev Client solves this problem by bringing the same seamless development experience you get in the playground directly to your integrated application.
353+
### Bringing Playground Experience to Your Application
354+
The Merkur Dev Client enables the same fluid development experience you enjoy in the playground environment when working with your widget in any integrated application:
355+
- **Real-time Widget Updates**: Edit your widget code and see changes instantly in your application
356+
- **No Application Refreshes**: Updates are applied without reloading the entire application
357+
- **Preserve Application State**: Keep authentication, form inputs, and application context intact during development
358+
### Enabling the Dev Client
359+
To enable the Dev Client in your host application, simply add the following script tag to your HTML head:
360+
```html
361+
<script src="http://localhost:4445/__dev__/js/merkurDevClient.js"></script>
362+
```
363+
For server-side templates (like EJS), you can conditionally include it only in development mode:
364+
```ejs
365+
<% if (process.env.NODE_ENV === 'development') { %>
366+
<script src="http://localhost:4445/__dev__/js/merkurDevClient.js"></script>
367+
<% } %>
368+
```
369+
### How Dev Client Works
370+
The Dev Client works by:
371+
1. Establishing a WebSocket connection to your Merkur dev server
372+
2. Monitoring changes to Merkur widget assets (scripts, styles)
373+
3. Automatically replacing or updating affected assets when changes are detected
374+
4. Hooking into the Merkur widget creation process to track active widgets within your application
375+
Assets are tracked using the `data-merkur-asset-name` attribute, which the Dev Client uses to identify and update them without reloading the entire application page.
376+
The Dev Client is automatically configured when running your widget in development mode with the Merkur CLI (`merkur dev`), and only requires adding a single script tag to your host application.

website/docs/merkur-cli.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Merkur CLI for building your widget use [esbuild](https://esbuild.github.io/) to
1010

1111
## Commands
1212

13-
- `merkur dev` - build your widget with with NODE_ENV = 'development' and with watch mode
13+
- `merkur dev` - build your widget with NODE_ENV = 'development' and with watch mode. Enables [Merkur Dev Client](/docs/integration-with-app#merkur-dev-client) for hot module replacement
1414
- `merkur build` - build your widget with NODE_ENV = 'production'
1515
- `merkur test` - run defined widget tests with NODE_ENV = 'test'
1616
- `merkur start` - run widget server and playground server

website/docs/storybook-integration-into-merkur.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,3 @@ TenCounter.args = {
122122
```
123123

124124
Now run command `npm run storybook` and you will see our Counter component with two settings.
125-
```

0 commit comments

Comments
 (0)