New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

markmap-lib

Package Overview
Dependencies
Maintainers
1
Versions
145
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markmap-lib - npm Package Compare versions

Comparing version 0.15.9-alpha.6 to 0.15.9-alpha.11

dist/index.no-plugins.js

2

dist/constants.d.ts
export declare const template: string;
export declare const baseJsPaths: string[];
export declare const svg_marked = "<svg width=\"16\" height=\"16\" fill=\"currentColor\" viewBox=\"0 -3 24 24\"><path d=\"M19 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2m-9 14-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8z\"/></svg>";
export declare const svg_unmarked = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" fill=\"currentColor\" viewBox=\"0 -3 24 24\"><path fill-rule=\"evenodd\" d=\"M6 5a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1zM3 6a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3v12a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3v-5z\" clip-rule=\"evenodd\"/></svg>";

@@ -6,296 +6,11 @@ "use strict";

const remarkable = require("remarkable");
const yaml = require("js-yaml");
const hljs = require("highlight.js");
const remarkableKatex = require("remarkable-katex");
const plugins = require("./plugins.js");
require("js-yaml");
require("highlight.js");
require("remarkable-katex");
const template = '<!DOCTYPE html>\n<html>\n<head>\n<meta charset="UTF-8">\n<meta name="viewport" content="width=device-width, initial-scale=1.0">\n<meta http-equiv="X-UA-Compatible" content="ie=edge">\n<title>Markmap</title>\n<style>\n* {\n margin: 0;\n padding: 0;\n}\n#mindmap {\n display: block;\n width: 100vw;\n height: 100vh;\n}\n</style>\n<!--CSS-->\n</head>\n<body>\n<svg id="mindmap"></svg>\n<!--JS-->\n</body>\n</html>\n';
const baseJsPaths = [
`d3@${"7.8.5"}/dist/d3.min.js`,
`markmap-view@${"0.15.9-alpha.6"}/dist/browser/index.js`
`markmap-view@${"0.15.8"}/dist/browser/index.js`
];
const svg_marked = `<svg width="16" height="16" fill="currentColor" viewBox="0 -3 24 24"><path d="M19 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2m-9 14-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8z"/></svg>`;
const svg_unmarked = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 -3 24 24"><path fill-rule="evenodd" d="M6 5a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1zM3 6a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3v12a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3v-5z" clip-rule="evenodd"/></svg>`;
function createTransformHooks(transformer) {
return {
transformer,
parser: new markmapCommon.Hook(),
beforeParse: new markmapCommon.Hook(),
afterParse: new markmapCommon.Hook(),
htmltag: new markmapCommon.Hook(),
retransform: new markmapCommon.Hook()
};
}
function definePlugin(plugin2) {
return plugin2;
}
const name$5 = "checkbox";
const plugin$3 = definePlugin({
name: name$5,
transform(transformHooks) {
transformHooks.parser.tap((md) => {
md.core.ruler.before(
"inline",
"checkbox",
(state) => {
for (let i = 2; i < state.tokens.length; i += 1) {
const token = state.tokens[i];
if (token.type === "inline" && token.content) {
const prevType = state.tokens[i - 1].type;
const prevPrevType = state.tokens[i - 2].type;
if (prevType === "heading_open" || prevType === "paragraph_open" && prevPrevType === "list_item_open") {
if (token.content.startsWith("[ ]")) {
token.content = `${svg_unmarked} ${token.content.slice(3)}`;
} else if (token.content.startsWith("[x]")) {
token.content = `${svg_marked} ${token.content.slice(3)}`;
}
}
}
}
return false;
},
{}
);
});
return {};
}
});
const name$4 = "frontmatter";
const frontmatter = definePlugin({
name: name$4,
transform(transformHooks) {
transformHooks.beforeParse.tap((md, context) => {
const { content } = context;
if (!/^---\r?\n/.test(content))
return;
const match = /\n---\r?\n/.exec(content);
if (!match)
return;
const raw = content.slice(4, match.index);
let frontmatter2;
try {
frontmatter2 = yaml.load(raw);
if (frontmatter2 == null ? void 0 : frontmatter2.markmap) {
frontmatter2.markmap = normalizeMarkmapJsonOptions(
frontmatter2.markmap
);
}
} catch {
return;
}
context.frontmatter = frontmatter2;
context.content = content.slice(match.index + match[0].length);
context.contentLineOffset = content.slice(0, match.index).split("\n").length + 1;
});
return {};
}
});
function normalizeMarkmapJsonOptions(options) {
if (!options)
return;
["color", "extraJs", "extraCss"].forEach((key) => {
if (options[key] != null)
options[key] = normalizeStringArray(options[key]);
});
["duration", "maxWidth", "initialExpandLevel"].forEach((key) => {
if (options[key] != null)
options[key] = normalizeNumber(options[key]);
});
return options;
}
function normalizeStringArray(value) {
let result;
if (typeof value === "string")
result = [value];
else if (Array.isArray(value))
result = value.filter((item) => item && typeof item === "string");
return (result == null ? void 0 : result.length) ? result : void 0;
}
function normalizeNumber(value) {
if (isNaN(+value))
return;
return +value;
}
const name$3 = "hljs";
const preloadScripts$1 = [
`@highlightjs/cdn-assets@${"11.8.0"}/highlight.min.js`
].map((path) => markmapCommon.buildJSItem(path));
const styles$1 = [
`@highlightjs/cdn-assets@${"11.8.0"}/styles/default.min.css`
// `highlight.js@${process.env.HLJS_VERSION}/styles/default.css`,
].map((path) => markmapCommon.buildCSSItem(path));
const config$1 = {
versions: {
hljs: "11.8.0"
},
preloadScripts: preloadScripts$1,
styles: styles$1
};
const plugin$2 = definePlugin({
name: name$3,
config: config$1,
transform(transformHooks) {
var _a;
let enableFeature = markmapCommon.noop;
transformHooks.parser.tap((md) => {
md.set({
highlight: (str, language) => {
enableFeature();
return hljs.highlightAuto(str, language ? [language] : void 0).value;
}
});
});
transformHooks.beforeParse.tap((_, context) => {
enableFeature = () => {
context.features[name$3] = true;
};
});
return {
styles: (_a = plugin$2.config) == null ? void 0 : _a.styles
};
}
});
const name$2 = "katex";
const preloadScripts = [
`katex@${"0.16.8"}/dist/katex.min.js`
].map((path) => markmapCommon.buildJSItem(path));
const webfontloader = markmapCommon.buildJSItem(
`webfontloader@${"1.6.28"}/webfontloader.js`
);
webfontloader.data.defer = true;
const styles = [`katex@${"0.16.8"}/dist/katex.min.css`].map(
(path) => markmapCommon.buildCSSItem(path)
);
const config = {
versions: {
katex: "0.16.8",
webfontloader: "1.6.28"
},
preloadScripts,
scripts: [
{
type: "iife",
data: {
fn: (getMarkmap) => {
window.WebFontConfig = {
custom: {
families: [
"KaTeX_AMS",
"KaTeX_Caligraphic:n4,n7",
"KaTeX_Fraktur:n4,n7",
"KaTeX_Main:n4,n7,i4,i7",
"KaTeX_Math:i4,i7",
"KaTeX_Script",
"KaTeX_SansSerif:n4,n7,i4",
"KaTeX_Size1",
"KaTeX_Size2",
"KaTeX_Size3",
"KaTeX_Size4",
"KaTeX_Typewriter"
]
},
active: () => {
getMarkmap().refreshHook.call();
}
};
},
getParams({ getMarkmap }) {
return [getMarkmap];
}
}
},
webfontloader
],
styles
};
const plugin$1 = definePlugin({
name: name$2,
config,
transform(transformHooks) {
var _a, _b;
let enableFeature = markmapCommon.noop;
transformHooks.parser.tap((md) => {
md.use(remarkableKatex);
md.renderer.rules.katex = markmapCommon.wrapFunction(
md.renderer.rules.katex,
(render, ...args) => {
enableFeature();
return render(...args);
}
);
});
transformHooks.beforeParse.tap((_, context) => {
enableFeature = () => {
context.features[name$2] = true;
};
});
return {
styles: (_a = plugin$1.config) == null ? void 0 : _a.styles,
scripts: (_b = plugin$1.config) == null ? void 0 : _b.scripts
};
}
});
const name$1 = "npmUrl";
const npmUrl = definePlugin({
name: name$1,
transform(transformHooks) {
transformHooks.afterParse.tap((_, context) => {
const { frontmatter: frontmatter2 } = context;
const markmap = frontmatter2 == null ? void 0 : frontmatter2.markmap;
if (markmap) {
["extraJs", "extraCss"].forEach((key) => {
const value = markmap[key];
if (value) {
markmap[key] = value.map((path) => {
if (path.startsWith("npm:")) {
return transformHooks.transformer.urlBuilder.getFullUrl(
path.slice(4)
);
}
return path;
});
}
});
}
});
return {};
}
});
const name = "sourceLines";
const plugin = definePlugin({
name,
transform(transformHooks) {
transformHooks.parser.tap((md) => {
Object.entries(md.renderer.rules).forEach(([key, value]) => {
if (typeof value === "function") {
md.renderer.rules[key] = patchRule(value);
} else {
Object.entries(value).forEach(([k, v]) => {
value[k] = patchRule(v);
});
}
});
});
return {};
}
});
function patchRule(rule) {
return markmapCommon.wrapFunction(rule, (render, tokens, idx, ...rest) => {
let html = render(tokens, idx, ...rest);
const { lines } = tokens[idx];
if (lines) {
html = html.replace(
/^<[\w-]+/,
(m) => `${m} data-lines="${lines.join(",")}"`
);
}
return html;
});
}
const plugins = [
frontmatter,
plugin$1,
plugin$2,
npmUrl,
plugin$3,
plugin
];
function patchJSItem(urlBuilder, item) {

@@ -325,2 +40,3 @@ if (item.type === "script" && item.data.src) {

}
const builtInPlugins = plugins.plugins;
function cleanNode(node) {

@@ -342,12 +58,12 @@ while (!node.content && node.children.length === 1) {

class Transformer {
constructor(plugins$1 = plugins) {
constructor(plugins$1 = builtInPlugins) {
this.assetsMap = {};
this.urlBuilder = new markmapCommon.UrlBuilder();
this.hooks = createTransformHooks(this);
this.hooks = plugins.createTransformHooks(this);
this.plugins = plugins$1.map(
(plugin2) => typeof plugin2 === "function" ? plugin2() : plugin2
(plugin) => typeof plugin === "function" ? plugin() : plugin
);
const assetsMap = {};
for (const { name: name2, transform } of this.plugins) {
assetsMap[name2] = transform(this.hooks);
for (const { name, transform } of this.plugins) {
assetsMap[name] = transform(this.hooks);
}

@@ -393,9 +109,9 @@ this.assetsMap = assetsMap;

getAssets(keys) {
const styles2 = [];
const styles = [];
const scripts = [];
keys ?? (keys = this.plugins.map((plugin2) => plugin2.name));
keys ?? (keys = this.plugins.map((plugin) => plugin.name));
for (const assets of keys.map((key) => this.assetsMap[key])) {
if (assets) {
if (assets.styles)
styles2.push(...assets.styles);
styles.push(...assets.styles);
if (assets.scripts)

@@ -406,3 +122,3 @@ scripts.push(...assets.scripts);

return {
styles: styles2.map((item) => patchCSSItem(this.urlBuilder, item)),
styles: styles.map((item) => patchCSSItem(this.urlBuilder, item)),
scripts: scripts.map((item) => patchJSItem(this.urlBuilder, item))

@@ -415,3 +131,3 @@ };

getUsedAssets(features) {
const keys = this.plugins.map((plugin2) => plugin2.name).filter((name2) => features[name2]);
const keys = this.plugins.map((plugin) => plugin.name).filter((name) => features[name]);
return this.getAssets(keys);

@@ -424,4 +140,4 @@ }

extra.baseJs ?? (extra.baseJs = baseJsPaths.map((path) => this.urlBuilder.getFullUrl(path)).map((path) => markmapCommon.buildJSItem(path)));
const { scripts, styles: styles2 } = assets;
const cssList = [...styles2 ? markmapCommon.persistCSS(styles2) : []];
const { scripts, styles } = assets;
const cssList = [...styles ? markmapCommon.persistCSS(styles) : []];
const context = {

@@ -468,6 +184,4 @@ getMarkmap: () => window.markmap,

exports.baseJsPaths = baseJsPaths;
exports.builtInPlugins = plugins;
exports.svg_marked = svg_marked;
exports.svg_unmarked = svg_unmarked;
exports.builtInPlugins = builtInPlugins;
exports.template = template;
exports.transformerVersions = transformerVersions;
import { IMarkmapOptions, IPureNode, JSItem, UrlBuilder } from 'markmap-common';
import { IHtmlParserOptions } from 'markmap-html-parser';
import { Remarkable } from 'remarkable';
import { plugins as builtInPlugins } from './plugins';
import { IAssets, IFeatures, ITransformHooks, ITransformPlugin, ITransformResult, ITransformer, IMarkmapJSONOptions } from './types';
export { builtInPlugins };
export declare const builtInPlugins: ITransformPlugin[];
export declare class Transformer implements ITransformer {

@@ -8,0 +7,0 @@ hooks: ITransformHooks;

{
"name": "markmap-lib",
"version": "0.15.9-alpha.6+ccc1c15",
"version": "0.15.9-alpha.11+d60da2f",
"description": "Visualize your Markdown as mindmaps with Markmap",

@@ -10,3 +10,4 @@ "author": "Gerald <gera2ld@live.com>",

"build:types": "tsc",
"build:js": "vite build && TARGET=browserEs vite build --emptyOutDir=false && TARGET=browserJs vite build --emptyOutDir=false",
"build:js": "vite build && TARGET=nodeLight vite build && TARGET=browserEs vite build && TARGET=browserJs vite build",
"build": "run-s clean build:*",
"test": "jest test"

@@ -18,2 +19,3 @@ },

},
"sideEffects": false,
"main": "dist/index.js",

@@ -30,2 +32,12 @@ "module": "dist/index.mjs",

},
"./plugins": {
"types": "./dist/plugins/index.d.ts",
"require": "./dist/plugins.js",
"default": "./dist/plugins.mjs"
},
"./no-plugins": {
"types": "./dist/index.d.ts",
"require": "./dist/index.no-plugins.js",
"default": "./dist/index.no-plugins.mjs"
},
"./package.json": "./package.json"

@@ -53,4 +65,4 @@ },

"@types/remarkable": "^2.0.3",
"markmap-common": "0.15.9-alpha.6+ccc1c15",
"markmap-view": "0.15.9-alpha.6+ccc1c15",
"markmap-common": "0.15.9-alpha.11+d60da2f",
"markmap-view": "0.15.9-alpha.11+d60da2f",
"webfontloader": "^1.6.28"

@@ -63,3 +75,3 @@ },

"katex": "^0.16.8",
"markmap-html-parser": "0.15.9-alpha.6+ccc1c15",
"markmap-html-parser": "0.15.9-alpha.11+d60da2f",
"prismjs": "^1.29.0",

@@ -82,3 +94,3 @@ "remarkable": "^2.0.1",

},
"gitHead": "ccc1c157905c0a8aedbadcb579a79d7114b45b0b"
"gitHead": "d60da2fb13a85edec875ef002f1be414a0c00abe"
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc