markmap-cli 0.15.5-alpha.1 → 0.15.6-alpha.4

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.
@@ -0,0 +1 @@
1
+ export declare function fetchAssets(): Promise<void>;
@@ -1,7 +1,8 @@
1
1
  import { type IMarkmapCreateOptions } from 'markmap-lib';
2
2
  import { IDevelopOptions } from './util';
3
3
  import { develop } from './dev-server';
4
+ import { fetchAssets } from './fetch-assets';
4
5
  export * from 'markmap-lib';
5
- export { develop };
6
+ export { develop, fetchAssets };
6
7
  export declare function createMarkmap(options: IMarkmapCreateOptions & IDevelopOptions): Promise<void>;
7
8
  export declare function main(): Promise<void>;
package/dist/index.js CHANGED
@@ -1,139 +1,101 @@
1
- /*! markmap-cli v0.15.5-alpha.1+013bf59 | MIT License */
2
- import { readFile, writeFile } from 'fs/promises';
3
- import { fileURLToPath } from 'url';
4
- import { Command } from 'commander';
5
- import open from 'open';
6
- import updateNotifier from 'update-notifier';
7
- import { readPackageUp } from 'read-pkg-up';
8
- import { buildCSSItem, buildJSItem, defer } from 'markmap-common';
9
- import { Transformer, baseJsPaths } from 'markmap-lib';
10
- export * from 'markmap-lib';
11
- import { join, extname } from 'path';
12
- import { createRequire } from 'module';
13
- import { packageDirectory } from 'pkg-dir';
14
- import { createReadStream } from 'fs';
15
- import { EventEmitter } from 'events';
16
- import http from 'http';
17
- import Koa from 'koa';
18
- import chokidar from 'chokidar';
19
-
20
- function _extends() {
21
- _extends = Object.assign ? Object.assign.bind() : function (target) {
22
- for (var i = 1; i < arguments.length; i++) {
23
- var source = arguments[i];
24
- for (var key in source) {
25
- if (Object.prototype.hasOwnProperty.call(source, key)) {
26
- target[key] = source[key];
27
- }
28
- }
29
- }
30
- return target;
31
- };
32
- return _extends.apply(this, arguments);
33
- }
34
-
35
- const TOOLBAR_VERSION = "0.15.5-alpha.1";
1
+ import { readFile, stat, mkdir, writeFile } from "fs/promises";
2
+ import { resolve, extname, dirname } from "path";
3
+ import { fileURLToPath } from "url";
4
+ import { Command } from "commander";
5
+ import open from "open";
6
+ import updateNotifier from "update-notifier";
7
+ import { readPackageUp } from "read-pkg-up";
8
+ import { buildCSSItem, buildJSItem, defer } from "markmap-common";
9
+ import { Transformer, baseJsPaths } from "markmap-lib";
10
+ export * from "markmap-lib";
11
+ import { packageDirectory } from "pkg-dir";
12
+ import { createReadStream, createWriteStream } from "fs";
13
+ import { EventEmitter } from "events";
14
+ import http from "http";
15
+ import Koa from "koa";
16
+ import chokidar from "chokidar";
17
+ import { Readable } from "stream";
18
+ import { finished } from "stream/promises";
19
+ const TOOLBAR_VERSION = "0.15.6-alpha.4";
36
20
  const TOOLBAR_CSS = `markmap-toolbar@${TOOLBAR_VERSION}/dist/style.css`;
37
21
  const TOOLBAR_JS = `markmap-toolbar@${TOOLBAR_VERSION}/dist/index.js`;
22
+ const ASSETS_PREFIX = "/assets/";
38
23
  const renderToolbar = () => {
39
- const {
40
- markmap,
41
- mm
42
- } = window;
24
+ const { markmap, mm } = window;
43
25
  const toolbar = new markmap.Toolbar();
44
26
  toolbar.attach(mm);
45
27
  const el = toolbar.render();
46
- el.setAttribute('style', 'position:absolute;bottom:20px;right:20px');
28
+ el.setAttribute("style", "position:absolute;bottom:20px;right:20px");
47
29
  document.body.append(el);
48
30
  };
