markmap-cli
Advanced tools
Comparing version 0.14.4 to 0.14.5-alpha.13
@@ -1,2 +0,2 @@ | ||
/*! markmap-cli v0.14.4 | MIT License */ | ||
/*! markmap-cli v0.14.5-alpha.13+50ca560 | MIT License */ | ||
'use strict'; | ||
@@ -8,2 +8,3 @@ | ||
var markmapLib = require('markmap-lib'); | ||
var markmapCommon = require('markmap-common'); | ||
var events = require('events'); | ||
@@ -14,13 +15,5 @@ var http = require('http'); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; } | ||
var open__default = /*#__PURE__*/_interopDefaultLegacy(open); | ||
var http__default = /*#__PURE__*/_interopDefaultLegacy(http); | ||
var Koa__default = /*#__PURE__*/_interopDefaultLegacy(Koa); | ||
var chokidar__default = /*#__PURE__*/_interopDefaultLegacy(chokidar); | ||
const TOOLBAR_VERSION = "0.14.4"; | ||
const TOOLBAR_CSS = `npm/markmap-toolbar@${TOOLBAR_VERSION}/dist/style.min.css`; | ||
const TOOLBAR_JS = `npm/markmap-toolbar@${TOOLBAR_VERSION}/dist/index.umd.min.js`; | ||
const TOOLBAR_VERSION = "0.14.5-alpha.13+50ca560"; | ||
const TOOLBAR_CSS = `markmap-toolbar@${TOOLBAR_VERSION}/dist/style.min.css`; | ||
const TOOLBAR_JS = `markmap-toolbar@${TOOLBAR_VERSION}/dist/index.umd.min.js`; | ||
const renderToolbar = () => { | ||
@@ -37,17 +30,6 @@ const { | ||
}; | ||
function addToolbar(assets) { | ||
return { | ||
styles: [...(assets.styles || []), { | ||
type: 'stylesheet', | ||
data: { | ||
href: `https://cdn.jsdelivr.net/${TOOLBAR_CSS}` | ||
} | ||
}], | ||
scripts: [...(assets.scripts || []), { | ||
type: 'script', | ||
data: { | ||
src: `https://cdn.jsdelivr.net/${TOOLBAR_JS}` | ||
} | ||
}, { | ||
styles: [...(assets.styles || []), ...[TOOLBAR_CSS].map(markmapCommon.buildCSSItem)], | ||
scripts: [...(assets.scripts || []), ...[TOOLBAR_JS].map(markmapCommon.buildJSItem), { | ||
type: 'iife', | ||
@@ -70,21 +52,14 @@ data: { | ||
} | ||
} | ||
/* eslint-disable max-classes-per-file */ | ||
function consecutive(fn) { | ||
function sequence(fn) { | ||
let promise; | ||
return () => { | ||
if (!promise) { | ||
promise = fn(); | ||
promise.catch(() => {}).then(() => { | ||
promise = null; | ||
}); | ||
} | ||
promise || (promise = fn().finally(() => { | ||
promise = null; | ||
})); | ||
return promise; | ||
}; | ||
} | ||
class BufferContentProvider { | ||
@@ -107,3 +82,2 @@ constructor() { | ||
} | ||
async getUpdate(ts, timeout = 10000) { | ||
@@ -115,3 +89,2 @@ const deferred = new Defer(); | ||
}, timeout); | ||
if (ts < this.ts) { | ||
@@ -123,6 +96,4 @@ this.feed({ | ||
} | ||
return deferred.promise; | ||
} | ||
feed(data, deferred) { | ||
@@ -136,7 +107,5 @@ if (deferred) { | ||
} | ||
this.deferredSet.clear(); | ||
} | ||
} | ||
setCursor(line) { | ||
@@ -146,3 +115,2 @@ this.line = line; | ||
} | ||
setContent(content) { | ||
@@ -153,7 +121,6 @@ this.ts = Date.now(); | ||
} | ||
dispose() {} | ||
dispose() { | ||
/* noop */ | ||
} | ||
} | ||
class FileSystemProvider extends BufferContentProvider { | ||
@@ -163,5 +130,4 @@ constructor(fileName) { | ||
this.fileName = fileName; | ||
this.watcher = chokidar__default.watch(fileName).on('all', consecutive(() => this.update())); | ||
this.watcher = chokidar.watch(fileName).on('all', sequence(() => this.update())); | ||
} | ||
async update() { | ||
@@ -171,3 +137,2 @@ const content = await fs.promises.readFile(this.fileName, 'utf8'); | ||
} | ||
dispose() { | ||
@@ -177,5 +142,3 @@ super.dispose(); | ||
} | ||
} | ||
function startServer(paddingBottom) { | ||
@@ -188,3 +151,2 @@ let ts = 0; | ||
refresh(); | ||
function refresh() { | ||
@@ -195,3 +157,4 @@ fetch(`/data?ts=${ts}`).then(res => res.json()).then(res => { | ||
root, | ||
frontmatter | ||
frontmatter, | ||
contentLineOffset | ||
} = res.result; | ||
@@ -203,3 +166,2 @@ mm.setOptions(markmap.deriveOptions(frontmatter == null ? void 0 : frontmatter.markmap)); | ||
} | ||
setTimeout(refresh, 300); | ||
@@ -209,3 +171,2 @@ }); | ||
} | ||
function setUpServer(transformer, provider, options) { | ||
@@ -215,3 +176,3 @@ let assets = transformer.getAssets(); | ||
const html = `${markmapLib.fillTemplate(null, assets)}<script>(${startServer.toString()})(${options.toolbar ? 60 : 0})</script>`; | ||
const app = new Koa__default(); | ||
const app = new Koa(); | ||
app.use(async (ctx, next) => { | ||
@@ -233,3 +194,3 @@ if (ctx.path === '/') { | ||
const handle = app.callback(); | ||
const server = http__default.createServer(handle); | ||
const server = http.createServer(handle); | ||
server.listen(() => { | ||
@@ -240,3 +201,3 @@ const { | ||
console.info(`Listening at http://localhost:${port}`); | ||
if (options.open) open__default(`http://localhost:${port}`); | ||
if (options.open) open(`http://localhost:${port}`); | ||
}); | ||
@@ -246,3 +207,2 @@ let closing; | ||
provider, | ||
close() { | ||
@@ -254,9 +214,6 @@ if (!closing) { | ||
} | ||
return closing; | ||
} | ||
}; | ||
} | ||
async function develop(fileName, options) { | ||
@@ -282,3 +239,3 @@ const transformer = new markmapLib.Transformer(); | ||
await fs.promises.writeFile(output, html, 'utf8'); | ||
if (options.open) open__default(output); | ||
if (options.open) open(output); | ||
} | ||
@@ -290,3 +247,2 @@ function main(version) { | ||
const output = cmd.output || `${input.replace(/\.\w*$/, '')}.html`; | ||
if (cmd.watch) { | ||
@@ -312,4 +268,4 @@ await develop(input, { | ||
exports.main = main; | ||
for (var k in markmapLib) { | ||
if (k !== 'default' && !exports.hasOwnProperty(k)) exports[k] = markmapLib[k]; | ||
} | ||
Object.keys(markmapLib).forEach(function (k) { | ||
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = markmapLib[k]; | ||
}); |
{ | ||
"name": "markmap-cli", | ||
"version": "0.14.4", | ||
"version": "0.14.5-alpha.13+50ca560", | ||
"description": "Create markmaps from CLI", | ||
@@ -15,3 +15,3 @@ "author": "Gerald <gera2ld@live.com>", | ||
], | ||
"homepage": "https://github.com/gera2ld/markmap/packages/markmap-cli#readme", | ||
"homepage": "https://github.com/markmap/markmap/packages/markmap-cli#readme", | ||
"publishConfig": { | ||
@@ -23,3 +23,3 @@ "access": "public", | ||
"type": "git", | ||
"url": "git+https://github.com/gera2ld/markmap.git" | ||
"url": "git+https://github.com/markmap/markmap.git" | ||
}, | ||
@@ -33,3 +33,3 @@ "scripts": { | ||
"bugs": { | ||
"url": "https://github.com/gera2ld/markmap/issues" | ||
"url": "https://github.com/markmap/markmap/issues" | ||
}, | ||
@@ -48,4 +48,4 @@ "main": "dist/index.js", | ||
"koa": "^2.13.1", | ||
"markmap-common": "^0.14.2", | ||
"markmap-lib": "^0.14.4", | ||
"markmap-common": "0.14.5-alpha.13+50ca560", | ||
"markmap-lib": "0.14.5-alpha.13+50ca560", | ||
"open": "^8.0.3", | ||
@@ -55,8 +55,6 @@ "update-notifier": "^5.1.0" | ||
"devDependencies": { | ||
"markmap-view": "^0.14.4" | ||
"markmap-toolbar": "0.14.5-alpha.13+50ca560", | ||
"markmap-view": "0.14.5-alpha.13+50ca560" | ||
}, | ||
"engines": { | ||
"node": ">=10" | ||
}, | ||
"gitHead": "8eb2fa223ab85d1a7699d2c9660fdb5fac24acd1" | ||
"gitHead": "50ca5603019498f93dba6485c96d0a5630b221e5" | ||
} |
@@ -1,2 +0,2 @@ | ||
import type { IMarkmapCreateOptions } from 'markmap-lib'; | ||
import { type IMarkmapCreateOptions } from 'markmap-lib'; | ||
import { IDevelopOptions } from './util'; | ||
@@ -3,0 +3,0 @@ import { develop } from './dev-server'; |
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
12419
2
290
3
- Removedargparse@1.0.102.0.1(transitive)
- Removedautolinker@3.16.2(transitive)
- Removedcommander@8.3.0(transitive)
- Removedjs-yaml@4.1.0(transitive)
- Removedkatex@0.16.21(transitive)
- Removedmarkmap-common@0.14.2(transitive)
- Removedmarkmap-lib@0.14.4(transitive)
- Removedprismjs@1.29.0(transitive)
- Removedremarkable@2.0.1(transitive)
- Removedremarkable-katex@1.2.1(transitive)
- Removedsprintf-js@1.0.3(transitive)
- Removedtslib@2.8.1(transitive)