markmap-lib
Advanced tools
Comparing version 0.15.5 to 0.15.6-alpha.4
@@ -1,48 +0,66 @@ | ||
/*! markmap-lib v0.15.5 | MIT License */ | ||
'use strict'; | ||
var _extends = require('@babel/runtime/helpers/extends'); | ||
var remarkable = require('remarkable'); | ||
var markmapCommon = require('markmap-common'); | ||
var remarkableKatex = require('remarkable-katex'); | ||
var yaml = require('js-yaml'); | ||
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.15.5"}/dist/browser/index.js`]; | ||
const name$3 = 'katex'; | ||
const preloadScripts$1 = [`katex@${"0.16.8"}/dist/katex.min.js`].map(path => markmapCommon.buildJSItem(path)); | ||
const webfontloader = markmapCommon.buildJSItem(`webfontloader@${"1.6.28"}/webfontloader.js`); | ||
"use strict"; | ||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); | ||
const remarkable = require("remarkable"); | ||
const markmapCommon = require("markmap-common"); | ||
const remarkableKatex = require("remarkable-katex"); | ||
const yaml = require("js-yaml"); | ||
const 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.15.6-alpha.4"}/dist/browser/index.js` | ||
]; | ||
const name$3 = "katex"; | ||
const preloadScripts$1 = [ | ||
`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 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" | ||
katex: "0.16.8", | ||
webfontloader: "1.6.28" | ||
}, | ||
preloadScripts: preloadScripts$1, | ||
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]; | ||
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], | ||
}, | ||
webfontloader | ||
], | ||
styles: styles$1 | ||
}; | ||
function createTransformHooks(transformer) { | ||
@@ -58,10 +76,5 @@ return { | ||
} | ||
/** | ||
* This function is only used to help type checking. | ||
*/ | ||
function definePlugin(plugin) { | ||
return plugin; | ||
function definePlugin(plugin2) { | ||
return plugin2; | ||
} | ||
const plugin$1 = definePlugin({ | ||
@@ -71,10 +84,13 @@ name: name$3, | ||
transform(transformHooks) { | ||
var _plugin$config, _plugin$config2; | ||
var _a, _b; | ||
let enableFeature = markmapCommon.noop; | ||
transformHooks.parser.tap(md => { | ||
transformHooks.parser.tap((md) => { | ||
md.use(remarkableKatex); | ||
md.renderer.rules.katex = markmapCommon.wrapFunction(md.renderer.rules.katex, (render, ...args) => { | ||
enableFeature(); | ||
return render(...args); | ||
}); | ||
md.renderer.rules.katex = markmapCommon.wrapFunction( | ||
md.renderer.rules.katex, | ||
(render, ...args) => { | ||
enableFeature(); | ||
return render(...args); | ||
} | ||
); | ||
}); | ||
@@ -87,33 +103,33 @@ transformHooks.beforeParse.tap((_, context) => { | ||
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 | ||
styles: (_a = plugin$1.config) == null ? void 0 : _a.styles, | ||
scripts: (_b = plugin$1.config) == null ? void 0 : _b.scripts | ||
}; | ||
} | ||
}); | ||
const name$2 = 'frontmatter'; | ||
var frontmatter = definePlugin({ | ||
const name$2 = "frontmatter"; | ||
const frontmatter = definePlugin({ | ||
name: name$2, | ||
transform(transformHooks) { | ||
transformHooks.beforeParse.tap((md, context) => { | ||
const { | ||
content | ||
} = context; | ||
if (!content.startsWith('---\n')) return; | ||
const endOffset = content.indexOf('\n---\n'); | ||
if (endOffset < 0) return; | ||
const { content } = context; | ||
if (!content.startsWith("---\n")) | ||
return; | ||
const endOffset = content.indexOf("\n---\n"); | ||
if (endOffset < 0) | ||
return; | ||
const raw = content.slice(4, endOffset); | ||
let frontmatter; | ||
let frontmatter2; | ||
try { | ||
var _frontmatter; | ||
frontmatter = yaml.load(raw); | ||
if ((_frontmatter = frontmatter) != null && _frontmatter.markmap) { | ||
frontmatter.markmap = normalizeMarkmapJsonOptions(frontmatter.markmap); | ||
frontmatter2 = yaml.load(raw); | ||
if (frontmatter2 == null ? void 0 : frontmatter2.markmap) { | ||
frontmatter2.markmap = normalizeMarkmapJsonOptions( | ||
frontmatter2.markmap | ||
); | ||
} | ||
} catch (_unused) { | ||
} catch { | ||
return; | ||
} | ||
context.frontmatter = frontmatter; | ||
context.frontmatter = frontmatter2; | ||
context.content = content.slice(endOffset + 5); | ||
context.contentLineOffset = content.slice(0, endOffset).split('\n').length + 1; | ||
context.contentLineOffset = content.slice(0, endOffset).split("\n").length + 1; | ||
}); | ||
@@ -124,8 +140,11 @@ return {}; | ||
function normalizeMarkmapJsonOptions(options) { | ||
if (!options) return; | ||
['color', 'extraJs', 'extraCss'].forEach(key => { | ||
if (options[key] != null) options[key] = normalizeStringArray(options[key]); | ||
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]); | ||
["duration", "maxWidth", "initialExpandLevel"].forEach((key) => { | ||
if (options[key] != null) | ||
options[key] = normalizeNumber(options[key]); | ||
}); | ||
@@ -135,28 +154,30 @@ return options; | ||
function normalizeStringArray(value) { | ||
var _result; | ||
let result; | ||
if (typeof value === 'string') result = [value];else if (Array.isArray(value)) result = value.filter(item => item && typeof item === 'string'); | ||
return (_result = result) != null && _result.length ? result : undefined; | ||
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; | ||
if (isNaN(+value)) | ||
return; | ||
return +value; | ||
} | ||
const name$1 = 'npmUrl'; | ||
var npmUrl = definePlugin({ | ||
const name$1 = "npmUrl"; | ||
const npmUrl = definePlugin({ | ||
name: name$1, | ||
transform(transformHooks) { | ||
transformHooks.afterParse.tap((_, context) => { | ||
const { | ||
frontmatter | ||
} = context; | ||
const markmap = frontmatter == null ? void 0 : frontmatter.markmap; | ||
const { frontmatter: frontmatter2 } = context; | ||
const markmap = frontmatter2 == null ? void 0 : frontmatter2.markmap; | ||
if (markmap) { | ||
['extraJs', 'extraCss'].forEach(key => { | ||
["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)); | ||
markmap[key] = value.map((path) => { | ||
if (path.startsWith("npm:")) { | ||
return transformHooks.transformer.urlBuilder.getFullUrl( | ||
path.slice(4) | ||
); | ||
} | ||
@@ -172,11 +193,13 @@ return path; | ||
}); | ||
const name = 'hljs'; | ||
const preloadScripts = [`@highlightjs/cdn-assets@${"11.8.0"}/highlight.min.js`].map(path => markmapCommon.buildJSItem(path)); | ||
const styles = [`@highlightjs/cdn-assets@${"11.8.0"}/styles/default.min.css` | ||
// `highlight.js@${"11.8.0"}/styles/default.css`, | ||
].map(path => markmapCommon.buildCSSItem(path)); | ||
const name = "hljs"; | ||
const preloadScripts = [ | ||
`@highlightjs/cdn-assets@${"11.8.0"}/highlight.min.js` | ||
].map((path) => markmapCommon.buildJSItem(path)); | ||
const styles = [ | ||
`@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 = { | ||
versions: { | ||
hljs: "11.8.0" | ||
hljs: "11.8.0" | ||
}, | ||
@@ -186,3 +209,2 @@ preloadScripts, | ||
}; | ||
const plugin = definePlugin({ | ||
@@ -192,9 +214,9 @@ name, | ||
transform(transformHooks) { | ||
var _plugin$config; | ||
var _a; | ||
let enableFeature = markmapCommon.noop; | ||
transformHooks.parser.tap(md => { | ||
transformHooks.parser.tap((md) => { | ||
md.set({ | ||
highlight: (str, language) => { | ||
enableFeature(); | ||
return hljs.highlightAuto(str, language ? [language] : undefined).value; | ||
return hljs.highlightAuto(str, language ? [language] : void 0).value; | ||
} | ||
@@ -209,42 +231,44 @@ }); | ||
return { | ||
styles: (_plugin$config = plugin.config) == null ? void 0 : _plugin$config.styles | ||
styles: (_a = plugin.config) == null ? void 0 : _a.styles | ||
}; | ||
} | ||
}); | ||
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) | ||
}) | ||
}); | ||
function patchJSItem(urlBuilder, item) { | ||
if (item.type === "script" && item.data.src) { | ||
return { | ||
...item, | ||
data: { | ||
...item.data, | ||
src: 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) | ||
}) | ||
}); | ||
function patchCSSItem(urlBuilder, item) { | ||
if (item.type === "stylesheet" && item.data.href) { | ||
return { | ||
...item, | ||
data: { | ||
...item.data, | ||
href: urlBuilder.getFullUrl(item.data.href) | ||
} | ||
}; | ||
} | ||
return item; | ||
} | ||
function cleanNode(node) { | ||
if (node.type === 'heading') { | ||
// drop all paragraphs | ||
node.children = node.children.filter(item => item.type !== 'paragraph'); | ||
} else if (node.type === 'list_item') { | ||
var _node$payload; | ||
// keep first paragraph as content of list_item, drop others | ||
node.children = node.children.filter(item => { | ||
if (['paragraph', 'fence'].includes(item.type)) { | ||
var _a, _b; | ||
if (node.type === "heading") { | ||
node.children = node.children.filter((item) => item.type !== "paragraph"); | ||
} else if (node.type === "list_item") { | ||
node.children = node.children.filter((item) => { | ||
if (["paragraph", "fence"].includes(item.type)) { | ||
if (!node.content) { | ||
node.content = item.content; | ||
node.payload = _extends({}, node.payload, item.payload); | ||
node.payload = { | ||
...node.payload, | ||
...item.payload | ||
}; | ||
} | ||
@@ -255,13 +279,13 @@ return false; | ||
}); | ||
if (((_node$payload = node.payload) == null ? void 0 : _node$payload.index) != null) { | ||
if (((_a = node.payload) == null ? void 0 : _a.index) != null) { | ||
node.content = `${node.payload.index}. ${node.content}`; | ||
} | ||
} else if (node.type === 'ordered_list') { | ||
var _node$payload$startIn, _node$payload2; | ||
let index = (_node$payload$startIn = (_node$payload2 = node.payload) == null ? void 0 : _node$payload2.startIndex) != null ? _node$payload$startIn : 1; | ||
node.children.forEach(item => { | ||
if (item.type === 'list_item') { | ||
item.payload = _extends({}, item.payload, { | ||
} else if (node.type === "ordered_list") { | ||
let index = ((_b = node.payload) == null ? void 0 : _b.startIndex) ?? 1; | ||
node.children.forEach((item) => { | ||
if (item.type === "list_item") { | ||
item.payload = { | ||
...item.payload, | ||
index | ||
}); | ||
}; | ||
index += 1; | ||
@@ -272,3 +296,3 @@ } | ||
if (node.children.length > 0) { | ||
node.children.forEach(child => cleanNode(child)); | ||
node.children.forEach((child) => cleanNode(child)); | ||
if (node.children.length === 1 && !node.children[0].content) { | ||
@@ -281,3 +305,3 @@ node.children = node.children[0].children; | ||
node.depth = depth; | ||
node.children.forEach(child => { | ||
node.children.forEach((child) => { | ||
resetDepth(child, depth + 1); | ||
@@ -291,12 +315,11 @@ }); | ||
this.hooks = createTransformHooks(this); | ||
this.plugins = plugins$1.map(plugin => typeof plugin === 'function' ? plugin() : plugin); | ||
this.plugins = plugins$1.map( | ||
(plugin2) => typeof plugin2 === "function" ? plugin2() : plugin2 | ||
); | ||
const assetsMap = {}; | ||
for (const { | ||
name, | ||
transform | ||
} of this.plugins) { | ||
assetsMap[name] = transform(this.hooks); | ||
for (const { name: name2, transform } of this.plugins) { | ||
assetsMap[name2] = transform(this.hooks); | ||
} | ||
this.assetsMap = assetsMap; | ||
const md = new remarkable.Remarkable('full', { | ||
const md = new remarkable.Remarkable("full", { | ||
html: true, | ||
@@ -306,10 +329,10 @@ breaks: true, | ||
}); | ||
md.renderer.rules.htmltag = markmapCommon.wrapFunction(md.renderer.rules.htmltag, (render, ...args) => { | ||
const result = render(...args); | ||
this.hooks.htmltag.call({ | ||
args, | ||
result | ||
}); | ||
return result; | ||
}); | ||
md.renderer.rules.htmltag = markmapCommon.wrapFunction( | ||
md.renderer.rules.htmltag, | ||
(render, ...args) => { | ||
const result = render(...args); | ||
this.hooks.htmltag.call({ args, result }); | ||
return result; | ||
} | ||
); | ||
this.md = md; | ||
@@ -319,9 +342,7 @@ this.hooks.parser.call(md); | ||
buildTree(tokens) { | ||
const { | ||
md | ||
} = this; | ||
const { md } = this; | ||
const root = { | ||
type: 'root', | ||
type: "root", | ||
depth: 0, | ||
content: '', | ||
content: "", | ||
children: [], | ||
@@ -338,8 +359,7 @@ payload: {} | ||
let current = stack[stack.length - 1]; | ||
if (token.type.endsWith('_open')) { | ||
if (token.type.endsWith("_open")) { | ||
const type = token.type.slice(0, -5); | ||
if (type === 'heading') { | ||
if (type === "heading") { | ||
depth = token.hLevel; | ||
while (((_current = current) == null ? void 0 : _current.depth) >= depth) { | ||
var _current; | ||
while ((current == null ? void 0 : current.depth) >= depth) { | ||
stack.pop(); | ||
@@ -349,5 +369,4 @@ current = stack[stack.length - 1]; | ||
} else { | ||
var _current2; | ||
depth = Math.max(depth, ((_current2 = current) == null ? void 0 : _current2.depth) || 0) + 1; | ||
if (type === 'ordered_list') { | ||
depth = Math.max(depth, (current == null ? void 0 : current.depth) || 0) + 1; | ||
if (type === "ordered_list") { | ||
payload.startIndex = token.order; | ||
@@ -360,3 +379,3 @@ } | ||
payload, | ||
content: '', | ||
content: "", | ||
children: [] | ||
@@ -369,3 +388,3 @@ }; | ||
} else if (token.type === `${current.type}_close`) { | ||
if (current.type === 'heading') { | ||
if (current.type === "heading") { | ||
depth = current.depth; | ||
@@ -376,12 +395,13 @@ } else { | ||
} | ||
} else if (token.type === 'inline') { | ||
const revoke = this.hooks.htmltag.tap(ctx => { | ||
var _ctx$result; | ||
const comment = (_ctx$result = ctx.result) == null ? void 0 : _ctx$result.match(/^<!--([\s\S]*?)-->$/); | ||
const data = comment == null ? void 0 : comment[1].trim().split(' '); | ||
if ((data == null ? void 0 : data[0]) === 'fold') { | ||
current.payload = _extends({}, current.payload, { | ||
fold: ['all', 'recursively'].includes(data[1]) ? 2 : 1 | ||
}); | ||
ctx.result = ''; | ||
} else if (token.type === "inline") { | ||
const revoke = this.hooks.htmltag.tap((ctx) => { | ||
var _a; | ||
const comment = (_a = ctx.result) == null ? void 0 : _a.match(/^<!--([\s\S]*?)-->$/); | ||
const data = comment == null ? void 0 : comment[1].trim().split(" "); | ||
if ((data == null ? void 0 : data[0]) === "fold") { | ||
current.payload = { | ||
...current.payload, | ||
fold: ["all", "recursively"].includes(data[1]) ? 2 : 1 | ||
}; | ||
ctx.result = ""; | ||
} | ||
@@ -391,4 +411,4 @@ }); | ||
revoke(); | ||
current.content = `${current.content || ''}${text}`; | ||
} else if (token.type === 'fence') { | ||
current.content = `${current.content || ""}${text}`; | ||
} else if (token.type === "fence") { | ||
const result = md.renderer.render([token], md.options, {}); | ||
@@ -402,3 +422,4 @@ current.children.push({ | ||
}); | ||
} else ; | ||
} else | ||
; | ||
} | ||
@@ -408,3 +429,3 @@ return root; | ||
transform(content) { | ||
var _root$children; | ||
var _a; | ||
const context = { | ||
@@ -420,9 +441,7 @@ content, | ||
cleanNode(root); | ||
if (((_root$children = root.children) == null ? void 0 : _root$children.length) === 1) root = root.children[0]; | ||
if (((_a = root.children) == null ? void 0 : _a.length) === 1) | ||
root = root.children[0]; | ||
resetDepth(root); | ||
return _extends({}, context, { | ||
root | ||
}); | ||
return { ...context, root }; | ||
} | ||
/** | ||
@@ -432,18 +451,18 @@ * Get all assets from enabled plugins or filter them by plugin names as keys. | ||
getAssets(keys) { | ||
var _keys; | ||
const styles = []; | ||
const styles2 = []; | ||
const scripts = []; | ||
(_keys = keys) != null ? _keys : keys = this.plugins.map(plugin => plugin.name); | ||
for (const assets of keys.map(key => this.assetsMap[key])) { | ||
keys ?? (keys = this.plugins.map((plugin2) => plugin2.name)); | ||
for (const assets of keys.map((key) => this.assetsMap[key])) { | ||
if (assets) { | ||
if (assets.styles) styles.push(...assets.styles); | ||
if (assets.scripts) scripts.push(...assets.scripts); | ||
if (assets.styles) | ||
styles2.push(...assets.styles); | ||
if (assets.scripts) | ||
scripts.push(...assets.scripts); | ||
} | ||
} | ||
return { | ||
styles: styles.map(item => patchCSSItem(this, item)), | ||
scripts: scripts.map(item => patchJSItem(this, item)) | ||
styles: styles2.map((item) => patchCSSItem(this.urlBuilder, item)), | ||
scripts: scripts.map((item) => patchJSItem(this.urlBuilder, item)) | ||
}; | ||
} | ||
/** | ||
@@ -453,14 +472,12 @@ * Get used assets by features object returned by `transform`. | ||
getUsedAssets(features) { | ||
const keys = this.plugins.map(plugin => plugin.name).filter(name => features[name]); | ||
const keys = this.plugins.map((plugin2) => plugin2.name).filter((name2) => features[name2]); | ||
return this.getAssets(keys); | ||
} | ||
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) : [])]; | ||
extra = { | ||
...extra | ||
}; | ||
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 context = { | ||
@@ -472,29 +489,35 @@ getMarkmap: () => window.markmap, | ||
}; | ||
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('')); | ||
const jsList = [ | ||
...markmapCommon.persistJS( | ||
[ | ||
...extra.baseJs, | ||
...scripts || [], | ||
{ | ||
type: "iife", | ||
data: { | ||
fn: (getMarkmap, getOptions, root2, jsonOptions) => { | ||
const markmap = getMarkmap(); | ||
window.mm = markmap.Markmap.create( | ||
"svg#mindmap", | ||
(getOptions || markmap.deriveOptions)(jsonOptions), | ||
root2 | ||
); | ||
}, | ||
getParams: ({ getMarkmap, getOptions, root: root2, jsonOptions }) => { | ||
return [getMarkmap, getOptions, root2, jsonOptions]; | ||
} | ||
} | ||
} | ||
], | ||
context | ||
) | ||
]; | ||
const html = template.replace("<!--CSS-->", () => cssList.join("")).replace("<!--JS-->", () => jsList.join("")); | ||
return html; | ||
} | ||
} | ||
const transformerVersions = { | ||
'markmap-lib': '0.15.5', | ||
"markmap-lib": "process.env.VERSION", | ||
d3: "7.8.5" | ||
}; | ||
exports.Transformer = Transformer; | ||
@@ -501,0 +524,0 @@ exports.baseJsPaths = baseJsPaths; |
{ | ||
"name": "markmap-lib", | ||
"version": "0.15.5", | ||
"version": "0.15.6-alpha.4+4734119", | ||
"description": "Visualize your Markdown as mindmaps with Markmap", | ||
@@ -8,6 +8,5 @@ "author": "Gerald <gera2ld@live.com>", | ||
"scripts": { | ||
"dev": "rollup -wc rollup.conf.js", | ||
"clean": "del-cli dist types", | ||
"clean": "del-cli dist", | ||
"build:types": "tsc", | ||
"build:js": "rollup -c", | ||
"build:js": "vite build && TARGET=browserEs vite build --emptyOutDir=false && TARGET=browserJs vite build --emptyOutDir=false", | ||
"test": "jest test" | ||
@@ -21,7 +20,7 @@ }, | ||
"module": "dist/index.mjs", | ||
"unpkg": "dist/browser/index.js", | ||
"jsdelivr": "dist/browser/index.js", | ||
"unpkg": "dist/browser/index.iife.js", | ||
"jsdelivr": "dist/browser/index.iife.js", | ||
"exports": { | ||
".": { | ||
"types": "./types/index.d.ts", | ||
"types": "./dist/index.d.ts", | ||
"browser": "./dist/browser/index.mjs", | ||
@@ -33,6 +32,5 @@ "require": "./dist/index.js", | ||
}, | ||
"types": "types/index.d.ts", | ||
"types": "dist/index.d.ts", | ||
"files": [ | ||
"dist", | ||
"types" | ||
"dist" | ||
], | ||
@@ -56,3 +54,3 @@ "keywords": [ | ||
"markmap-common": "0.15.5", | ||
"markmap-view": "0.15.5", | ||
"markmap-view": "0.15.6-alpha.4+4734119", | ||
"webfontloader": "^1.6.28" | ||
@@ -82,3 +80,3 @@ }, | ||
}, | ||
"gitHead": "f7bda12b219cba3833dec1dae1daad14c3b53db6" | ||
"gitHead": "473411985496abcc20a546978438614c48ec56cf" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
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
26
289846
9346
3