markmap-cli 0.17.3-beta.4 → 0.18.1-alpha.1

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 +20 -20
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -16,7 +16,7 @@ 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 TOOLBAR_VERSION = "0.17.3-beta.4";
19
+ const TOOLBAR_VERSION = "0.18.0";
20
20
  const TOOLBAR_CSS = `markmap-toolbar@${TOOLBAR_VERSION}/dist/style.css`;
21
21
  const TOOLBAR_JS = `markmap-toolbar@${TOOLBAR_VERSION}/dist/index.js`;
22
22
  const currentDir = dirname(fileURLToPath(import.meta.url));
@@ -226,37 +226,37 @@ function startServer(paddingBottom) {
226
226
  let ts = 0;
227
227
  let root;
228
228
  let line;
229
- let offset = 0;
230
229
  const { mm, markmap } = window;
231
230
  refresh();
232
231
  function refresh() {
233
- fetch(`/~data?ts=${ts}`).then((res) => res.json()).then((res) => {
234
- if (res.ts && res.ts > ts && res.result) {
235
- let frontmatter;
236
- ({ root, frontmatter, contentLineOffset: offset } = res.result);
237
- mm.setOptions(markmap.deriveOptions(frontmatter == null ? void 0 : frontmatter.markmap));
238
- mm.setData(root);
239
- if (!ts) mm.fit();
240
- ts = res.ts;
241
- line = -1;
242
- }
243
- if (root && res.line != null && line !== res.line) {
244
- line = res.line;
245
- const active = findActiveNode();
246
- if (active) mm.ensureView(active, { bottom: paddingBottom });
232
+ fetch(`/~data?ts=${ts}`).then((res) => res.json()).then(
233
+ (res) => {
234
+ if (res.ts && res.ts > ts && res.result) {
235
+ let frontmatter;
236
+ ({ root, frontmatter } = res.result);
237
+ mm.setOptions(markmap.deriveOptions(frontmatter == null ? void 0 : frontmatter.markmap));
238
+ mm.setData(root);
239
+ if (!ts) mm.fit();
240
+ ts = res.ts;
241
+ line = -1;
242
+ }
243
+ if (root && res.line != null && line !== res.line) {
244
+ line = res.line;
245
+ const active = findActiveNode();
246
+ if (active) mm.ensureView(active, { bottom: paddingBottom });
247
+ }
248
+ setTimeout(refresh, 300);
247
249
  }
248
- setTimeout(refresh, 300);
249
- });
250
+ );
250
251
  }
251
252
  function findActiveNode() {
252
- const lineWithoutFrontmatter = line - offset;
253
253
  let best;
254
254
  dfs(root);
255
255
  return best;
256
256
  function dfs(node) {
257
257
  var _a, _b, _c;
258
258
  const [start, end] = ((_b = (_a = node.payload) == null ? void 0 : _a.lines) == null ? void 0 : _b.split(",").map((s) => +s)) || [];
259
- if (start >= 0 && start <= lineWithoutFrontmatter && lineWithoutFrontmatter < end) {
259
+ if (start >= 0 && start <= line && line < end) {
260
260
  best = node;
261
261
  }
262
262
  (_c = node.children) == null ? void 0 : _c.forEach(dfs);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markmap-cli",
3
- "version": "0.17.3-beta.4+120a195",
3
+ "version": "0.18.1-alpha.1+f00ade4",
4
4
  "description": "Create markmaps from CLI",
5
5
  "author": "Gerald <gera2ld@live.com>",
6
6
  "license": "MIT",
@@ -49,14 +49,14 @@
49
49
  "chokidar": "^4.0.1",
50
50
  "commander": "^12.1.0",
51
51
  "hono": "^4.6.13",
52
- "markmap-common": "0.17.3-beta.4+120a195",
53
- "markmap-lib": "0.17.3-beta.4+120a195",
54
- "markmap-render": "0.17.3-beta.4+120a195",
55
- "markmap-toolbar": "0.17.3-beta.4+120a195",
52
+ "markmap-common": "0.18.0",
53
+ "markmap-lib": "0.18.1-alpha.1+f00ade4",
54
+ "markmap-render": "0.18.0",
55
+ "markmap-toolbar": "0.18.0",
56
56
  "open": "^10.1.0",
57
57
  "pkg-dir": "^8.0.0",
58
58
  "read-package-up": "^11.0.0",
59
59
  "update-notifier": "^7.3.1"
60
60
  },
61
- "gitHead": "120a1954940590e194130156a4c5fb60d82c0b3d"
61
+ "gitHead": "f00ade49c4b34f9c34579e67cd185ad29afd6950"
62
62
  }