markmap-cli 0.16.1 → 0.16.3-alpha.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 (2) hide show
  1. package/dist/index.js +12 -7
  2. package/package.json +5 -5
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
- const TOOLBAR_VERSION = "0.16.0";
19
+ const TOOLBAR_VERSION = "0.16.3-alpha.2";
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.1",
3
+ "version": "0.16.3-alpha.2+0f4c3f8",
4
4
  "description": "Create markmaps from CLI",
5
5
  "author": "Gerald <gera2ld@live.com>",
6
6
  "license": "MIT",
@@ -49,13 +49,13 @@
49
49
  "commander": "^11.1.0",
50
50
  "hono": "^3.11.8",
51
51
  "markmap-common": "0.16.0",
52
- "markmap-lib": "0.16.1",
53
- "markmap-render": "0.16.0",
54
- "markmap-toolbar": "0.16.0",
52
+ "markmap-lib": "0.16.3-alpha.2+0f4c3f8",
53
+ "markmap-render": "0.16.3-alpha.2+0f4c3f8",
54
+ "markmap-toolbar": "0.16.3-alpha.2+0f4c3f8",
55
55
  "open": "^10.0.0",
56
56
  "pkg-dir": "^8.0.0",
57
57
  "read-package-up": "^11.0.0",
58
58
  "update-notifier": "^7.0.0"
59
59
  },
60
- "gitHead": "f10ad62ef03e02a1843484cca51521f48989fab7"
60
+ "gitHead": "0f4c3f84ff21f0957ec3dbf338ed7a453f050638"
61
61
  }