markmap-cli 0.16.0 → 0.16.2

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 +2 -53
  2. package/dist/index.js +11 -6
  3. package/package.json +3 -3
package/README.md CHANGED
@@ -6,57 +6,6 @@
6
6
 
7
7
  Use [markmap-lib](https://markmap.js.org/) in command-line.
8
8
 
9
- ## Installation
9
+ ## Usage
10
10
 
11
- ```sh
12
- $ yarn global add markmap-cli
13
- # or
14
- $ npm install -g markmap-cli
15
- ```
16
-
17
- You can also use with `npx` without installation:
18
-
19
- ```sh
20
- $ npx markmap-cli
21
- ```
22
-
23
- ## Command-line Usage
24
-
25
- ```
26
- Usage: markmap [options] <input>
27
-
28
- Create a markmap from a Markdown input file
29
-
30
- Options:
31
- -V, --version output the version number
32
- --no-open do not open the output file after generation
33
- --no-toolbar do not show toolbar
34
- -o, --output <output> specify filename of the output HTML
35
- -w, --watch watch the input file and update output on the fly, note that this feature is for development only
36
- -h, --help display help for command
37
- ```
38
-
39
- ### Creating a markmap
40
-
41
- Suppose we have a Markdown file named `note.md`.
42
-
43
- Run the following command to get an interactive mindmap:
44
-
45
- ```sh
46
- $ markmap note.md
47
-
48
- # without global installation
49
- $ npx markmap-lib note.md
50
- ```
51
-
52
- Then we get `note.html` in the same directory, and hopefully it will be open in your default browser.
53
-
54
- ### Watching changes
55
-
56
- Enable watching mode by `-w`:
57
-
58
- ```sh
59
- $ markmap -w note.md
60
- ```
61
-
62
- A markmap will be created and opened in your browser, and will be updated as soon as changes are saved to the source file.
11
+ See [the documentation](https://markmap.js.org/docs/packages--markmap-cli).
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { readFile, stat, mkdir, writeFile } from "fs/promises";
2
- import { join, resolve, dirname } from "path";
2
+ import { dirname, join, resolve } from "path";
3
3
  import { fileURLToPath } from "url";
4
4
  import { Command } from "commander";
5
5
  import open from "open";
@@ -16,10 +16,10 @@ import { createReadStream, createWriteStream } from "fs";
16
16
  import { Hono } from "hono";
17
17
  import { Readable } from "stream";
18
18
  import { finished } from "stream/promises";
19
- const __vite_glob_0_0 = "data:application/octet-stream;base64,L2Fzc2V0cwo=";
20
19
  const TOOLBAR_VERSION = "0.16.0";
21
20
  const TOOLBAR_CSS = `markmap-toolbar@${TOOLBAR_VERSION}/dist/style.css`;
22
21
  const TOOLBAR_JS = `markmap-toolbar@${TOOLBAR_VERSION}/dist/index.js`;
22
+ const currentDir = dirname(fileURLToPath(import.meta.url));
23
23
  const ASSETS_PREFIX = "/assets/";
24
24
  const renderToolbar = () => {
25
25
  const { markmap, mm } = window;
@@ -70,7 +70,7 @@ function createStreamBody(stream) {
70
70
  return body;
71
71
  }
72
72
  const config = {
73
- assetsDir: fileURLToPath(new URL((/* @__PURE__ */ Object.assign({ "../.gitignore": __vite_glob_0_0 }))[`../.${ASSETS_PREFIX}`], import.meta.url))
73
+ assetsDir: `${currentDir}${ASSETS_PREFIX}`
74
74
  };
75
75
  var getMimeType = (filename) => {
76
76
  const regexp = /\.([a-zA-Z0-9]+?)$/;
@@ -381,23 +381,28 @@ async function fetchAssets(assetsDir = config.assetsDir) {
381
381
  )) || []
382
382
  ].filter((url) => url.startsWith(ASSETS_PREFIX)).map((url) => url.slice(ASSETS_PREFIX.length));
383
383
  const paths = [...baseJsPaths, ...pluginPaths];
384
- const fastest = await transformer.urlBuilder.getFastestProvider();
384
+ let findingProvider;
385
+ const findProvider = () => {
386
+ findingProvider || (findingProvider = transformer.urlBuilder.getFastestProvider());
387
+ return findingProvider;
388
+ };
385
389
  await Promise.all(
386
390
  paths.map(
387
391
  (path) => downloadAsset(
388
392
  resolve(assetsDir, path),
389
- transformer.urlBuilder.getFullUrl(path, fastest)
393
+ async () => transformer.urlBuilder.getFullUrl(path, await findProvider())
390
394
  )
391
395
  )
392
396
  );
393
397
  }
394
- async function downloadAsset(fullPath, url) {
398
+ async function downloadAsset(fullPath, resolveUrl) {
395
399
  try {
396
400
  const result = await stat(fullPath);
397
401
  if (result.isFile())
398
402
  return;
399
403
  } catch {
400
404
  }
405
+ const url = await resolveUrl();
401
406
  const res = await fetch(url);
402
407
  if (!res.ok || !res.body)
403
408
  throw new Error(`Failed to download: ${url}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markmap-cli",
3
- "version": "0.16.0",
3
+ "version": "0.16.2",
4
4
  "description": "Create markmaps from CLI",
5
5
  "author": "Gerald <gera2ld@live.com>",
6
6
  "license": "MIT",
@@ -49,7 +49,7 @@
49
49
  "commander": "^11.1.0",
50
50
  "hono": "^3.11.8",
51
51
  "markmap-common": "0.16.0",
52
- "markmap-lib": "0.16.0",
52
+ "markmap-lib": "0.16.1",
53
53
  "markmap-render": "0.16.0",
54
54
  "markmap-toolbar": "0.16.0",
55
55
  "open": "^10.0.0",
@@ -57,5 +57,5 @@
57
57
  "read-package-up": "^11.0.0",
58
58
  "update-notifier": "^7.0.0"
59
59
  },
60
- "gitHead": "caf3f840ad39c240ba522bfea83c57de62c6cac4"
60
+ "gitHead": "a888c810a9add22cdbbed43d02cb382093004a9a"
61
61
  }