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.2 to 0.14.5-alpha.13

dist/index.mjs

164

dist/index.js

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

/*! markmap-common v0.14.2 | MIT License */
/*! markmap-common v0.14.5-alpha.13+50ca560 | MIT License */
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
class Hook {

@@ -10,3 +8,2 @@ constructor() {

}
tap(fn) {

@@ -16,3 +13,2 @@ this.listeners.push(fn);

}
revoke(fn) {

@@ -22,7 +18,5 @@ const i = this.listeners.indexOf(fn);

}
revokeAll() {
this.listeners.splice(0);
}
call(...args) {

@@ -33,10 +27,8 @@ for (const fn of this.listeners) {

}
}
function _extends() {
_extends = Object.assign || function (target) {
_extends = Object.assign ? Object.assign.bind() : function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {

@@ -48,6 +40,4 @@ if (Object.prototype.hasOwnProperty.call(source, key)) {

}
return target;
};
return _extends.apply(this, arguments);

@@ -61,3 +51,2 @@ }

var key, i;
for (i = 0; i < sourceKeys.length; i++) {

@@ -68,3 +57,2 @@ key = sourceKeys[i];

}
return target;

@@ -111,10 +99,8 @@ }

const _item$data = item.data,
{
textContent
} = _item$data,
rest = _objectWithoutPropertiesLoose(_item$data, _excluded);
{
textContent
} = _item$data,
rest = _objectWithoutPropertiesLoose(_item$data, _excluded);
return wrapHtml('script', textContent || '', rest);
}
if (item.type === 'iife') {

@@ -127,3 +113,2 @@ const {

}
return '';

@@ -140,4 +125,2 @@ });

/* else if (item.type === 'style') */
return wrapHtml('style', item.data);