49
- function addToolbar(transformer, assets) {
31
+ function addToolbar(urlBuilder, assets) {
50
32
  return {
51
- styles: [...(assets.styles || []), ...[TOOLBAR_CSS].map(path => transformer.urlBuilder.getFullUrl(path)).map(path => buildCSSItem(path))],
52
- scripts: [...(assets.scripts || []), ...[TOOLBAR_JS].map(path => transformer.urlBuilder.getFullUrl(path)).map(path => buildJSItem(path)), {
53
- type: 'iife',
54
- data: {
55
- fn: r => {
56
- setTimeout(r);
57
- },
58
- getParams: () => [renderToolbar]
33
+ styles: [
34
+ ...assets.styles || [],
35
+ ...[TOOLBAR_CSS].map((path) => urlBuilder.getFullUrl(path)).map((path) => buildCSSItem(path))
36
+ ],
37
+ scripts: [
38
+ ...assets.scripts || [],
39
+ ...[TOOLBAR_JS].map((path) => urlBuilder.getFullUrl(path)).map((path) => buildJSItem(path)),
40
+ {
41
+ type: "iife",
42
+ data: {
43
+ fn: (r) => {
44
+ setTimeout(r);
45
+ },
46
+ getParams: () => [renderToolbar]
47
+ }
59
48
  }
60
- }]
49
+ ]
61
50
  };
62
51
  }
63
- function removeVersionString(part) {
64
- return part.replace(/@.+$/, '');
65
- }
66
52
  function localProvider(path) {
67
- const parts = path.split('/');
68
- // xxx@0.0.0-alpha.0+aaaaaa
69
- // @scope/xxx@0.0.0-alpha.0+aaaaaa
70
- if (parts[0].startsWith('@')) {
71
- parts[1] = removeVersionString(parts[1]);
72
- } else {
73
- parts[0] = removeVersionString(parts[0]);
74
- }
75
- path = parts.join('/');
76
- return `/node_modules/${path}`;
77
- }
78
- const require = createRequire(import.meta.url);
79
- async function doResolveFile(relpath) {
80
- const parts = relpath.split('/');
81
- const nameOffset = parts[0].startsWith('@') ? 2 : 1;
82
- const name = parts.slice(0, nameOffset).join('/');
83
- const filepath = parts.slice(nameOffset).join('/');
84
- const mainPath = require.resolve(name);
85
- const pkgDir = await packageDirectory({
86
- cwd: mainPath
87
- });
88
- if (!pkgDir) throw new Error(`File not found: ${relpath}`);
89
- const realpath = join(pkgDir, filepath);
90
- return realpath;
91
- }
92
- const cache = {};
93
- function resolveFile(relpath) {
94
- cache[relpath] || (cache[relpath] = doResolveFile(relpath));
95
- return cache[relpath];
53
+ return `${ASSETS_PREFIX}${path}`;
96
54
  }
97
-
55
+ const rootDirPromise = packageDirectory({
56
+ cwd: new URL(import.meta.url).pathname
57
+ });
58
+ const assetsDirPromise = rootDirPromise.then((rootDir) => {
59
+ if (!rootDir)
60
+ throw new Error("Could not find root dir");
61
+ return resolve(rootDir, `.${ASSETS_PREFIX}`);
62
+ });
98
63
  function sequence(fn) {
99
64
  let promise;
100
65
  return () => {
101
66
  promise || (promise = fn().finally(() => {
102
- promise = undefined;
67
+ promise = void 0;
103
68
  }));
104
69
  return promise;
105
70
  };
106
71
  }
107
72
  class BufferContentProvider {
108
73
  constructor() {
109
- this.deferredSet = new Set();
74
+ this.deferredSet = /* @__PURE__ */ new Set();
110
75
  this.events = new EventEmitter();
111
76
  this.ts = 0;
112
- this.content = '';
77
+ this.content = "";
113
78
  this.line = -1;
114
- this.events.on('content', () => {
79
+ this.events.on("content", () => {
115
80
  this.feed({
116
81
  ts: this.ts,
117
82
  content: this.content
118
83
  });
119
84
  });
120
- this.events.on('cursor', () => {
85
+ this.events.on("cursor", () => {
121
86
  this.feed({
122
87
  line: this.line
123
88
  });
124
89
  });
125
90
  }
126
- async getUpdate(ts, timeout = 10000) {
91
+ async getUpdate(ts, timeout = 1e4) {
127
92
  const deferred = defer();
128
93
  this.deferredSet.add(deferred);
129
94
  setTimeout(() => {
130
95
  this.feed({}, deferred);
131
96
  }, timeout);
132
97
  if (ts < this.ts) {
133
- this.feed({
134
- ts: this.ts,
135
- content: this.content
136
- }, deferred);
98
+ this.feed({ ts: this.ts, content: this.content }, deferred);
137
99
  }
138
100
  return deferred.promise;
139
101
  }
@@ -150,25 +112,27 @@ class BufferContentProvider {
150
112
  }
151
113
  setCursor(line) {
152
114
  this.line = line;
153
- this.events.emit('cursor');
115
+ this.events.emit("cursor");
154
116
  }
155
117
  setContent(content) {
156
118
  this.ts = Date.now();
157
119
  this.content = content;
158
- this.events.emit('content');
120
+ this.events.emit("content");
159
121
  }
160
122
  dispose() {
161
- /* noop */
162
123
  }
163
124
  }
164
125
  class FileSystemProvider extends BufferContentProvider {
165
126
  constructor(fileName) {
166
127
  super();
167
128
  this.fileName = fileName;
168
- this.watcher = chokidar.watch(fileName).on('all', sequence(() => this.update()));
129
+ this.watcher = chokidar.watch(fileName).on(
130
+ "all",
131
+ sequence(() => this.update())
132
+ );
169
133
  }
170
134
  async update() {
171
- const content = await readFile(this.fileName, 'utf8');
135
+ const content = await readFile(this.fileName, "utf8");
172
136
  this.setContent(content);
173
137
  }
174
138
  dispose() {
@@ -181,33 +145,25 @@ function startServer(paddingBottom) {
181
145
  let root;
182
146
  let line;
183
147
  let offset = 0;
184
- const {
185
- mm,
186
- markmap
187
- } = window;
148
+ const { mm, markmap } = window;
188
149
  refresh();
189
150
  function refresh() {
190
- fetch(`/data?ts=${ts}`).then(res => res.json()).then(res => {
151
+ fetch(`/data?ts=${ts}`).then((res) => res.json()).then((res) => {
191
152
  if (res.ts && res.ts > ts && res.result) {
192
- var _frontmatter;
193
153
  let frontmatter;
194
- ({
195
- root,
196
- frontmatter,
197
- contentLineOffset: offset
198
- } = res.result);
199
- mm.setOptions(markmap.deriveOptions((_frontmatter = frontmatter) == null ? void 0 : _frontmatter.markmap));
154
+ ({ root, frontmatter, contentLineOffset: offset } = res.result);
155
+ mm.setOptions(markmap.deriveOptions(frontmatter == null ? void 0 : frontmatter.markmap));
200
156
  mm.setData(root);
201
- if (!ts) mm.fit();
157
+ if (!ts)
158
+ mm.fit();
202
159
  ts = res.ts;
203
160
  line = -1;
204
161
  }
205
162
  if (root && res.line != null && line !== res.line) {
206
163
  line = res.line;
207
164
  const active = findActiveNode();
208
- if (active) mm.ensureView(active, {
209
- bottom: paddingBottom
210
- });
165
+ if (active)
166
+ mm.ensureView(active, { bottom: paddingBottom });
211
167
  }
212
168
  setTimeout(refresh, 300);
213
169
  });
@@ -218,36 +174,37 @@ function startServer(paddingBottom) {
218
174
  dfs(root);
219
175
  return best;
220
176
  function dfs(node) {
221
- var _node$payload, _node$children;
222
- const lines = (_node$payload = node.payload) == null ? void 0 : _node$payload.lines;
177
+ var _a, _b;
178
+ const lines = (_a = node.payload) == null ? void 0 : _a.lines;
223
179
  if (lines && lines[0] <= lineWithoutFrontmatter && lineWithoutFrontmatter < lines[1]) {
224
180
  best = node;
225
181
  }
226
- (_node$children = node.children) == null || _node$children.forEach(dfs);
182
+ (_b = node.children) == null ? void 0 : _b.forEach(dfs);
227
183
  }
228
184
  }
229
185
  }
230
186
  function setUpServer(transformer, provider, options) {
231
187
  let assets = transformer.getAssets();
232
- if (options.toolbar) assets = addToolbar(transformer, assets);
233
- const html = `${transformer.fillTemplate(null, assets)}<script>(${startServer.toString()})(${options.toolbar ? 60 : 0})</script>`;
188
+ if (options.toolbar)
189
+ assets = addToolbar(transformer.urlBuilder, assets);
190
+ const html = `${transformer.fillTemplate(
191
+ null,
192
+ assets
193
+ )}<script>(${startServer.toString()})(${options.toolbar ? 60 : 0})<\/script>`;
234
194
  const app = new Koa();
235
195
  app.use(async (ctx, next) => {
236
- if (ctx.path === '/') {
196
+ if (ctx.path === "/") {
237
197
  ctx.body = html;
238
- } else if (ctx.path === '/data') {
198
+ } else if (ctx.path === "/data") {
239
199
  const update = await provider.getUpdate(ctx.query.ts);
240
- const result = update.content == null ? null : transformer.transform(update.content || '');
241
- ctx.body = {
242
- ts: update.ts,
243
- result,
244
- line: update.line
245
- };
200
+ const result = update.content == null ? null : transformer.transform(update.content || "");
201
+ ctx.body = { ts: update.ts, result, line: update.line };
246
202
  } else {
247
- if (ctx.path.startsWith('/node_modules/')) {
248
- const relpath = ctx.path.slice(14);
203
+ if (ctx.path.startsWith(ASSETS_PREFIX)) {
204
+ const relpath = ctx.path.slice(ASSETS_PREFIX.length);
205
+ const assetsDir = await assetsDirPromise;
249
206
  try {
250
- const realpath = await resolveFile(relpath);
207
+ const realpath = resolve(assetsDir, relpath);
251
208
  ctx.type = extname(relpath);
252
209
  ctx.body = createReadStream(realpath);
253
210
  return;
@@ -261,20 +218,24 @@ function setUpServer(transformer, provider, options) {
261
218
  const handle = app.callback();
262
219
  const server = http.createServer(handle);
263
220
  server.listen(() => {
264
- const {
265
- port
266
- } = server.address();
221
+ const { port } = server.address();
267
222
  console.info(`Listening at http://localhost:${port}`);
268
- if (options.open) open(`http://localhost:${port}`);
223
+ if (options.open)
224
+ open(`http://localhost:${port}`);
269
225
  });
270
226
  let closing;
271
227
  return {
272
228
  provider,
273
229
  close() {
274
230
  if (!closing) {
275
- closing = new Promise((resolve, reject) => server.close(err => {
276
- if (err) reject(err);else resolve();
277
- }));
231
+ closing = new Promise(
232
+ (resolve2, reject) => server.close((err) => {
233
+ if (err)
234
+ reject(err);
235
+ else
236
+ resolve2();
237
+ })
238
+ );
278
239
  }
279
240
  return closing;
280
241
  }
@@ -282,31 +243,91 @@ function setUpServer(transformer, provider, options) {
282
243
  }
283
244
  async function develop(fileName, options) {
284
245
  const transformer = new Transformer();
285
- transformer.urlBuilder.setProvider('local', localProvider);
286
- transformer.urlBuilder.provider = 'local';
246
+ transformer.urlBuilder.setProvider("local", localProvider);
247
+ transformer.urlBuilder.provider = "local";
287
248
  const provider = fileName ? new FileSystemProvider(fileName) : new BufferContentProvider();
288
249
  return setUpServer(transformer, provider, options);
289
250
  }
290
-
251
+ const providerName = "local-hook";
252
+ async function fetchAssets() {
253
+ var _a, _b;
254
+ const transformer = new Transformer();
255
+ const { provider } = transformer.urlBuilder;
256
+ transformer.urlBuilder.setProvider(providerName, localProvider);
257
+ transformer.urlBuilder.provider = providerName;
258
+ let assets = transformer.getAssets();
259
+ assets = addToolbar(transformer.urlBuilder, assets);
260
+ delete transformer.urlBuilder.providers[providerName];
261
+ transformer.urlBuilder.provider = provider;
262
+ const pluginPaths = [
263
+ ...((_a = assets.scripts) == null ? void 0 : _a.map(
264
+ (item) => item.type === "script" && item.data.src || ""
265
+ )) || [],
266
+ ...((_b = assets.styles) == null ? void 0 : _b.map(
267
+ (item) => item.type === "stylesheet" && item.data.href || ""
268
+ )) || []
269
+ ].filter((url) => url.startsWith(ASSETS_PREFIX)).map((url) => url.slice(ASSETS_PREFIX.length));
270
+ const paths = [...baseJsPaths, ...pluginPaths];
271
+ const assetsDir = await assetsDirPromise;
272
+ const fastest = await transformer.urlBuilder.getFastestProvider();
273
+ await Promise.all(
274
+ paths.map(
275
+ (path) => downloadAsset(
276
+ resolve(assetsDir, path),
277
+ transformer.urlBuilder.getFullUrl(path, fastest)
278
+ )
279
+ )
280
+ );
281
+ }
282
+ async function downloadAsset(fullPath, url) {
283
+ try {
284
+ const result = await stat(fullPath);
285
+ if (result.isFile())
286
+ return;
287
+ } catch {
288
+ }
289
+ const res = await fetch(url);
290
+ if (!res.ok || !res.body)
291
+ throw new Error(`Failed to download: ${url}`);
292
+ await mkdir(dirname(fullPath), { recursive: true });
293
+ await finished(
294
+ Readable.fromWeb(res.body).pipe(
295
+ createWriteStream(fullPath)
296
+ )
297
+ );
298
+ }
291
299
  async function loadFile(path) {
292
- if (path.startsWith('/node_modules/')) {
293
- const relpath = path.slice(14);
294
- return readFile(await resolveFile(relpath), 'utf8');
300
+ if (path.startsWith(ASSETS_PREFIX)) {
301
+ const relpath = path.slice(ASSETS_PREFIX.length);
302
+ const assetsDir = await assetsDirPromise;
303
+ return readFile(resolve(assetsDir, relpath), "utf8");
295
304
  }
296
305
  const res = await fetch(path);
297
- if (!res.ok) throw res;
306
+ if (!res.ok)
307
+ throw res;
298
308
  return res.text();
299
309
  }
300
310
  async function inlineAssets(assets) {
301
- const [scripts, styles] = await Promise.all([Promise.all((assets.scripts || []).map(async item => item.type === 'script' && item.data.src ? {
302
- type: 'script',
303
- data: {
304
- textContent: await loadFile(item.data.src)
305
- }
306
- } : item)), Promise.all((assets.styles || []).map(async item => item.type === 'stylesheet' ? {
307
- type: 'style',
308
- data: await loadFile(item.data.href)
309
- } : item))]);
311
+ const [scripts, styles] = await Promise.all([
312
+ Promise.all(
313
+ (assets.scripts || []).map(
314
+ async (item) => item.type === "script" && item.data.src ? {
315
+ type: "script",
316
+ data: {
317
+ textContent: await loadFile(item.data.src)
318
+ }
319
+ } : item
320
+ )
321
+ ),
322
+ Promise.all(
323
+ (assets.styles || []).map(
324
+ async (item) => item.type === "stylesheet" ? {
325
+ type: "style",
326
+ data: await loadFile(item.data.href)
327
+ } : item
328
+ )
329
+ )
330
+ ]);
310
331
  return {
311
332
  scripts,
312
333
  styles
@@ -315,26 +336,27 @@ async function inlineAssets(assets) {
315
336
  async function createMarkmap(options) {
316
337
  const transformer = new Transformer();
317
338
  if (options.offline) {
318
- transformer.urlBuilder.setProvider('local', localProvider);
319
- transformer.urlBuilder.provider = 'local';
339
+ transformer.urlBuilder.setProvider("local", localProvider);
340
+ transformer.urlBuilder.provider = "local";
320
341
  } else {
321
342
  try {
322
343
  await transformer.urlBuilder.findFastestProvider();
323
- } catch (_unused) {
324
- // ignore
344
+ } catch {
325
345
  }
326
346
  }
327
- const {
328
- root,
329
- features,
330
- frontmatter
331
- } = transformer.transform(options.content || '');
347
+ const { root, features, frontmatter } = transformer.transform(
348
+ options.content || ""
349
+ );
332
350
  let assets = transformer.getUsedAssets(features);
333
- assets = _extends({}, assets, {
334
- scripts: [...baseJsPaths.map(path => transformer.urlBuilder.getFullUrl(path)).map(path => buildJSItem(path)), ...(assets.scripts || [])]
335
- });
351
+ assets = {
352
+ ...assets,
353
+ scripts: [
354
+ ...baseJsPaths.map((path) => transformer.urlBuilder.getFullUrl(path)).map((path) => buildJSItem(path)),
355
+ ...assets.scripts || []
356
+ ]
357
+ };
336
358
  if (options.toolbar) {
337
- assets = addToolbar(transformer, assets);
359
+ assets = addToolbar(transformer.urlBuilder, assets);
338
360
  }
339
361
  if (options.offline) {
340
362
  assets = await inlineAssets(assets);
@@ -343,29 +365,40 @@ async function createMarkmap(options) {
343
365
  baseJs: [],
344
366
  jsonOptions: frontmatter == null ? void 0 : frontmatter.markmap
345
367
  });
346
- const output = options.output || 'markmap.html';
347
- await writeFile(output, html, 'utf8');
348
- if (options.open) open(output);
368
+ const output = options.output || "markmap.html";
369
+ await writeFile(output, html, "utf8");
370
+ if (options.open)
371
+ open(output);
349
372
  }
350
373
  async function main() {
351
- var _await$readPackageUp;
352
- const pkg = (_await$readPackageUp = await readPackageUp({
374
+ var _a;
375
+ const pkg = (_a = await readPackageUp({
353
376
  cwd: fileURLToPath(import.meta.url)
354
- })) == null ? void 0 : _await$readPackageUp.packageJson;
355
- if (!pkg) throw new Error('package.json not found');
356
- const notifier = updateNotifier({
357
- pkg
358
- });
377
+ })) == null ? void 0 : _a.packageJson;
378
+ if (!pkg)
379
+ throw new Error("package.json not found");
380
+ const notifier = updateNotifier({ pkg });
359
381
  notifier.notify();
360
382
  const program = new Command();
361
- program.version(pkg.version).description('Create a markmap from a Markdown input file').arguments('<input>').option('--no-open', 'do not open the output file after generation').option('--no-toolbar', 'do not show toolbar').option('-o, --output <output>', 'specify filename of the output HTML').option('--offline', 'Inline all assets to allow the generated HTML to work offline').option('-w, --watch', 'watch the input file and update output on the fly, note that this feature is for development only').action(async (input, cmd) => {
362
- const content = await readFile(input, 'utf8');
363
- const output = cmd.output || `${input.replace(/\.\w*$/, '')}.html`;
383
+ program.version(pkg.version).description("Create a markmap from a Markdown input file").arguments("<input>").option("--no-open", "do not open the output file after generation").option("--no-toolbar", "do not show toolbar").option("-o, --output <output>", "specify filename of the output HTML").option(
384
+ "--offline",
385
+ "Inline all assets to allow the generated HTML to work offline"
386
+ ).option(
387
+ "-w, --watch",
388
+ "watch the input file and update output on the fly, note that this feature is for development only"
389
+ ).action(async (input, cmd) => {
390
+ let { offline } = cmd;
391
+ if (cmd.watch)
392
+ offline = true;
393
+ if (offline)
394
+ await fetchAssets();
395
+ const content = await readFile(input, "utf8");
396
+ const output = cmd.output || `${input.replace(/\.\w*$/, "")}.html`;
364
397
  if (cmd.watch) {
365
398
  await develop(input, {
366
399
  open: cmd.open,
367
400
  toolbar: cmd.toolbar,
368
- offline: true
401
+ offline
369
402
  });
370
403
  } else {
371
404
  await createMarkmap({
@@ -373,11 +406,15 @@ async function main() {
373
406
  output,
374
407
  open: cmd.open,
375
408
  toolbar: cmd.toolbar,
376
- offline: cmd.offline
409
+ offline
377
410
  });
378
411
  }
379
412
  });
380
413
  program.parse(process.argv);
381
414
  }
382
-
383
- export { createMarkmap, develop, main };
415
+ export {
416
+ createMarkmap,
417
+ develop,
418
+ fetchAssets,
419
+ main
420
+ };
@@ -1,4 +1,6 @@
1
- import { IAssets, ITransformer } from 'markmap-lib';
1
+ import { UrlBuilder } from 'markmap-common';
2
+ import { IAssets } from 'markmap-lib';
3
+ export declare const ASSETS_PREFIX = "/assets/";
2
4
  export interface IDevelopOptions {
3
5
  /**
4
6
  * Whether to open the generated markmap in browser
@@ -14,6 +16,7 @@ export interface IDevelopOptions {
14
16
  */
15
17
  offline: boolean;
16
18
  }
17
- export declare function addToolbar(transformer: ITransformer, assets: IAssets): IAssets;
19
+ export declare function addToolbar(urlBuilder: UrlBuilder, assets: IAssets): IAssets;
18
20
  export declare function localProvider(path: string): string;
19
- export declare function resolveFile(relpath: string): Promise<string>;
21
+ export declare const rootDirPromise: Promise<string | undefined>;
22
+ export declare const assetsDirPromise: Promise<string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markmap-cli",
3
- "version": "0.15.5-alpha.1+013bf59",
3
+ "version": "0.15.6-alpha.4+4734119",
4
4
  "description": "Create markmaps from CLI",
5
5
  "author": "Gerald <gera2ld@live.com>",
6
6
  "license": "MIT",
@@ -8,7 +8,7 @@
8
8
  "markmap": "bin/cli.js"
9
9
  },
10
10
  "engines": {
11
- "node": ">=16"
11
+ "node": ">=18"
12
12
  },
13
13
  "keywords": [
14
14
  "markmap",
@@ -25,10 +25,10 @@
25
25
  "url": "git+https://github.com/markmap/markmap.git"
26
26
  },
27
27
  "scripts": {
28
- "dev": "rollup -wc",
29
- "clean": "del-cli dist types",
28
+ "clean": "del-cli dist",
30
29
  "build:types": "tsc",
31
- "build:js": "rollup -c"
30
+ "build:js": "vite build",
31
+ "postinstall": "node -e \"import('./dist/index.js').then(({ fetchAssets }) => fetchAssets()).catch(() => {})\""
32
32
  },
33
33
  "bugs": {
34
34
  "url": "https://github.com/markmap/markmap/issues"
@@ -38,28 +38,21 @@
38
38
  "module": "dist/index.js",
39
39
  "files": [
40
40
  "bin",
41
- "dist",
42
- "types"
41
+ "dist"
43
42
  ],
44
- "typings": "types/index.d.ts",
43
+ "typings": "dist/index.d.ts",
45
44
  "dependencies": {
46
45
  "@babel/runtime": "^7.22.6",
47
46
  "chokidar": "^3.5.3",
48
47
  "commander": "^11.0.0",
49
- "d3": "^7.8.5",
50
- "highlight.js": "^11.8.0",
51
- "katex": "^0.16.8",
52
48
  "koa": "^2.14.2",
53
- "markmap-common": "0.15.5-alpha.1+013bf59",
54
- "markmap-lib": "0.15.5-alpha.1+013bf59",
55
- "markmap-toolbar": "0.15.5-alpha.1+013bf59",
56
- "markmap-view": "0.15.5-alpha.1+013bf59",
49
+ "markmap-common": "0.15.5",
50
+ "markmap-lib": "0.15.6-alpha.4+4734119",
51
+ "markmap-toolbar": "0.15.6-alpha.4+4734119",
57
52
  "open": "^9.1.0",
58
53
  "pkg-dir": "^7.0.0",
59
- "prismjs": "^1.29.0",
60
54
  "read-pkg-up": "^10.0.0",
61
- "update-notifier": "^6.0.2",
62
- "webfontloader": "^1.6.28"
55
+ "update-notifier": "^6.0.2"
63
56
  },
64
- "gitHead": "013bf59b71f2253dc54249c4a5a3097bf686494f"
57
+ "gitHead": "473411985496abcc20a546978438614c48ec56cf"
65
58
  }
File without changes