hyperbook 0.77.6 → 0.77.7

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.
Files changed (3) hide show
  1. package/README.md +109 -0
  2. package/dist/index.js +54 -1
  3. package/package.json +3 -3
package/README.md ADDED
@@ -0,0 +1,109 @@
1
+ # hyperbook
2
+
3
+ The main CLI tool for creating, building, and serving Hyperbook projects. Hyperbook is a quick and easy way to build interactive workbooks that support modern standards and run superfast.
4
+
5
+ ## Features
6
+
7
+ - **Quick Project Setup** - Scaffold new projects with `hyperbook new`
8
+ - **Development Server** - Live-reload development server with hot module replacement
9
+ - **Production Builds** - Optimized static site generation
10
+ - **Interactive Elements** - Support for 30+ custom directives (alerts, videos, code environments, etc.)
11
+ - **Multi-language Support** - Built-in i18n for 7 languages
12
+ - **Search** - Full-text search with Lunr.js
13
+ - **Navigation** - Automatic navigation generation from file structure
14
+ - **Themes** - Customizable colors and styling
15
+ - **Archives** - Downloadable file archives for students
16
+ - **Glossary** - Automatic term indexing and tooltips
17
+
18
+ ## Installation
19
+
20
+ Install globally:
21
+
22
+ ```sh
23
+ npm install -g hyperbook
24
+ # or
25
+ pnpm add -g hyperbook
26
+ ```
27
+
28
+ Or use directly with npx:
29
+
30
+ ```sh
31
+ npx hyperbook@latest new my-book
32
+ ```
33
+
34
+ ## Usage
35
+
36
+ ### Create a new Hyperbook project
37
+
38
+ ```sh
39
+ hyperbook new my-documentation
40
+ cd my-documentation
41
+ ```
42
+
43
+ ### Start development server
44
+
45
+ ```sh
46
+ hyperbook dev
47
+ # or with custom port
48
+ hyperbook dev --port 3000
49
+ ```
50
+
51
+ The development server will start at `http://localhost:8080` with live reload.
52
+
53
+ ### Build for production
54
+
55
+ ```sh
56
+ hyperbook build
57
+ ```
58
+
59
+ This generates a static site in the `public` directory ready for deployment.
60
+
61
+ ## Project Structure
62
+
63
+ A Hyperbook project consists of:
64
+
65
+ ```
66
+ my-book/
67
+ ├── hyperbook.json # Main configuration
68
+ ├── glossary.md # Glossary definitions
69
+ ├── book/ # Content directory
70
+ │ ├── index.md # Home page
71
+ │ ├── chapter1/
72
+ │ │ ├── index.md
73
+ │ │ └── page.md
74
+ │ └── chapter2/
75
+ │ └── index.md
76
+ └── public/ # Built output (after build)
77
+ ```
78
+
79
+ ## Configuration
80
+
81
+ The `hyperbook.json` file configures your project:
82
+
83
+ ```json
84
+ {
85
+ "name": "My Documentation",
86
+ "description": "Interactive documentation",
87
+ "language": "en",
88
+ "basePath": "",
89
+ "colors": {
90
+ "brand": "#3b82f6"
91
+ },
92
+ "links": [
93
+ {
94
+ "label": "GitHub",
95
+ "href": "https://github.com/org/repo"
96
+ }
97
+ ]
98
+ }
99
+ ```
100
+
101
+ ## Learn More
102
+
103
+ - **Documentation**: https://hyperbook.openpatch.org
104
+ - **Repository**: https://github.com/openpatch/hyperbook
105
+ - **Community**: https://matrix.to/#/#openpatch:matrix.org
106
+
107
+ ## License
108
+
109
+ MIT © Mike Barkmin
package/dist/index.js CHANGED
@@ -56006,7 +56006,60 @@ const mime_1 = __importDefault(__nccwpck_require__(94931));
56006
56006
  const ws_1 = __nccwpck_require__(55999);
56007
56007
  const chalk_1 = __importDefault(__nccwpck_require__(2434));
56008
56008
  const rimraf_1 = __nccwpck_require__(52114);
