marp-dev-preview 0.1.5 → 0.1.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/README.md +57 -29
- package/package.json +4 -4
- package/{marp-dev-preview.mjs → src/marp-dev-preview.mjs} +1 -1
- package/{args.test.mjs → test/args.test.mjs} +1 -1
- package/{marp-dev-preview.test.mjs → test/marp-dev-preview.test.mjs} +1 -1
- package/{marp-utils.test.mjs → test/marp-utils.test.mjs} +1 -1
- /package/{args.mjs → src/args.mjs} +0 -0
- /package/{client.js → src/client.js} +0 -0
- /package/{marp-utils.mjs → src/marp-utils.mjs} +0 -0
- /package/{server.mjs → src/server.mjs} +0 -0
package/README.md
CHANGED
|
@@ -84,35 +84,63 @@ In addition to normal browser navigation keys (`Page Up`, `Page Down`, `Home`, `
|
|
|
84
84
|
|
|
85
85
|
---
|
|
86
86
|
|
|
87
|
-
## 🔗
|
|
88
|
-
|
|
89
|
-
The preview server exposes a simple **HTTP API** for controlling slides.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
87
|
+
## 🔗 API Endpoints
|
|
88
|
+
|
|
89
|
+
The preview server exposes a simple **HTTP API** for controlling slides and content.
|
|
90
|
+
|
|
91
|
+
### `POST /api/reload`
|
|
92
|
+
|
|
93
|
+
Reloads the presentation with new markdown content. The server parses the received markdown, renders it into HTML, and broadcasts the changes to all connected clients. This is ideal for tools that need to push updates without requiring a full page refresh.
|
|
94
|
+
|
|
95
|
+
- **Request**:
|
|
96
|
+
- **Headers**: `Content-Type: text/markdown`
|
|
97
|
+
- **Body**: Raw markdown content.
|
|
98
|
+
|
|
99
|
+
- **Response**:
|
|
100
|
+
- `200 OK`: `{ "status": "ok" }` on success.
|
|
101
|
+
- `500 Internal Server Error`: `{ "status": "error", "message": "..." }` on failure.
|
|
102
|
+
|
|
103
|
+
- **Example**:
|
|
104
|
+
```bash
|
|
105
|
+
curl -X POST \
|
|
106
|
+
-H "Content-Type: text/markdown" \
|
|
107
|
+
-d "$(cat path/to/your/slides.md)" \
|
|
108
|
+
http://localhost:8080/api/reload
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### `POST /api/command`
|
|
112
|
+
|
|
113
|
+
Sends a command to the browser to control the presentation's navigation. This allows external tools to programmatically change the visible slide.
|
|
114
|
+
|
|
115
|
+
- **Request**:
|
|
116
|
+
- **Headers**: `Content-Type: application/json`
|
|
117
|
+
- **Body**: A JSON object describing the command.
|
|
118
|
+
|
|
119
|
+
- **Response**:
|
|
120
|
+
- `200 OK`: `{ "status": "ok", "command": { ... } }` on success.
|
|
121
|
+
- `400 Bad Request`: `{ "status": "error", "message": "Invalid JSON" }` if the body is malformed.
|
|
122
|
+
|
|
123
|
+
#### Supported Commands
|
|
124
|
+
|
|
125
|
+
1. **`goto`**: Jumps to a specific slide number.
|
|
126
|
+
- **Payload**: `{ "command": "goto", "slide": <number> }`
|
|
127
|
+
- **Example**:
|
|
128
|
+
```bash
|
|
129
|
+
curl -X POST \
|
|
130
|
+
-H "Content-Type: application/json" \
|
|
131
|
+
-d '{"command": "goto", "slide": 5}' \
|
|
132
|
+
http://localhost:8080/api/command
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
2. **`find`**: Searches for a string and jumps to the first slide containing it. The search is case-insensitive.
|
|
136
|
+
- **Payload**: `{ "command": "find", "string": "<search-term>" }`
|
|
137
|
+
- **Example**:
|
|
138
|
+
```bash
|
|
139
|
+
curl -X POST \
|
|
140
|
+
-H "Content-Type: application/json" \
|
|
141
|
+
-d '{"command": "find", "string": "My Awesome Slide"}' \
|
|
142
|
+
http://localhost:8080/api/command
|
|
143
|
+
```
|
|
116
144
|
|
|
117
145
|
|
|
118
146
|
---
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "marp-dev-preview",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "A CLI tool to preview Marp markdown files.",
|
|
5
|
-
"main": "marp-dev-preview.mjs",
|
|
5
|
+
"main": "src/marp-dev-preview.mjs",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
8
|
-
"mdp": "marp-dev-preview.mjs"
|
|
8
|
+
"mdp": "src/marp-dev-preview.mjs"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
|
-
"start": "node marp-dev-preview.mjs",
|
|
11
|
+
"start": "node src/marp-dev-preview.mjs",
|
|
12
12
|
"test": "jest"
|
|
13
13
|
},
|
|
14
14
|
"keywords": [
|
|
@@ -21,7 +21,7 @@ const port = argv.port;
|
|
|
21
21
|
const verbose = argv.verbose;
|
|
22
22
|
|
|
23
23
|
if (argv.version) {
|
|
24
|
-
const pkg = JSON.parse(await fs.readFile(path.join(__dirname, 'package.json'), 'utf8'));
|
|
24
|
+
const pkg = JSON.parse(await fs.readFile(path.join(__dirname, '..', 'package.json'), 'utf8'));
|
|
25
25
|
console.log(`marp-dev-preview version ${pkg.version}`);
|
|
26
26
|
process.exit(0);
|
|
27
27
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|