@@ -153,3 +136,4 @@ });

}
function noop() {// noop
function noop() {
// noop
}

@@ -159,3 +143,2 @@ function walkTree(tree, callback, key = 'children') {

var _item$key;
(_item$key = item[key]) == null ? void 0 : _item$key.forEach(child => {

@@ -165,26 +148,4 @@ walk(child, item);

}, parent);
walk(tree);
}
function arrayFrom(arrayLike) {
if (Array.from) return Array.from(arrayLike);
const array = [];
for (let i = 0; i < arrayLike.length; i += 1) {
array.push(arrayLike[i]);
}
return array;
}
function flatMap(arrayLike, callback) {
if (arrayLike.flatMap) return arrayLike.flatMap(callback);
const array = [];
for (let i = 0; i < arrayLike.length; i += 1) {
const result = callback(arrayLike[i], i, arrayLike);
if (Array.isArray(result)) array.push(...result);else array.push(result);
}
return array;
}
function addClass(className, ...rest) {

@@ -200,9 +161,7 @@ const classList = (className || '').split(' ').filter(Boolean);

const tagName = filter;
filter = el => el.tagName === tagName;
}
const filterFn = filter;
return function selector() {
let nodes = arrayFrom(this.childNodes);
let nodes = Array.from(this.childNodes);
if (filterFn) nodes = nodes.filter(node => filterFn(node));

@@ -212,26 +171,4 @@ return nodes;

}
function wrapFunction(fn, {
before,
after
}) {
return function wrapped(...args) {
const ctx = {
args,
thisObj: this
};
try {
if (before) before(ctx);
} catch (_unused) {// ignore
}
ctx.result = fn.apply(ctx.thisObj, ctx.args);
try {
if (after) after(ctx);
} catch (_unused2) {// ignore
}
return ctx.result;
};
function wrapFunction(fn, wrapper) {
return (...args) => wrapper(fn, ...args);
}

@@ -251,3 +188,2 @@ function defer() {

let data = cache[key];
if (!data) {

@@ -259,3 +195,2 @@ data = {

}
return data.value;

@@ -265,5 +200,27 @@ };

const testPath = "@gera2ld/jsx-dom/dist/index.js";
const providers = {
jsdelivr: path => `https://cdn.jsdelivr.net/npm/${path}`,
unpkg: path => `https://unpkg.com/${path}`
};
function cdnUrl(provider, path) {
const factory = providers[provider];
if (!factory) {
throw new Error(`Provider ${provider} not found`);
}
return factory(path);
}
function getFastestProvider(path = testPath) {
return Promise.any(Object.entries(providers).map(async ([name, factory]) => {
const res = await fetch(factory(path));
if (!res.ok) {
throw res;
}
await res.text();
return name;
}));
}
function createElement(tagName, props, attrs) {
const el = document.createElement(tagName);
if (props) {

@@ -274,3 +231,2 @@ Object.entries(props).forEach(([key, value]) => {

}
if (attrs) {

@@ -281,6 +237,4 @@ Object.entries(attrs).forEach(([key, value]) => {

}
return el;
}
const memoizedPreloadJS = memoize(url => {

@@ -293,3 +247,2 @@ document.head.append(createElement('link', {

});
async function loadJSItem(item, context) {

@@ -300,8 +253,7 @@ if (!item.loaded) {

var _item$data;
document.head.append(createElement('script', _extends({}, item.data, {
onload: resolve,
onerror: reject
}))); // Run inline script synchronously
})));
// Run inline script synchronously
if (!((_item$data = item.data) != null && _item$data.src)) resolve(undefined);

@@ -312,3 +264,2 @@ }).then(() => {

}
if (item.type === 'iife') {

@@ -323,10 +274,7 @@ const {

}
await item.loaded;
}
function loadCSSItem(item) {
if (item.loaded) return;
item.loaded = true;
if (item.type === 'style') {

@@ -342,7 +290,5 @@ document.head.append(createElement('style', {

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

@@ -354,3 +300,2 @@ });

}, context);
for (const item of items) {

@@ -365,7 +310,38 @@ await loadJSItem(item, context);

}
let provider = 'jsdelivr';
async function findFastestProvider() {
provider = await getFastestProvider();
}
function setProvider(name, factory) {
if (factory) {
providers[name] = factory;
}
provider = name;
}
function getFullUrl(path) {
if (path.includes('://')) return path;
return cdnUrl(provider, path);
}
function buildJSItem(path) {
return {
type: 'script',
data: {
src: getFullUrl(path)
}
};
}
function buildCSSItem(path) {
return {
type: 'stylesheet',
data: {
href: getFullUrl(path)
}
};
}
exports.Hook = Hook;
exports.addClass = addClass;
exports.arrayFrom = arrayFrom;
exports.buildCSSItem = buildCSSItem;
exports.buildCode = buildCode;
exports.buildJSItem = buildJSItem;
exports.childSelector = childSelector;

@@ -375,3 +351,4 @@ exports.defer = defer;

exports.escapeScript = escapeScript;
exports.flatMap = flatMap;
exports.findFastestProvider = findFastestProvider;
exports.getFullUrl = getFullUrl;
exports.getId = getId;

@@ -386,4 +363,5 @@ exports.htmlClose = htmlClose;

exports.persistJS = persistJS;
exports.setProvider = setProvider;
exports.walkTree = walkTree;
exports.wrapFunction = wrapFunction;
exports.wrapHtml = wrapHtml;
{
"name": "markmap-common",
"version": "0.14.2",
"version": "0.14.5-alpha.13+50ca560",
"description": "",

@@ -14,3 +14,3 @@ "author": "",

"main": "dist/index.js",
"module": "dist/index.esm.js",
"module": "dist/index.mjs",
"files": [

@@ -24,7 +24,16 @@ "dist",

},
"homepage": "https://github.com/markmap/markmap/packages/markmap-common#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/markmap/markmap.git"
},
"bugs": {
"url": "https://github.com/markmap/markmap/issues"
},
"typings": "types/index.d.ts",
"dependencies": {
"@babel/runtime": "^7.12.1"
"@babel/runtime": "^7.22.6",
"npm2url": "^0.1.1"
},
"gitHead": "91e58839b99837eaaa9e151cda18814d11ceebe0"
"gitHead": "50ca5603019498f93dba6485c96d0a5630b221e5"
}

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

export declare type HookCallback<T extends unknown[]> = (...args: T) => void;
export type HookCallback<T extends unknown[]> = (...args: T) => void;
export declare class Hook<T extends unknown[]> {

@@ -3,0 +3,0 @@ protected listeners: Array<HookCallback<T>>;

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

import { JSItem, CSSItem } from './types';
import { JSItem, JSScriptItem, CSSItem, CSSStylesheetItem } from './types';
export declare function loadJS(items: JSItem[], context?: object): Promise<void>;
export declare function loadCSS(items: CSSItem[]): void;
export declare function findFastestProvider(): Promise<void>;
export declare function setProvider(name: string, factory?: (path: string) => string): void;
export declare function getFullUrl(path: string): string;
export declare function buildJSItem(path: string): JSScriptItem;
export declare function buildCSSItem(path: string): CSSStylesheetItem;

@@ -58,3 +58,3 @@ export interface IHierarchy<T> {

}
export declare type JSScriptItem = {
export type JSScriptItem = {
type: 'script';

@@ -69,3 +69,3 @@ loaded?: Promise<void> | boolean;

};
export declare type JSIIFEItem = {
export type JSIIFEItem = {
type: 'iife';

@@ -78,4 +78,4 @@ loaded?: Promise<void> | boolean;

};
export declare type JSItem = JSScriptItem | JSIIFEItem;
export declare type CSSStyleItem = {
export type JSItem = JSScriptItem | JSIIFEItem;
export type CSSStyleItem = {
type: 'style';

@@ -85,3 +85,3 @@ loaded?: boolean;

};
export declare type CSSStylesheetItem = {
export type CSSStylesheetItem = {
type: 'stylesheet';

@@ -93,5 +93,4 @@ loaded?: boolean;

};
export declare type CSSItem = CSSStyleItem | CSSStylesheetItem;
export type CSSItem = CSSStyleItem | CSSStylesheetItem;
export interface IWrapContext<T extends unknown[], U> {
thisObj: unknown;
args: T;

@@ -132,3 +131,4 @@ result?: U;

pan: boolean;
toggleRecursively: boolean;
style?: (id: string) => string;
}

@@ -1,14 +0,9 @@

import { IWrapContext, IDeferred } from './types';
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 arrayFrom<T>(arrayLike: ArrayLike<T>): T[];
export declare function flatMap<T, U>(arrayLike: ArrayLike<T>, callback: (item?: T, index?: number, thisObj?: ArrayLike<T>) => U | U[]): U[];
export declare function addClass(className: string, ...rest: string[]): string;
export declare function childSelector<T extends Element>(filter?: string | ((el: T) => boolean)): () => T[];
export declare function wrapFunction<T extends unknown[], U>(fn: (...args: T) => U, { before, after, }: {
before?: (ctx: IWrapContext<T, U>) => void;
after?: (ctx: IWrapContext<T, U>) => void;
}): (...args: T) => U;
export declare function wrapFunction<T extends unknown[], U>(fn: (...args: T) => U, wrapper: (fn: (...args: T) => U, ...args: T) => U): (...args: T) => U;
export declare function defer<T>(): IDeferred<T>;
export declare function memoize<T extends unknown[], U>(fn: (...args: T) => U): (...args: T) => U;
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