Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

markmap-lib

Package Overview
Dependencies
Maintainers
1
Versions
144
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.14.5-alpha.21 to 0.14.5-alpha.22

types/constants.d.ts

281

dist/index.js

@@ -1,87 +0,51 @@

/*! markmap-lib v0.14.5-alpha.21+fb81f2c | MIT License */
/*! markmap-lib v0.14.5-alpha.22+04afb38 | MIT License */
'use strict';
var _extends = require('@babel/runtime/helpers/extends');
var remarkable = require('remarkable');
var markmapCommon = require('markmap-common');
var remarkable = require('remarkable');
var remarkableKatex = require('remarkable-katex');
var yaml = require('js-yaml');
var hljs$1 = require('highlight.js');
var hljs = require('highlight.js');
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.14.5-alpha.21"}/dist/browser/index.js`];
function fillTemplate(root, assets, extra) {
var _extra, _extra$baseJs;
extra = _extends({}, extra);
(_extra$baseJs = (_extra = extra).baseJs) != null ? _extra$baseJs : _extra.baseJs = baseJsPaths.map(path => markmapCommon.buildJSItem(path));
const {
scripts,
styles
} = assets;
const cssList = [...(styles ? markmapCommon.persistCSS(styles) : [])];
const context = {
getMarkmap: () => window.markmap,
getOptions: extra.getOptions,
jsonOptions: extra.jsonOptions,
root
};
const jsList = [...markmapCommon.persistJS([...extra.baseJs, ...(scripts || []), {
const baseJsPaths = [`d3@${"7.8.5"}/dist/d3.min.js`, `markmap-view@${"0.14.5-alpha.22"}/dist/browser/index.js`];
const name$3 = '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$1 = [`katex@${"0.16.8"}/dist/katex.min.css`].map(path => markmapCommon.buildCSSItem(path));
const config$1 = {
versions: {
katex: "0.16.8" ,
webfontloader: "1.6.28"
},
preloadScripts,
scripts: [{
type: 'iife',
data: {
fn: (getMarkmap, getOptions, root, jsonOptions) => {
const markmap = getMarkmap();
window.mm = markmap.Markmap.create('svg#mindmap', (getOptions || markmap.deriveOptions)(jsonOptions), root);
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,
getOptions,
root,
jsonOptions
}) => {
return [getMarkmap, getOptions, root, jsonOptions];
getParams({
getMarkmap
}) {
return [getMarkmap];
}
}
}], context)];
const html = template.replace('<!--CSS-->', () => cssList.join('')).replace('<!--JS-->', () => jsList.join(''));
return html;
}
}, webfontloader],
styles: styles$1
};
const name$3 = 'katex';
function getConfig$1() {
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));
function createTransformHooks(transformer) {
return {
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
};
}
function createTransformHooks() {
return {
transformer,
parser: new markmapCommon.Hook(),

@@ -102,27 +66,25 @@ beforeParse: new markmapCommon.Hook(),

var katex = definePlugin(() => {
const plugin = {
name: name$3,
config: getConfig$1(),
transform(transformHooks) {
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);
});
const plugin$1 = definePlugin({
name: name$3,
config: config$1,
transform(transformHooks) {
var _plugin$config, _plugin$config2;
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$3] = true;
};
});
return {
styles: plugin.config.styles,
scripts: plugin.config.scripts
});
transformHooks.beforeParse.tap((_, context) => {
enableFeature = () => {
context.features[name$3] = true;
};
}
};
return plugin;
});
return {
styles: (_plugin$config = plugin$1.config) == null ? void 0 : _plugin$config.styles,
scripts: (_plugin$config2 = plugin$1.config) == null ? void 0 : _plugin$config2.scripts
};
}
});

@@ -195,3 +157,3 @@

if (path.startsWith('npm:')) {
return markmapCommon.getFullUrl(path.slice(4));
return transformHooks.transformer.urlBuilder.getFullUrl(path.slice(4));
}

@@ -209,40 +171,57 @@ return path;

