markmap-cli 0.18.5-alpha.6 → 0.18.5-alpha.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.
@@ -1 +1 @@
1
- import './style.css';
1
+ export {};
package/dist/client.js CHANGED
@@ -1,31 +1,51 @@
1
1
  const { mm, markmap } = window;
2
2
  const { cliOptions } = markmap;
3
3
  const key = new URLSearchParams(window.location.search).get("key") || "";
4
- let ts = 0;
5
- let root;
6
- let active;
4
+ const state = {
5
+ content: {
6
+ ts: 0,
7
+ value: void 0
8
+ },
9
+ line: {
10
+ ts: 0,
11
+ value: 0
12
+ }
13
+ };
7
14
  const activeNodeOptions = {};
8
15
  const highlightEl = document.createElement("div");
9
16
  highlightEl.className = "markmap-highlight-area";
10
17
  checkData();
11
- checkHighlight();
12
18
  async function checkData() {
19
+ var _a;
13
20
  try {
14
- const resp = await fetch(`/~data?key=${key}&ts=${ts}`);
21
+ const query = new URLSearchParams(
22
+ [
23
+ ["key", key],
24
+ ["content", state.content.ts],
25
+ ["line", state.line.ts]
26
+ ].map((pair) => pair.map((s) => `${s}`))
27
+ );
28
+ const resp = await fetch(`/~data?${query}`);
29
+ if (!resp.ok)
30
+ throw {
31
+ status: resp.status
32
+ };
15
33
  const res = await resp.json();
16
- if (res.ts && res.ts > ts && res.result) {
17
- let frontmatter;
18
- ({ root, frontmatter } = res.result);
19
- mm.setOptions(markmap.deriveOptions(frontmatter == null ? void 0 : frontmatter.markmap));
20
- await mm.setData(root);
21
- if (!ts) await mm.fit();
22
- ts = res.ts;
34
+ if (res.content) {
35
+ const value = res.content.value;
36
+ mm.setOptions(markmap.deriveOptions((_a = value.frontmatter) == null ? void 0 : _a.markmap));
37
+ await mm.setData(value.root);
38
+ if (!state.content.ts) await mm.fit();
39
+ }
40
+ Object.assign(state, res);
41
+ if (res.line && state.content.value) {
42
+ await setCursor({ line: res.line.value });
23
43
  }
24
- if (root && res.line != null) {
25
- await setCursor({ line: res.line });
44
+ setTimeout(checkData);
45
+ } catch (err) {
46
+ if (err.status !== 404) {
47
+ setTimeout(checkData, 1e3);
26
48
  }
27
- } finally {
28
- setTimeout(checkData, 3e3);
29
49
  }
30
50
  }
31
51
  function findActiveNode({
@@ -46,48 +66,26 @@ function findActiveNode({
46
66
  }
47
67
  let best;
48
68
  let bestAncestors = [];
49
- dfs(root);
50
- let needRerender = false;
69
+ dfs(state.content.value.root);
51
70
  if (autoExpand) {
52
71
  bestAncestors.forEach((node) => {
53
72
  var _a;
54
73
  if ((_a = node.payload) == null ? void 0 : _a.fold) {
55
74
  node.payload.fold = 0;
56
- needRerender = true;
57
75
  }
58
76
  });
59
77
  }
60
- return best && { node: best, needRerender };
78
+ return best;
61
79
  }
62
80
  async function setCursor(options) {
63
- const result = root && findActiveNode(options);
64
- if (!result) return;
65
- const { node, needRerender } = result;
66
- if (needRerender) await mm.renderData();
67
- if (node) highlightNode(node);
81
+ if (!state.content.value) return;
82
+ const node = findActiveNode(options);
83
+ await highlightNode(node);
68
84
  }
69
85
  async function highlightNode(node) {
70
- var _a;
86
+ await mm.setHighlight(node);
87
+ if (!node) return;
71
88
  await mm[activeNodeOptions.placement === "center" ? "centerNode" : "ensureVisible"](node, {
72
89
  bottom: cliOptions.toolbar ? 80 : 0
73
90
  });
74
- const g = (_a = mm.findElement(node)) == null ? void 0 : _a.g;
75
- const el = g == null ? void 0 : g.querySelector("foreignObject");
76
- active = el && { el, node };
77
- }
78
- function checkHighlight() {
79
- if (!active) {
80
- highlightEl.remove();
81
- } else {
82
- const rect = active.el.getBoundingClientRect();
83
- const padding = 4;
84
- const { width } = active.node.state.rect;
85
- const scale = (width + padding * 2) / width;
86
- highlightEl.setAttribute(
87
- "style",
88
- `--mm-highlight-x:${rect.x}px;--mm-highlight-y:${rect.y}px;--mm-highlight-width:${rect.width}px;--mm-highlight-height:${rect.height}px;--mm-highlight-scale:${scale}`
89
- );
90
- if (!highlightEl.parentNode) document.body.append(highlightEl);
91
- }
92
- requestAnimationFrame(checkHighlight);
93
91
  }
@@ -7,6 +7,9 @@ export declare class MarkmapDevServer {
7
7
  providers: Record<string, IContentProvider>;
8
8
  private transformer;
9
9
  private html;
10
+ private watcher;
11
+ private callbacks;
12
+ private disposeList;
10
13
  serverInfo: {
11
14
  server: ServerType;
12
15
  address: AddressInfo;
@@ -15,7 +18,12 @@ export declare class MarkmapDevServer {
15
18
  private _buildHtml;
16
19
  setup(): Promise<void>;
17
20
  shutdown(): Promise<void>;
18
- addProvider(filePath?: string): string;
19
- delProvider(filePath?: string): void;
21
+ destroy(): Promise<void>;
22
+ private _watch;
23
+ addProvider(options?: {
24
+ key?: string;
25
+ filePath?: string;
26
+ }): IContentProvider;
27
+ delProvider(key: string): void;
20
28
  }
21
29
  export declare function develop(options: IDevelopOptions): Promise<MarkmapDevServer>;
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Command } from "commander";
2
2
  import { readFile, stat, mkdir, writeFile } from "fs/promises";
3
- import { buildCSSItem, buildJSItem, defer } from "markmap-common";
3
+ import { buildCSSItem, buildJSItem, mergeAssets, defer, extractAssets } from "markmap-common";
4
4
  import { Transformer } from "markmap-lib";
5
5
  import * as markmapLib from "markmap-lib";
6
6
  import { fillTemplate, baseJsPaths } from "markmap-render";
@@ -8,13 +8,12 @@ import open from "open";
8
8
  import { dirname, join, resolve, basename } from "path";
9
9
  import { readPackageUp } from "read-package-up";
10
10
  import updateNotifier from "update-notifier";
11
+ import { fileURLToPath } from "url";
11
12
  import { serve } from "@hono/node-server";
12
13
  import { watch } from "chokidar";
13
14
  import { createHash } from "crypto";
14
- import { EventEmitter } from "events";
15
15
  import { createReadStream, createWriteStream } from "fs";
16
16
  import { Hono } from "hono";
17
- import { fileURLToPath } from "url";
18
17
  import { Readable } from "stream";
19
18
  import { finished } from "stream/promises";
20
19
  var getMimeType = (filename, mimes = baseMimes) => {
@@ -87,7 +86,7 @@ var _baseMimes = {
87
86
  glb: "model/gltf-binary"
88
87
  };
89
88
  var baseMimes = _baseMimes;
90
- const TOOLBAR_VERSION = "0.18.5-alpha.6+cea75c9";
89
+ const TOOLBAR_VERSION = "0.18.5-alpha.7+41488b9";
91
90
  const TOOLBAR_CSS = `markmap-toolbar@${TOOLBAR_VERSION}/dist/style.css`;
92
91
  const TOOLBAR_JS = `markmap-toolbar@${TOOLBAR_VERSION}/dist/index.js`;
93
92
  const distDir = dirname(fileURLToPath(import.meta.url));
@@ -100,27 +99,21 @@ const renderToolbar = () => {
100
99
  el.setAttribute("style", "position:absolute;bottom:20px;right:20px");
101
100
  document.body.append(el);
102
101
  };
103
- function addToolbar(urlBuilder, assets) {
104
- return {
105
- styles: [
106
- ...assets.styles || [],
107
- ...[TOOLBAR_CSS].map((path) => urlBuilder.getFullUrl(path)).map((path) => buildCSSItem(path))
108
- ],
109
- scripts: [
110
- ...assets.scripts || [],
111
- ...[TOOLBAR_JS].map((path) => urlBuilder.getFullUrl(path)).map((path) => buildJSItem(path)),
112
- {
113
- type: "iife",
114
- data: {
115
- fn: (r) => {
116
- setTimeout(r);
117
- },
118
- getParams: () => [renderToolbar]
119
- }
102
+ const toolbarAssets = {
103
+ styles: [buildCSSItem(TOOLBAR_CSS)],
104
+ scripts: [
105
+ buildJSItem(TOOLBAR_JS),
106
+ {
107
+ type: "iife",
108
+ data: {
109
+ fn: (r) => {
110
+ setTimeout(r);
111
+ },
112
+ getParams: () => [renderToolbar]
120
113
  }
121
- ]
122
- };
123
- }
114
+ }
115
+ ]
116
+ };
124
117
  function localProvider(path) {
125
118
  return `${ASSETS_PREFIX}${path}`;
126
119
  }
@@ -147,84 +140,83 @@ const config = {
147
140
  function sequence(fn) {
148
141
  let promise;
149
142
  return () => {
150
- promise || (promise = fn().finally(() => {
143
+ promise || (promise = Promise.resolve(fn()).finally(() => {
151
144
  promise = void 0;
152
145
  }));
153
146
  return promise;
154
147
  };
155
148
  }
156
149
  class BufferContentProvider {
157
- constructor() {
150
+ constructor(key) {
151
+ this.key = key;
158
152
  this.deferredSet = /* @__PURE__ */ new Set();
159
- this.events = new EventEmitter();
160
- this.ts = 0;
161
- this.content = "";
162
- this.line = -1;
163
- this.key = "";
164
- this.events.on("content", () => {
165
- this.feed({
166
- ts: this.ts,
167
- content: this.content
168
- });
169
- });
170
- this.events.on("cursor", () => {
171
- this.feed({
172
- line: this.line
173
- });
174
- });
153
+ this.state = {
154
+ content: {
155
+ ts: 0,
156
+ value: ""
157
+ },
158
+ line: {
159
+ ts: 0,
160
+ value: 0
161
+ }
162
+ };
163
+ this.disposeList = [];
175
164
  }
176
- async getUpdate(ts, timeout = 1e4) {
165
+ async getUpdate(query, timeout = 1e4) {
177
166
  const deferred = defer();
178
167
  this.deferredSet.add(deferred);
179
168
  setTimeout(() => {
180
- this.feed({}, deferred);
169
+ this.feed(null, deferred);
181
170
  }, timeout);
182
- if (ts < this.ts) {
183
- this.feed({ ts: this.ts, content: this.content }, deferred);
171
+ if (Object.keys(query).some((key) => query[key] < this.state[key].ts)) {
172
+ this.feed(null, deferred);
184
173
  }
185
- return deferred.promise;
174
+ await deferred.promise;
186
175
  }
187
176
  feed(data, deferred) {
177
+ if (data) {
178
+ Object.assign(this.state, data);
179
+ }
188
180
  if (deferred) {
189
- deferred.resolve(data);
181
+ deferred.resolve();
190
182
  this.deferredSet.delete(deferred);
191
183
  } else {
192
184
  for (const d of this.deferredSet) {
193
- d.resolve(data);
185
+ d.resolve();
194
186
  }
195
187
  this.deferredSet.clear();
196
188
  }
197
189
  }
198
190
  setCursor(line) {
199
- this.line = line;
200
- this.events.emit("cursor");
191
+ this.feed({
192
+ line: {
193
+ ts: Date.now(),
194
+ value: line
195
+ }
196
+ });
201
197
  }
202
198
  setContent(content) {
203
- this.ts = Date.now();
204
- this.content = content;
205
- this.events.emit("content");
199
+ this.feed({
200
+ content: {
201
+ ts: Date.now(),
202
+ value: content
203
+ }
204
+ });
206
205
  }
207
206
  dispose() {
207
+ this.disposeList.forEach((dispose) => dispose());
208
208
  }
209
209
  }
210
210
  class FileSystemProvider extends BufferContentProvider {
211
- constructor(key, filePath) {
212
- super();
213
- this.key = key;
211
+ constructor(key, filePath, watch2) {
212
+ super(key);
214
213
  this.filePath = filePath;
215
- this.watcher = watch(filePath).on(
216
- "all",
217
- sequence(() => this.update())
218
- );
214
+ this.disposeList.push(watch2(() => this.update()));
219
215
  }
220
216
  async update() {
221
217
  const content = await readFile(this.filePath, "utf8");
222
218
  this.setContent(content);
223
219
  }
224
- dispose() {
225
- super.dispose();
226
- this.watcher.close();
227
- }
228
220
  }
229
221
  function sha256(input) {
230
222
  return createHash("sha256").update(input, "utf8").digest("hex").slice(0, 7);
@@ -245,37 +237,42 @@ class MarkmapDevServer {
245
237
  constructor(options, transformer) {
246
238
  this.options = options;
247
239
  this.providers = {};
240
+ this.callbacks = {};
241
+ this.disposeList = [];
248
242
  this.serverInfo = null;
249
243
  this.transformer = transformer || new Transformer();
250
244
  this.html = this._buildHtml();
245
+ this.disposeList.push(() => {
246
+ var _a;
247
+ (_a = this.watcher) == null ? void 0 : _a.close();
248
+ });
251
249
  }
252
250
  _buildHtml() {
253
- let assets = this.transformer.getAssets();
254
- if (this.options.toolbar)
255
- assets = addToolbar(this.transformer.urlBuilder, assets);
256
- assets = {
257
- styles: [
258
- ...assets.styles || [],
259
- {
260
- type: "stylesheet",
261
- data: {
262
- href: "/~client.css"
263
- }
264
- }
265
- ],
266
- scripts: [
267
- ...assets.scripts || [],
268
- {
269
- type: "iife",
270
- data: {
271
- fn: (options) => {
272
- window.markmap.cliOptions = options;
273
- },
274
- getParams: () => [this.options]
251
+ var _a, _b;
252
+ const otherAssets = mergeAssets(
253
+ this.options.toolbar ? toolbarAssets : null,
254
+ {
255
+ scripts: [
256
+ {
257
+ type: "iife",
258
+ data: {
259
+ fn: (options) => {
260
+ window.markmap.cliOptions = options;
261
+ },
262
+ getParams: () => [this.options]
263
+ }
275
264
  }
276
- }
277
- ]
278
- };
265
+ ]
266
+ }
267
+ );
268
+ const assets = mergeAssets(this.transformer.getAssets(), {
269
+ scripts: (_a = otherAssets.scripts) == null ? void 0 : _a.map(
270
+ (item) => this.transformer.resolveJS(item)
271
+ ),
272
+ styles: (_b = otherAssets.styles) == null ? void 0 : _b.map(
273
+ (item) => this.transformer.resolveCSS(item)
274
+ )
275
+ });
279
276
  const html = fillTemplate(null, assets, {
280
277
  urlBuilder: this.transformer.urlBuilder
281
278
  }) + '<script src="/~client.js"><\/script>';
@@ -284,15 +281,39 @@ class MarkmapDevServer {
284
281
  async setup() {
285
282
  if (this.serverInfo) throw new Error("Server already set up");
286
283
  const app = new Hono();
287
- app.get("/", (c) => c.html(this.html));
284
+ app.get("/", (c) => {
285
+ const key = c.req.query("key") || "";
286
+ if (!this.providers[key]) return c.notFound();
287
+ return c.html(this.html);
288
+ });
288
289
  app.get("/~data", async (c) => {
289
290
  const key = c.req.query("key") || "";
290
291
  const provider = this.providers[key];
291
292
  if (!provider) return c.json({}, 404);
292
- const ts = +(c.req.query("ts") || "") || 0;
293
- const update = await provider.getUpdate(ts);
294
- const result = update.content == null ? null : this.transformer.transform(update.content || "");
295
- return c.json({ ts: update.ts, result, line: update.line });
293
+ const query = Object.fromEntries(
294
+ ["content", "line"].map((key2) => [key2, +(c.req.query(key2) || "") || 0])
295
+ );
296
+ await provider.getUpdate(query);
297
+ const updatedKeys = Object.keys(query).filter(
298
+ (key2) => query[key2] < provider.state[key2].ts
299
+ );
300
+ const result = Object.fromEntries(
301
+ updatedKeys.map((key2) => {
302
+ let data = provider.state[key2];
303
+ if (key2 === "content") {
304
+ const result2 = this.transformer.transform(data.value);
305
+ data = {
306
+ ...data,
307
+ value: {
308
+ frontmatter: result2.frontmatter,
309
+ root: result2.root
310
+ }
311
+ };
312
+ }
313
+ return [key2, data];
314
+ })
315
+ );
316
+ return c.json(result);
296
317
  });
297
318
  app.post("/~api", async (c) => {
298
319
  var _a;
@@ -337,16 +358,40 @@ class MarkmapDevServer {
337
358
  await deferred.promise;
338
359
  this.serverInfo = null;
339
360
  }
340
- addProvider(filePath) {
361
+ async destroy() {
362
+ await this.shutdown();
363
+ this.disposeList.forEach((dispose) => dispose());
364
+ }
365
+ _watch(filePath, callback) {
366
+ let { watcher } = this;
367
+ if (!watcher) {
368
+ watcher = watch([]).on("all", (_event, path) => {
369
+ const callback2 = this.callbacks[path];
370
+ callback2 == null ? void 0 : callback2();
371
+ });
372
+ this.watcher = watcher;
373
+ }
374
+ watcher.add(filePath);
375
+ this.callbacks[filePath] = sequence(callback);
376
+ return () => {
377
+ watcher.unwatch(filePath);
378
+ delete this.callbacks[filePath];
379
+ };
380
+ }
381
+ addProvider(options) {
341
382
  var _a;
342
- filePath = filePath && resolve(filePath);
343
- const key = filePath ? sha256(filePath) : "";
344
- (_a = this.providers)[key] || (_a[key] = filePath ? new FileSystemProvider(key, filePath) : new BufferContentProvider());
345
- return key;
383
+ const filePath = (options == null ? void 0 : options.filePath) && resolve(options.filePath);
384
+ const key = (options == null ? void 0 : options.key) || (filePath ? sha256(filePath) : Math.random().toString(36).slice(2, 9));
385
+ (_a = this.providers)[key] || (_a[key] = filePath ? new FileSystemProvider(
386
+ key,
387
+ filePath,
388
+ (callback) => this._watch(filePath, callback)
389
+ ) : new BufferContentProvider(key));
390
+ return this.providers[key];
346
391
  }
347
- delProvider(filePath) {
348
- filePath = filePath && resolve(filePath);
349
- const key = filePath ? sha256(filePath) : "";
392
+ delProvider(key) {
393
+ const provider = this.providers[key];
394
+ provider == null ? void 0 : provider.dispose();
350
395
  delete this.providers[key];
351
396
  }
352
397
  }
@@ -354,36 +399,30 @@ async function develop(options) {
354
399
  const transformer = new Transformer();
355
400
  transformer.urlBuilder.setProvider("local", localProvider);
356
401
  transformer.urlBuilder.provider = "local";
357
- const devServer = new MarkmapDevServer(options);
402
+ const devServer = new MarkmapDevServer(options, transformer);
358
403
  await devServer.setup();
359
404
  return devServer;
360
405
  }
361
406
  const providerName = "local-hook";
362
407
  async function fetchAssets(assetsDir = config.assetsDir) {
363
- var _a, _b;
364
408
  const transformer = new Transformer();
365
- const { provider } = transformer.urlBuilder;
366
409
  transformer.urlBuilder.setProvider(providerName, localProvider);
367
410
  transformer.urlBuilder.provider = providerName;
368
- let assets = transformer.getAssets();
411
+ const assets = transformer.getAssets();
412
+ delete transformer.urlBuilder.providers[providerName];
413
+ const pluginPaths = extractAssets(assets).filter((url) => url.startsWith(ASSETS_PREFIX)).map((url) => url.slice(ASSETS_PREFIX.length));
369
414
  const resources = transformer.plugins.flatMap(
370
415
  (plugin) => {
371
- var _a2;
372
- return ((_a2 = plugin.config) == null ? void 0 : _a2.resources) || [];
416
+ var _a;
417
+ return ((_a = plugin.config) == null ? void 0 : _a.resources) || [];
373
418
  }
374
419
  );
375
- assets = addToolbar(transformer.urlBuilder, assets);
376
- delete transformer.urlBuilder.providers[providerName];
377
- transformer.urlBuilder.provider = provider;
378
- const pluginPaths = [
379
- ...((_a = assets.scripts) == null ? void 0 : _a.map(
380
- (item) => item.type === "script" && item.data.src || ""
381
- )) || [],
382
- ...((_b = assets.styles) == null ? void 0 : _b.map(
383
- (item) => item.type === "stylesheet" && item.data.href || ""
384
- )) || []
385
- ].filter((url) => url.startsWith(ASSETS_PREFIX)).map((url) => url.slice(ASSETS_PREFIX.length));
386
- const paths = [...baseJsPaths, ...pluginPaths, ...resources];
420
+ const paths = [
421
+ ...baseJsPaths,
422
+ ...pluginPaths,
423
+ ...resources,
424
+ ...extractAssets(toolbarAssets)
425
+ ];
387
426
  let findingProvider;
388
427
  const findProvider = () => {
389
428
  findingProvider || (findingProvider = transformer.urlBuilder.getFastestProvider());
@@ -450,6 +489,7 @@ async function inlineAssets(assets) {
450
489
  };
451
490
  }
452
491
  async function createMarkmap(options) {
492
+ var _a, _b;
453
493
  const transformer = new Transformer();
454
494
  if (options.offline) {
455
495
  transformer.urlBuilder.setProvider("local", localProvider);
@@ -463,20 +503,20 @@ async function createMarkmap(options) {
463
503
  const { root, features, frontmatter } = transformer.transform(
464
504
  options.content || ""
465
505
  );
466
- let assets = transformer.getUsedAssets(features);
467
- assets = {
468
- ...assets,
469
- scripts: [
470
- ...baseJsPaths.map((path) => transformer.urlBuilder.getFullUrl(path)).map((path) => buildJSItem(path)),
471
- ...assets.scripts || []
472
- ]
473
- };
474
- if (options.toolbar) {
475
- assets = addToolbar(transformer.urlBuilder, assets);
476
- }
477
- if (options.offline) {
478
- assets = await inlineAssets(assets);
479
- }
506
+ const otherAssets = mergeAssets(
507
+ {
508
+ scripts: baseJsPaths.map(buildJSItem)
509
+ },
510
+ options.toolbar ? toolbarAssets : null
511
+ );
512
+ let assets = mergeAssets(
513
+ {
514
+ scripts: (_a = otherAssets.scripts) == null ? void 0 : _a.map((item) => transformer.resolveJS(item)),
515
+ styles: (_b = otherAssets.styles) == null ? void 0 : _b.map((item) => transformer.resolveCSS(item))
516
+ },
517
+ transformer.getUsedAssets(features)
518
+ );
519
+ if (options.offline) assets = await inlineAssets(assets);
480
520
  const html = fillTemplate(root, assets, {
481
521
  baseJs: [],
482
522
  jsonOptions: frontmatter == null ? void 0 : frontmatter.markmap,
@@ -489,7 +529,7 @@ async function createMarkmap(options) {
489
529
  async function main() {
490
530
  var _a;
491
531
  const pkg = (_a = await readPackageUp({
492
- cwd: import.meta.url
532
+ cwd: fileURLToPath(import.meta.url)
493
533
  })) == null ? void 0 : _a.packageJson;
494
534
  if (!pkg) throw new Error("package.json not found");
495
535
  const notifier = updateNotifier({ pkg });
@@ -513,9 +553,9 @@ async function main() {
513
553
  offline
514
554
  });
515
555
  const address = devServer.serverInfo.address;
516
- const key = devServer.addProvider(input);
556
+ const provider = devServer.addProvider({ filePath: input });
517
557
  const filename = basename(input);
518
- const url = `http://localhost:${address.port}/?key=${key}&filename=${filename}`;
558
+ const url = `http://localhost:${address.port}/?key=${provider.key}&filename=${encodeURIComponent(filename)}`;
519
559
  console.log(`Listening at ${url}`);
520
560
  if (cmd.open) open(url);
521
561
  } else {
package/dist/types.d.ts CHANGED
@@ -11,13 +11,15 @@ export interface IDevelopOptions {
11
11
  /** Port number for the devServer to listen. */
12
12
  port?: number;
13
13
  }
14
- export interface IFileUpdate {
15
- ts?: number;
16
- content?: string;
17
- line?: number;
14
+ export interface IVersionedValue<T = unknown> {
15
+ ts: number;
16
+ value: T;
18
17
  }
18
+ export type IFileState = Record<string, IVersionedValue>;
19
19
  export interface IContentProvider {
20
- getUpdate: (ts: number, timeout?: number) => Promise<IFileUpdate>;
20
+ key: string;
21
+ state: IFileState;
22
+ getUpdate: (query: Record<string, number>, timeout?: number) => Promise<void>;
21
23
  setContent: (content: string) => void;
22
24
  setCursor: (line: number) => void;
23
25
  dispose: () => void;
package/dist/util.d.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  import type { ReadStream } from 'fs';
2
- import { UrlBuilder } from 'markmap-common';
3
2
  import { IAssets } from 'markmap-lib';
4
3
  export declare const ASSETS_PREFIX = "/assets/";
5
- export declare function addToolbar(urlBuilder: UrlBuilder, assets: IAssets): IAssets;
4
+ export declare const toolbarAssets: IAssets;
6
5
  export declare function localProvider(path: string): string;
7
6
  export declare function createStreamBody(stream: ReadStream): ReadableStream<any>;
8
7
  export declare const config: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markmap-cli",
3
- "version": "0.18.5-alpha.6+cea75c9",
3
+ "version": "0.18.5-alpha.7+41488b9",
4
4
  "description": "Create markmaps from CLI",
5
5
  "author": "Gerald <gera2ld@live.com>",
6
6
  "license": "MIT",
@@ -49,14 +49,13 @@
49
49
  "chokidar": "^4.0.1",
50
50
  "commander": "^12.1.0",
51
51
  "hono": "^4.6.13",
52
- "markmap-common": "0.18.5-alpha.6+cea75c9",
53
- "markmap-lib": "0.18.5-alpha.6+cea75c9",
54
- "markmap-render": "0.18.5-alpha.6+cea75c9",
55
- "markmap-toolbar": "0.18.5-alpha.6+cea75c9",
52
+ "markmap-common": "0.18.5-alpha.7+41488b9",
53
+ "markmap-lib": "0.18.5-alpha.7+41488b9",
54
+ "markmap-render": "0.18.5-alpha.7+41488b9",
55
+ "markmap-toolbar": "0.18.5-alpha.7+41488b9",
56
56
  "open": "^10.1.0",
57
- "pkg-dir": "^8.0.0",
58
57
  "read-package-up": "^11.0.0",
59
58
  "update-notifier": "^7.3.1"
60
59
  },
61
- "gitHead": "cea75c9906a30ddf515f94bd6ad61d6c9ca4035a"
60
+ "gitHead": "41488b9988a1f49f7dadc029ef6be18fed981cac"
62
61
  }
package/dist/client.css DELETED
@@ -1,11 +0,0 @@
1
- .markmap-highlight-area {
2
- --mm-highlight-scale: 1;
3
- position: absolute;
4
- width: var(--mm-highlight-width);
5
- height: var(--mm-highlight-height);
6
- left: var(--mm-highlight-x);
7
- top: var(--mm-highlight-y);
8
- z-index: -1;
9
- background: #ff02;
10
- transform: scale(var(--mm-highlight-scale));
11
- }