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

markmap-common

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markmap-common - npm Package Compare versions

Comparing version 0.14.5-alpha.15 to 0.14.5-alpha.16

207

dist/index.js

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

/*! markmap-common v0.14.5-alpha.15+1fe26c8 | MIT License */
/*! markmap-common v0.14.5-alpha.16+33e8294 | MIT License */
'use strict';

@@ -55,8 +55,9 @@

const _excluded = ["textContent"];
const escapeChars = {
'&': '&',
'<': '&lt;',
'"': '&quot;'
};
function escapeHtml(html) {
return html.replace(/[&<"]/g, m => ({
'&': '&amp;',
'<': '&lt;',
'"': '&quot;'
})[m]);
return html.replace(/[&<"]/g, m => escapeChars[m]);
}

@@ -130,6 +131,6 @@ function escapeScript(content) {

}
function walkTree(tree, callback, key = 'children') {
function walkTree(tree, callback) {
const walk = (item, parent) => callback(item, () => {
var _item$key;
(_item$key = item[key]) == null ? void 0 : _item$key.forEach(child => {
var _item$children;
(_item$children = item.children) == null ? void 0 : _item$children.forEach(child => {
walk(child, item);

@@ -185,2 +186,157 @@ });

/*! @gera2ld/jsx-dom v2.2.2 | ISC License */
const VTYPE_ELEMENT = 1;
const VTYPE_FUNCTION = 2;
const SVG_NS = 'http://www.w3.org/2000/svg';
const XLINK_NS = 'http://www.w3.org/1999/xlink';
const NS_ATTRS = {
show: XLINK_NS,
actuate: XLINK_NS,
href: XLINK_NS
};
const isLeaf = c => typeof c === 'string' || typeof c === 'number';
const isElement = c => (c == null ? void 0 : c.vtype) === VTYPE_ELEMENT;
const isRenderFunction = c => (c == null ? void 0 : c.vtype) === VTYPE_FUNCTION;
function h(type, props, ...children) {
props = Object.assign({}, props, {
children: children.length === 1 ? children[0] : children
});
return jsx(type, props);
}
function jsx(type, props) {
let vtype;
if (typeof type === 'string') vtype = VTYPE_ELEMENT;else if (typeof type === 'function') vtype = VTYPE_FUNCTION;else throw new Error('Invalid VNode type');
return {
vtype,
type,
props
};
}
function Fragment(props) {
return props.children;
}
const DEFAULT_ENV = {
isSvg: false
};
function insertDom(parent, nodes) {
if (!Array.isArray(nodes)) nodes = [nodes];
nodes = nodes.filter(Boolean);
if (nodes.length) parent.append(...nodes);
}
function mountAttributes(domElement, props, env) {
for (const key in props) {
if (key === 'key' || key === 'children' || key === 'ref') continue;
if (key === 'dangerouslySetInnerHTML') {
domElement.innerHTML = props[key].__html;
} else if (key === 'innerHTML' || key === 'textContent' || key === 'innerText' || key === 'value' && ['textarea', 'select'].includes(domElement.tagName)) {
const value = props[key];
if (value != null) domElement[key] = value;
} else if (key.startsWith('on')) {
domElement[key.toLowerCase()] = props[key];
} else {
setDOMAttribute(domElement, key, props[key], env.isSvg);
}
}
}
const attrMap = {
className: 'class',
labelFor: 'for'
};
function setDOMAttribute(el, attr, value, isSVG) {
attr = attrMap[attr] || attr;
if (value === true) {
el.setAttribute(attr, '');
} else if (value === false) {
el.removeAttribute(attr);
} else {
const namespace = isSVG ? NS_ATTRS[attr] : undefined;
if (namespace !== undefined) {
el.setAttributeNS(namespace, attr, value);
} else {
el.setAttribute(attr, value);
}
}
}
function flatten(arr) {
return arr.reduce((prev, item) => prev.concat(item), []);
}
function mountChildren(children, env) {
return Array.isArray(children) ? flatten(children.map(child => mountChildren(child, env))) : mount(children, env);
}
function mount(vnode, env = DEFAULT_ENV) {
if (vnode == null || typeof vnode === 'boolean') {
return null;
}
if (vnode instanceof Node) {
return vnode;
}
if (isRenderFunction(vnode)) {
const {
type,
props
} = vnode;
if (type === Fragment) {
const node = document.createDocumentFragment();
if (props.children) {
const children = mountChildren(props.children, env);
insertDom(node, children);
}
return node;
}
const childVNode = type(props);
return mount(childVNode, env);
}
if (isLeaf(vnode)) {
return document.createTextNode(`${vnode}`);
}
if (isElement(vnode)) {
let node;
const {
type,
props
} = vnode;
if (!env.isSvg && type === 'svg') {
env = Object.assign({}, env, {
isSvg: true
});
}
if (!env.isSvg) {
node = document.createElement(type);
} else {
node = document.createElementNS(SVG_NS, type);
}
mountAttributes(node, props, env);
if (props.children) {
let childEnv = env;
if (env.isSvg && type === 'foreignObject') {
childEnv = Object.assign({}, childEnv, {
isSvg: false
});
}
const children = mountChildren(props.children, childEnv);
if (children != null) insertDom(node, children);
}
const {
ref
} = props;
if (typeof ref === 'function') ref(node);
return node;
}
throw new Error('mount: Invalid Vnode!');
}
/**
* Mount vdom as real DOM nodes.
*/
function mountDom(vnode) {
return mount(vnode);
}
/**
* Render and mount without returning VirtualDOM, useful when you don't need SVG support.
*/
function hm(...args) {
return mountDom(h(...args));
}
const testPath = "@gera2ld/jsx-dom/dist/index.js";

@@ -209,18 +365,4 @@ const providers = {

function createElement(tagName, props, attrs) {
const el = document.createElement(tagName);
if (props) {
Object.entries(props).forEach(([key, value]) => {
el[key] = value;
});
}
if (attrs) {
Object.entries(attrs).forEach(([key, value]) => {
el.setAttribute(key, value);
});
}
return el;
}
const memoizedPreloadJS = memoize(url => {
document.head.append(createElement('link', {
document.head.append(hm('link', {
rel: 'preload',

@@ -236,5 +378,5 @@ as: 'script',

var _item$data;
document.head.append(createElement('script', _extends({}, item.data, {
onload: resolve,
onerror: reject
document.head.append(hm('script', _extends({}, item.data, {
onLoad: resolve,
onError: reject
})));

@@ -262,7 +404,7 @@ // Run inline script synchronously

if (item.type === 'style') {
document.head.append(createElement('style', {
document.head.append(hm('style', {
textContent: item.data
}));
} else if (item.type === 'stylesheet') {
document.head.append(createElement('link', _extends({
document.head.append(hm('link', _extends({
rel: 'stylesheet'

@@ -273,7 +415,8 @@ }, item.data)));

async function loadJS(items, context) {
const needPreload = items.filter(item => {
items.forEach(item => {
var _item$data2;
return item.type === 'script' && ((_item$data2 = item.data) == null ? void 0 : _item$data2.src);
if (item.type === 'script' && (_item$data2 = item.data) != null && _item$data2.src) {
memoizedPreloadJS(item.data.src);
}
});
if (needPreload.length > 1) needPreload.forEach(item => memoizedPreloadJS(item.data.src));
context = _extends({

@@ -280,0 +423,0 @@ getMarkmap: () => window.markmap

5

package.json
{
"name": "markmap-common",
"version": "0.14.5-alpha.15+1fe26c8",
"version": "0.14.5-alpha.16+33e8294",
"description": "",

@@ -34,5 +34,6 @@ "author": "",

"@babel/runtime": "^7.22.6",
"@gera2ld/jsx-dom": "^2.2.2",
"npm2url": "^0.1.1"
},
"gitHead": "1fe26c8234296e2188e466c7b9dbf3b7e171857d"
"gitHead": "33e8294050d7438f6cdadd5bf06a665560585195"
}

@@ -6,5 +6,5 @@ import { JSItem, CSSItem } from './types';

export declare function htmlClose(tagName: string): string;
export declare function wrapHtml(tagName: string, content?: string, attrs?: Record<string, string | boolean>): string;
export declare function wrapHtml(tagName: string, content?: string | null, attrs?: Record<string, string | boolean>): string;
export declare function buildCode<T extends unknown[]>(fn: (...args: T) => void, args: T): string;
export declare function persistJS(items: JSItem[], context?: unknown): string[];
export declare function persistCSS(items: CSSItem[]): string[];

@@ -1,4 +0,9 @@

export interface IHierarchy<T> {
export interface IPureNode {
type: string;
depth: number;
/**
* HTML of the node content.
*/
content: string;
/**
* Additional data created on transformation.

@@ -28,31 +33,28 @@ */

};
children: IPureNode[];
}
export interface INode extends IPureNode {
/**
* Store temporary data that helps rendering.
*/
state?: {
/**
* An auto-increment unique ID for each node.
*/
id?: number;
/**
* A dot separated sequence of the node and its ancestors.
*/
path?: string;
/**
* The unique identifier of a node, supposed to be based on content.
*/
key?: string;
el?: HTMLElement;
x0?: number;
y0?: number;
size?: [width: number, height: number];
};
children?: T[];
state: INodeState;
children: INode[];
}
export interface INode extends IHierarchy<INode> {
depth?: number;
export interface INodeState {
/**
* HTML of the node content.
* An auto-increment unique ID for each node.
*/
content: string;
id: number;
/**
* A dot separated sequence of the node and its ancestors.
*/
path: string;
/**
* The unique identifier of a node, supposed to be based on content.
*/
key: string;
el: HTMLElement;
x0: number;
y0: number;
size: [width: number, height: number];
}

@@ -59,0 +61,0 @@ export type JSScriptItem = {

import { IDeferred } from './types';
export declare function getId(): string;
export declare function noop(): void;
export declare function walkTree<T>(tree: T, callback: (item: T, next: () => void, parent?: T) => void, key?: string): void;
export declare function walkTree<T extends {
children?: T[];
}>(tree: T, callback: (item: T, next: () => void, parent?: T) => void): void;
export declare function addClass(className: string, ...rest: string[]): string;

@@ -6,0 +8,0 @@ export declare function childSelector<T extends Element>(filter?: string | ((el: T) => boolean)): () => T[];

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