const name = 'hljs';
function getConfig() {
const styles = [`highlight.js@${"11.8.0"}/styles/default.css`].map(path => markmapCommon.buildCSSItem(path));
return {
versions: {
hljs: "11.8.0"
},
styles
};
}
var hljs = definePlugin(() => {
const plugin = {
name,
config: getConfig(),
transform(transformHooks) {
let enableFeature = markmapCommon.noop;
transformHooks.parser.tap(md => {
md.set({
highlight: (str, language) => {
enableFeature();
return hljs$1.highlightAuto(str, language ? [language] : undefined).value;
}
});
const styles = [`highlight.js@${"11.8.0"}/styles/default.css`].map(path => markmapCommon.buildCSSItem(path));
const config = {
versions: {
hljs: "11.8.0"
},
styles
};
const plugin = definePlugin({
name,
config,
transform(transformHooks) {
var _plugin$config;
let enableFeature = markmapCommon.noop;
transformHooks.parser.tap(md => {
md.set({
highlight: (str, language) => {
enableFeature();
return hljs.highlightAuto(str, language ? [language] : undefined).value;
}
});
transformHooks.beforeParse.tap((_, context) => {
enableFeature = () => {
context.features[name] = true;
};
});
return {
styles: plugin.config.styles
});
transformHooks.beforeParse.tap((_, context) => {
enableFeature = () => {
context.features[name] = true;
};
}
};
return plugin;
});
return {
styles: (_plugin$config = plugin.config) == null ? void 0 : _plugin$config.styles
};
}
});
const plugins = [frontmatter, katex, hljs, npmUrl];
const plugins = [frontmatter, plugin$1, plugin, npmUrl];
function patchJSItem(transformer, item) {
if (item.type === 'script' && item.data.src) {
return _extends({}, item, {
data: _extends({}, item.data, {
src: transformer.urlBuilder.getFullUrl(item.data.src)
})
});
}
return item;
}
function patchCSSItem(transformer, item) {
if (item.type === 'stylesheet' && item.data.href) {
return _extends({}, item, {
data: _extends({}, item.data, {
href: transformer.urlBuilder.getFullUrl(item.data.href)
})
});
}
return item;
}
function cleanNode(node) {

@@ -296,3 +275,4 @@ if (node.type === 'heading') {

this.assetsMap = {};
this.hooks = createTransformHooks();
this.urlBuilder = new markmapCommon.UrlBuilder();
this.hooks = createTransformHooks(this);
this.plugins = plugins$1.map(plugin => typeof plugin === 'function' ? plugin() : plugin);

@@ -438,4 +418,4 @@ const assetsMap = {};

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

@@ -451,6 +431,41 @@ }

}
fillTemplate(root, assets, extra) {
var _extra, _extra$baseJs;
extra = _extends({}, extra);
(_extra$baseJs = (_extra = extra).baseJs) != null ? _extra$baseJs : _extra.baseJs = baseJsPaths.map(path => this.urlBuilder.getFullUrl(path)).map(path => markmapCommon.buildJSItem(path));
const {
scripts,
styles
} = assets;
const cssList = [...(styles ? markmapCommon.persistCSS(styles) : [])];
const context = {
getMarkmap: () => window.markmap,
getOptions: extra.getOptions,
jsonOptions: extra.jsonOptions,
root
};
const jsList = [...markmapCommon.persistJS([...extra.baseJs, ...(scripts || []), {
type: 'iife',
data: {
fn: (getMarkmap, getOptions, root, jsonOptions) => {
const markmap = getMarkmap();
window.mm = markmap.Markmap.create('svg#mindmap', (getOptions || markmap.deriveOptions)(jsonOptions), root);
},
getParams: ({
getMarkmap,
getOptions,
root,
jsonOptions
}) => {
return [getMarkmap, getOptions, root, jsonOptions];
}
}
}], context)];
const html = template.replace('<!--CSS-->', () => cssList.join('')).replace('<!--JS-->', () => jsList.join(''));
return html;
}
}
const transformerVersions = {
'markmap-lib': '0.14.5-alpha.21+fb81f2c',
'markmap-lib': '0.14.5-alpha.22+04afb38',
d3: "7.8.5"

@@ -462,3 +477,3 @@ };

exports.builtInPlugins = plugins;
exports.fillTemplate = fillTemplate;
exports.template = template;
exports.transformerVersions = transformerVersions;
{
"name": "markmap-lib",
"version": "0.14.5-alpha.21+fb81f2c",
"version": "0.14.5-alpha.22+04afb38",
"description": "Visualize your Markdown as mindmaps with Markmap",

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

"@types/remarkable": "^2.0.3",
"markmap-common": "0.14.5-alpha.21+fb81f2c",
"markmap-view": "0.14.5-alpha.21+fb81f2c",
"markmap-common": "0.14.5-alpha.22+04afb38",
"markmap-view": "0.14.5-alpha.22+04afb38",
"webfontloader": "^1.6.28"

@@ -67,3 +67,3 @@ },

},
"gitHead": "fb81f2cb688f400f17f911774539267219f639ce"
"gitHead": "04afb38dd0a6f3b5e8eaffde3c29e9e38b215c35"
}
export * from './types';
export * from './template';
export * from './constants';
export * from './transform';

@@ -4,0 +4,0 @@ export declare const transformerVersions: {

@@ -1,6 +0,6 @@

import { ITransformHooks, ITransformPlugin } from '../types';
export declare function createTransformHooks(): ITransformHooks;
import { ITransformer, ITransformHooks, ITransformPlugin } from '../types';
export declare function createTransformHooks(transformer: ITransformer): ITransformHooks;
/**
* This function is only used to help type checking.
*/
export declare function definePlugin(plugin: ITransformPlugin | (() => ITransformPlugin)): ITransformPlugin | (() => ITransformPlugin);
export declare function definePlugin(plugin: ITransformPlugin): ITransformPlugin;

@@ -1,2 +0,2 @@

declare const _default: import("../types").ITransformPlugin | (() => import("../types").ITransformPlugin);
declare const _default: import("../types").ITransformPlugin;
export default _default;

@@ -1,2 +0,2 @@

declare const _default: import("../types").ITransformPlugin | (() => import("../types").ITransformPlugin);
export default _default;
declare const plugin: import("../types").ITransformPlugin;
export default plugin;
export * from './base';
export declare const plugins: (import("..").ITransformPlugin | (() => import("..").ITransformPlugin))[];
export declare const plugins: import("..").ITransformPlugin[];

@@ -1,2 +0,2 @@

declare const _default: import("../types").ITransformPlugin | (() => import("../types").ITransformPlugin);
export default _default;
declare const plugin: import("../types").ITransformPlugin;
export default plugin;
import { JSItem } from 'markmap-common';
export declare const name = "katex";
export declare function getConfig(): {
export declare const config: {
versions: {

@@ -5,0 +5,0 @@ katex: string;

@@ -1,2 +0,2 @@

declare const _default: import("../types").ITransformPlugin | (() => import("../types").ITransformPlugin);
export default _default;
declare const plugin: import("../types").ITransformPlugin;
export default plugin;

@@ -1,2 +0,2 @@

declare const _default: import("../types").ITransformPlugin | (() => import("../types").ITransformPlugin);
declare const _default: import("../types").ITransformPlugin;
export default _default;

@@ -1,2 +0,2 @@

declare const _default: import("../types").ITransformPlugin | (() => import("../types").ITransformPlugin);
export default _default;
declare const plugin: import("../types").ITransformPlugin;
export default plugin;
export declare const name = "prism";
export declare function getConfig(): {
export declare const config: {
versions: {

@@ -4,0 +4,0 @@ prismjs: string;

@@ -1,2 +0,2 @@

declare const _default: import("../types").ITransformPlugin | (() => import("../types").ITransformPlugin);
export default _default;
declare const plugin: import("../types").ITransformPlugin;
export default plugin;

@@ -0,1 +1,3 @@

import { CSSItem, JSItem } from 'markmap-common';
import { ITransformer } from '../types';
/**

@@ -5,1 +7,3 @@ * Find NPM paths and resolve them to full URLs with the same package version as in this library.

export declare function addDefaultVersions(paths: string[], name: string, version: string): string[];
export declare function patchJSItem(transformer: ITransformer, item: JSItem): JSItem;
export declare function patchCSSItem(transformer: ITransformer, item: CSSItem): CSSItem;
import { Remarkable } from 'remarkable';
import { IPureNode } from 'markmap-common';
import { ITransformResult, ITransformPlugin, IAssets, ITransformHooks, IFeatures } from './types';
import { UrlBuilder, JSItem, IMarkmapOptions, IMarkmapJSONOptions, IPureNode } from 'markmap-common';
import { ITransformResult, ITransformPlugin, IAssets, ITransformHooks, IFeatures, ITransformer } from './types';
import { plugins as builtInPlugins } from './plugins';
export { builtInPlugins };
export declare class Transformer {
export declare class Transformer implements ITransformer {
hooks: ITransformHooks;
md: Remarkable;
assetsMap: Record<string, IAssets>;
urlBuilder: UrlBuilder;
plugins: ITransformPlugin[];

@@ -22,2 +23,7 @@ constructor(plugins?: Array<ITransformPlugin | (() => ITransformPlugin)>);

getUsedAssets(features: IFeatures): IAssets;
fillTemplate(root: IPureNode | null, assets: IAssets, extra?: {
baseJs?: JSItem[];
jsonOptions?: IMarkmapJSONOptions;
getOptions?: (jsonOptions: IMarkmapJSONOptions) => Partial<IMarkmapOptions>;
}): string;
}
import type { Remarkable } from 'remarkable';
import { CSSItem, JSItem, IPureNode, IWrapContext, Hook, IMarkmapJSONOptions } from 'markmap-common';
import { UrlBuilder, CSSItem, JSItem, IPureNode, IWrapContext, Hook, IMarkmapJSONOptions } from 'markmap-common';
type Htmltag = Remarkable.Rule<Remarkable.HtmlTagToken, string>;
export interface ITransformHooks {
transformer: ITransformer;
/**

@@ -44,2 +45,5 @@ * Tapped once when the parser is created.

}
export interface ITransformer {
urlBuilder: UrlBuilder;
}
export interface ITransformContext {

@@ -46,0 +50,0 @@ features: IFeatures;

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