56009
+ const prompts_1 = __importDefault(__nccwpck_require__(63792));
56010
+ const net_1 = __importDefault(__nccwpck_require__(69278));
56011
+ async function isPortAvailable(port) {
56012
+ return new Promise((resolve) => {
56013
+ const server = net_1.default.createServer();
56014
+ server.once('error', (err) => {
56015
+ if (err.code === 'EADDRINUSE') {
56016
+ resolve(false);
56017
+ }
56018
+ else {
56019
+ resolve(false);
56020
+ }
56021
+ });
56022
+ server.once('listening', () => {
56023
+ server.close();
56024
+ resolve(true);
56025
+ });
56026
+ server.listen(port);
56027
+ });
56028
+ }
56029
+ async function findFreePort(startPort) {
56030
+ let port = startPort;
56031
+ while (port < 65535) {
56032
+ if (await isPortAvailable(port)) {
56033
+ return port;
56034
+ }
56035
+ port++;
56036
+ }
56037
+ throw new Error('No free ports available');
56038
+ }
56009
56039
  async function runDev({ port = 8080 }) {
56040
+ // Check if the port is available
56041
+ const portAvailable = await isPortAvailable(port);
56042
+ if (!portAvailable) {
56043
+ console.log(chalk_1.default.yellow(`Port ${port} is already in use.`));
56044
+ const response = await (0, prompts_1.default)({
56045
+ type: 'confirm',
56046
+ name: 'findFreePort',
56047
+ message: 'Would you like to find and use a free port?',
56048
+ initial: true
56049
+ });
56050
+ if (!response.findFreePort) {
56051
+ console.log(chalk_1.default.red('Exiting dev server.'));
56052
+ process.exit(0);
56053
+ }
56054
+ try {
56055
+ port = await findFreePort(port + 1);
56056
+ console.log(chalk_1.default.green(`Found free port: ${port}`));
56057
+ }
56058
+ catch (error) {
56059
+ console.error(chalk_1.default.red('Could not find a free port.'));
56060
+ process.exit(1);
56061
+ }
56062
+ }
56010
56063
  const root = process.cwd();
56011
56064
  const rootProject = await fs_1.hyperproject.get(root);
56012
56065
  const outDir = path_1.default.join(rootProject.src, ".hyperbook", "out");
@@ -201775,7 +201828,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"application/1d-interleaved-parityfec
201775
201828
  /***/ ((module) => {
201776
201829
 
201777
201830
  "use strict";
201778
- module.exports = /*#__PURE__*/JSON.parse('{"name":"hyperbook","version":"0.77.6","author":"Mike Barkmin","homepage":"https://github.com/openpatch/hyperbook#readme","license":"MIT","bin":{"hyperbook":"./dist/index.js"},"files":["dist"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/openpatch/hyperbook.git","directory":"packages/hyperbook"},"bugs":{"url":"https://github.com/openpatch/hyperbook/issues"},"engines":{"node":">=18"},"scripts":{"version":"pnpm build","lint":"tsc --noEmit","dev":"ncc build ./index.ts -w -o dist/","build":"rimraf dist && ncc build ./index.ts -o ./dist/ --no-cache --no-source-map-register --external favicons --external sharp && node postbuild.mjs"},"dependencies":{"favicons":"^7.2.0"},"devDependencies":{"create-hyperbook":"workspace:*","@hyperbook/fs":"workspace:*","@hyperbook/markdown":"workspace:*","@hyperbook/types":"workspace:*","@pnpm/exportable-manifest":"1000.0.6","@types/archiver":"6.0.3","@types/async-retry":"1.4.9","@types/cross-spawn":"6.0.6","@types/lunr":"^2.3.7","@types/prompts":"2.4.9","@types/tar":"6.1.13","@types/ws":"^8.5.14","@vercel/ncc":"0.38.3","archiver":"7.0.1","async-retry":"1.3.3","chalk":"5.4.1","chokidar":"4.0.3","commander":"12.1.0","cpy":"11.1.0","cross-spawn":"7.0.6","domutils":"^3.2.2","extract-zip":"^2.0.1","got":"12.6.0","htmlparser2":"^10.0.0","lunr":"^2.3.9","lunr-languages":"^1.14.0","mime":"^4.0.6","prompts":"2.4.2","rimraf":"6.0.1","tar":"7.4.3","update-check":"1.5.4","ws":"^8.18.0"}}');
201831
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"hyperbook","version":"0.77.7","author":"Mike Barkmin","homepage":"https://github.com/openpatch/hyperbook#readme","license":"MIT","bin":{"hyperbook":"./dist/index.js"},"files":["dist"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/openpatch/hyperbook.git","directory":"packages/hyperbook"},"bugs":{"url":"https://github.com/openpatch/hyperbook/issues"},"engines":{"node":">=18"},"scripts":{"version":"pnpm build","lint":"tsc --noEmit","dev":"ncc build ./index.ts -w -o dist/","build":"rimraf dist && ncc build ./index.ts -o ./dist/ --no-cache --no-source-map-register --external favicons --external sharp && node postbuild.mjs"},"dependencies":{"favicons":"^7.2.0"},"devDependencies":{"create-hyperbook":"workspace:*","@hyperbook/fs":"workspace:*","@hyperbook/markdown":"workspace:*","@hyperbook/types":"workspace:*","@pnpm/exportable-manifest":"1000.0.6","@types/archiver":"6.0.3","@types/async-retry":"1.4.9","@types/cross-spawn":"6.0.6","@types/lunr":"^2.3.7","@types/prompts":"2.4.9","@types/tar":"6.1.13","@types/ws":"^8.5.14","@vercel/ncc":"0.38.3","archiver":"7.0.1","async-retry":"1.3.3","chalk":"5.4.1","chokidar":"4.0.3","commander":"12.1.0","cpy":"11.1.0","cross-spawn":"7.0.6","domutils":"^3.2.2","extract-zip":"^2.0.1","got":"12.6.0","htmlparser2":"^10.0.0","lunr":"^2.3.9","lunr-languages":"^1.14.0","mime":"^4.0.6","prompts":"2.4.2","rimraf":"6.0.1","tar":"7.4.3","update-check":"1.5.4","ws":"^8.18.0"}}');
201779
201832
 
201780
201833
  /***/ })
201781
201834
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyperbook",
3
- "version": "0.77.6",
3
+ "version": "0.77.7",
4
4
  "author": "Mike Barkmin",
5
5
  "homepage": "https://github.com/openpatch/hyperbook#readme",
6
6
  "license": "MIT",
@@ -56,10 +56,10 @@
56
56
  "tar": "7.4.3",
57
57
  "update-check": "1.5.4",
58
58
  "ws": "^8.18.0",
59
+ "@hyperbook/fs": "0.24.1",
59
60
  "create-hyperbook": "0.3.2",
60
- "@hyperbook/markdown": "0.48.6",
61
61
  "@hyperbook/types": "0.20.0",
62
- "@hyperbook/fs": "0.24.1"
62
+ "@hyperbook/markdown": "0.48.6"
63
63
  },
64
64
  "scripts": {
65
65
  "version": "pnpm build",