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.1.1-alpha.8 to 0.1.1

271

dist/index.esm.js

@@ -1,55 +0,37 @@

/*! markmap-common v0.1.1-alpha.8+a8c283a | MIT License */
/*! markmap-common v0.1.1 | MIT License */
import _extends from '@babel/runtime/helpers/esm/extends';
import _regeneratorRuntime from '@babel/runtime/regenerator';
import _asyncToGenerator from '@babel/runtime/helpers/esm/asyncToGenerator';
function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } it = o[Symbol.iterator](); return it.next.bind(it); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
var Hook = /*#__PURE__*/function () {
function Hook() {
class Hook {
constructor() {
this.listeners = [];
}
var _proto = Hook.prototype;
_proto.tap = function tap(fn) {
var _this = this;
tap(fn) {
this.listeners.push(fn);
return function () {
return _this.revoke(fn);
};
};
return () => this.revoke(fn);
}
_proto.revoke = function revoke(fn) {
var i = this.listeners.indexOf(fn);
revoke(fn) {
const i = this.listeners.indexOf(fn);
if (i >= 0) this.listeners.splice(i, 1);
};
}
_proto.revokeAll = function revokeAll() {
revokeAll() {
this.listeners.splice(0);
};
}
_proto.call = function call() {
for (var _iterator = _createForOfIteratorHelperLoose(this.listeners), _step; !(_step = _iterator()).done;) {
var fn = _step.value;
fn.apply(void 0, arguments);
call(...args) {
for (const fn of this.listeners) {
fn(...args);
}
};
}
return Hook;
}();
}
function escapeHtml(html) {
return html.replace(/[&<"]/g, function (m) {
return {
'&': '&amp;',
'<': '&lt;',
'"': '&quot;'
}[m];
});
return html.replace(/[&<"]/g, m => ({
'&': '&amp;',
'<': '&lt;',
'"': '&quot;'
})[m]);
}

@@ -60,14 +42,12 @@ function escapeScript(content) {

function htmlOpen(tagName, attrs) {
var attrStr = attrs ? Object.entries(attrs).map(function (_ref) {
var key = _ref[0],
value = _ref[1];
const attrStr = attrs ? Object.entries(attrs).map(([key, value]) => {
if (value == null || value === false) return;
key = " " + escapeHtml(key);
key = ` ${escapeHtml(key)}`;
if (value === true) return key;
return key + "=\"" + escapeHtml(value) + "\"";
return `${key}="${escapeHtml(value)}"`;
}).filter(Boolean).join('') : '';
return "<" + tagName + attrStr + ">";
return `<${tagName}${attrStr}>`;
}
function htmlClose(tagName) {
return "</" + tagName + ">";
return `</${tagName}>`;
}

@@ -86,16 +66,17 @@ function wrapHtml(tagName, content, attrs) {

function buildCode(fn, args) {
var params = args.map(function (arg) {
const params = args.map(arg => {
if (typeof arg === 'function') return arg.toString();
return JSON.stringify(arg != null ? arg : null);
}).join(',');
return "(" + fn.toString() + ")(" + params + ")";
return `(${fn.toString()})(${params})`;
}
function persistJS(items, context) {
return items.map(function (item) {
return items.map(item => {
if (item.type === 'script') return wrapHtml('script', '', item.data);
if (item.type === 'iife') {
var _item$data = item.data,
fn = _item$data.fn,
getParams = _item$data.getParams;
const {
fn,
getParams
} = item.data;
return wrapHtml('script', escapeScript(buildCode(fn, (getParams == null ? void 0 : getParams(context)) || [])));

@@ -108,3 +89,3 @@ }

function persistCSS(items) {
return items.map(function (item) {
return items.map(item => {
if (item.type === 'stylesheet') {

@@ -122,25 +103,19 @@ return wrapHtml('link', null, _extends({

var uniqId = Math.random().toString(36).slice(2, 8);
var globalIndex = 0;
const uniqId = Math.random().toString(36).slice(2, 8);
let globalIndex = 0;
function getId() {
globalIndex += 1;
return "mm-" + uniqId + "-" + globalIndex;
return `mm-${uniqId}-${globalIndex}`;
}
function noop() {// noop
}
function walkTree(tree, callback, key) {
if (key === void 0) {
key = 'c';
}
function walkTree(tree, callback, key = 'c') {
const walk = (item, parent) => callback(item, () => {
var _item$key;
var walk = function walk(item, parent) {
return callback(item, function () {
var _item$key;
(_item$key = item[key]) == null ? void 0 : _item$key.forEach(child => {
walk(child, item);
});
}, parent);
(_item$key = item[key]) == null ? void 0 : _item$key.forEach(function (child) {
walk(child, item);
});
}, parent);
};
walk(tree);

@@ -150,5 +125,5 @@ }

if (Array.from) return Array.from(arrayLike);
var array = [];
const array = [];
for (var i = 0; i < arrayLike.length; i += 1) {
for (let i = 0; i < arrayLike.length; i += 1) {
array.push(arrayLike[i]);

@@ -161,7 +136,7 @@ }

if (arrayLike.flatMap) return arrayLike.flatMap(callback);
var array = [];
const array = [];
for (var i = 0; i < arrayLike.length; i += 1) {
var result = callback(arrayLike[i], i, arrayLike);
if (Array.isArray(result)) array.push.apply(array, result);else array.push(result);
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);
}

@@ -171,10 +146,5 @@

}
function addClass(className) {
var classList = (className || '').split(' ').filter(Boolean);
for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
rest[_key - 1] = arguments[_key];
}
rest.forEach(function (item) {
function addClass(className, ...rest) {
const classList = (className || '').split(' ').filter(Boolean);
rest.forEach(item => {
if (item && classList.indexOf(item) < 0) classList.push(item);

@@ -186,28 +156,21 @@ });

if (typeof filter === 'string') {
var tagName = filter;
const tagName = filter;
filter = function filter(el) {
return el.tagName === tagName;
};
filter = el => el.tagName === tagName;
}
var filterFn = filter;
const filterFn = filter;
return function selector() {
var nodes = arrayFrom(this.childNodes);
if (filterFn) nodes = nodes.filter(function (node) {
return filterFn(node);
});
let nodes = arrayFrom(this.childNodes);
if (filterFn) nodes = nodes.filter(node => filterFn(node));
return nodes;
};
}
function wrapFunction(fn, _ref) {
var before = _ref.before,
after = _ref.after;
return function wrapped() {
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
var ctx = {
args: args
function wrapFunction(fn, {
before,
after
}) {
return function wrapped(...args) {
const ctx = {
args
};

@@ -220,3 +183,3 @@

ctx.result = fn.apply(void 0, args);
ctx.result = fn(...args);

@@ -232,4 +195,4 @@ try {

function defer() {
var obj = {};
obj.promise = new Promise(function (resolve, reject) {
const obj = {};
obj.promise = new Promise((resolve, reject) => {
obj.resolve = resolve;

@@ -241,10 +204,10 @@ obj.reject = reject;

function memoize(fn) {
var cache = {};
return function memoized() {
var key = "" + (arguments.length <= 0 ? undefined : arguments[0]);
var data = cache[key];
const cache = {};
return function memoized(...args) {
const key = `${args[0]}`;
let data = cache[key];
if (!data) {
data = {
value: fn.apply(void 0, arguments)
value: fn(...args)
};

@@ -258,15 +221,7 @@ cache[key] = data;

function _createForOfIteratorHelperLoose$1(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$1(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } it = o[Symbol.iterator](); return it.next.bind(it); }
function _unsupportedIterableToArray$1(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$1(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen); }
function _arrayLikeToArray$1(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
function createElement(tagName, props, attrs) {
var el = document.createElement(tagName);
const el = document.createElement(tagName);
if (props) {
Object.entries(props).forEach(function (_ref) {
var key = _ref[0],
value = _ref[1];
Object.entries(props).forEach(([key, value]) => {
el[key] = value;

@@ -277,5 +232,3 @@ });

if (attrs) {
Object.entries(attrs).forEach(function (_ref2) {
var key = _ref2[0],
value = _ref2[1];
Object.entries(attrs).forEach(([key, value]) => {
el.setAttribute(key, value);

@@ -288,3 +241,3 @@ });

var memoizedPreloadJS = memoize(function (url) {
const memoizedPreloadJS = memoize(url => {
document.head.append(createElement('link', {

@@ -299,3 +252,3 @@ rel: 'preload',

if (item.type === 'script') {
return new Promise(function (resolve, reject) {
return new Promise((resolve, reject) => {
document.head.append(createElement('script', _extends({}, item.data, {

@@ -309,6 +262,7 @@ onload: resolve,

if (item.type === 'iife') {
var _item$data = item.data,
fn = _item$data.fn,
getParams = _item$data.getParams;
fn.apply(void 0, (getParams == null ? void 0 : getParams(context)) || []);
const {
fn,
getParams
} = item.data;
fn(...((getParams == null ? void 0 : getParams(context)) || []));
}

@@ -329,54 +283,15 @@ }

function loadJS(_x, _x2) {
return _loadJS.apply(this, arguments);
}
async function loadJS(items, context) {
const needPreload = items.filter(item => item.type === 'script');
if (needPreload.length > 1) needPreload.forEach(item => memoizedPreloadJS(item.data.src));
context = _extends({
getMarkmap: () => window.markmap
}, context);
function _loadJS() {
_loadJS = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(items, context) {
var needPreload, _iterator2, _step2, item;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
needPreload = items.filter(function (item) {
return item.type === 'script';
});
if (needPreload.length > 1) needPreload.forEach(function (item) {
return memoizedPreloadJS(item.data.src);
});
context = _extends({
getMarkmap: function getMarkmap() {
return window.markmap;
}
}, context);
_iterator2 = _createForOfIteratorHelperLoose$1(items);
case 4:
if ((_step2 = _iterator2()).done) {
_context.next = 10;
break;
}
item = _step2.value;
_context.next = 8;
return loadJSItem(item, context);
case 8:
_context.next = 4;
break;
case 10:
case "end":
return _context.stop();
}
}
}, _callee);
}));
return _loadJS.apply(this, arguments);
for (const item of items) {
await loadJSItem(item, context);
}
}
function loadCSS(items) {
for (var _iterator = _createForOfIteratorHelperLoose$1(items), _step; !(_step = _iterator()).done;) {
var item = _step.value;
for (const item of items) {
loadCSSItem(item);

@@ -383,0 +298,0 @@ }

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

/*! markmap-common v0.1.1-alpha.8+a8c283a | MIT License */
/*! markmap-common v0.1.1 | MIT License */
'use strict';

@@ -7,4 +7,2 @@

var _extends = require('@babel/runtime/helpers/extends');
var _regeneratorRuntime = require('@babel/runtime/regenerator');
var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');

@@ -14,54 +12,36 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e['default'] : e; }

var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
var _regeneratorRuntime__default = /*#__PURE__*/_interopDefaultLegacy(_regeneratorRuntime);
var _asyncToGenerator__default = /*#__PURE__*/_interopDefaultLegacy(_asyncToGenerator);
function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } it = o[Symbol.iterator](); return it.next.bind(it); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
var Hook = /*#__PURE__*/function () {
function Hook() {
class Hook {
constructor() {
this.listeners = [];
}
var _proto = Hook.prototype;
_proto.tap = function tap(fn) {
var _this = this;
tap(fn) {
this.listeners.push(fn);
return function () {
return _this.revoke(fn);
};
};
return () => this.revoke(fn);
}
_proto.revoke = function revoke(fn) {
var i = this.listeners.indexOf(fn);
revoke(fn) {
const i = this.listeners.indexOf(fn);
if (i >= 0) this.listeners.splice(i, 1);
};
}
_proto.revokeAll = function revokeAll() {
revokeAll() {
this.listeners.splice(0);
};
}
_proto.call = function call() {
for (var _iterator = _createForOfIteratorHelperLoose(this.listeners), _step; !(_step = _iterator()).done;) {
var fn = _step.value;
fn.apply(void 0, arguments);
call(...args) {
for (const fn of this.listeners) {
fn(...args);
}
};
}
return Hook;
}();
}
function escapeHtml(html) {
return html.replace(/[&<"]/g, function (m) {
return {
'&': '&amp;',
'<': '&lt;',
'"': '&quot;'
}[m];
});
return html.replace(/[&<"]/g, m => ({
'&': '&amp;',
'<': '&lt;',
'"': '&quot;'
})[m]);
}

@@ -72,14 +52,12 @@ function escapeScript(content) {

function htmlOpen(tagName, attrs) {
var attrStr = attrs ? Object.entries(attrs).map(function (_ref) {
var key = _ref[0],
value = _ref[1];
const attrStr = attrs ? Object.entries(attrs).map(([key, value]) => {
if (value == null || value === false) return;
key = " " + escapeHtml(key);
key = ` ${escapeHtml(key)}`;
if (value === true) return key;
return key + "=\"" + escapeHtml(value) + "\"";
return `${key}="${escapeHtml(value)}"`;
}).filter(Boolean).join('') : '';
return "<" + tagName + attrStr + ">";
return `<${tagName}${attrStr}>`;
}
function htmlClose(tagName) {
return "</" + tagName + ">";
return `</${tagName}>`;
}

@@ -98,16 +76,17 @@ function wrapHtml(tagName, content, attrs) {

function buildCode(fn, args) {
var params = args.map(function (arg) {
const params = args.map(arg => {
if (typeof arg === 'function') return arg.toString();
return JSON.stringify(arg != null ? arg : null);
}).join(',');
return "(" + fn.toString() + ")(" + params + ")";
return `(${fn.toString()})(${params})`;
}
function persistJS(items, context) {
return items.map(function (item) {
return items.map(item => {
if (item.type === 'script') return wrapHtml('script', '', item.data);
if (item.type === 'iife') {
var _item$data = item.data,
fn = _item$data.fn,
getParams = _item$data.getParams;
const {
fn,
getParams
} = item.data;
return wrapHtml('script', escapeScript(buildCode(fn, (getParams == null ? void 0 : getParams(context)) || [])));

@@ -120,3 +99,3 @@ }

function persistCSS(items) {
return items.map(function (item) {
return items.map(item => {
if (item.type === 'stylesheet') {

@@ -134,25 +113,19 @@ return wrapHtml('link', null, _extends__default({

var uniqId = Math.random().toString(36).slice(2, 8);
var globalIndex = 0;
const uniqId = Math.random().toString(36).slice(2, 8);
let globalIndex = 0;
function getId() {
globalIndex += 1;
return "mm-" + uniqId + "-" + globalIndex;
return `mm-${uniqId}-${globalIndex}`;
}
function noop() {// noop
}
function walkTree(tree, callback, key) {
if (key === void 0) {
key = 'c';
}
function walkTree(tree, callback, key = 'c') {
const walk = (item, parent) => callback(item, () => {
var _item$key;
var walk = function walk(item, parent) {
return callback(item, function () {
var _item$key;
(_item$key = item[key]) == null ? void 0 : _item$key.forEach(child => {
walk(child, item);
});
}, parent);
(_item$key = item[key]) == null ? void 0 : _item$key.forEach(function (child) {
walk(child, item);
});
}, parent);
};
walk(tree);

@@ -162,5 +135,5 @@ }

if (Array.from) return Array.from(arrayLike);
var array = [];
const array = [];
for (var i = 0; i < arrayLike.length; i += 1) {
for (let i = 0; i < arrayLike.length; i += 1) {
array.push(arrayLike[i]);

@@ -173,7 +146,7 @@ }

if (arrayLike.flatMap) return arrayLike.flatMap(callback);
var array = [];
const array = [];
for (var i = 0; i < arrayLike.length; i += 1) {
var result = callback(arrayLike[i], i, arrayLike);
if (Array.isArray(result)) array.push.apply(array, result);else array.push(result);
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);
}

@@ -183,10 +156,5 @@

}
function addClass(className) {
var classList = (className || '').split(' ').filter(Boolean);
for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
rest[_key - 1] = arguments[_key];
}
rest.forEach(function (item) {
function addClass(className, ...rest) {
const classList = (className || '').split(' ').filter(Boolean);
rest.forEach(item => {
if (item && classList.indexOf(item) < 0) classList.push(item);

@@ -198,28 +166,21 @@ });

if (typeof filter === 'string') {
var tagName = filter;
const tagName = filter;
filter = function filter(el) {
return el.tagName === tagName;
};
filter = el => el.tagName === tagName;
}
var filterFn = filter;
const filterFn = filter;
return function selector() {
var nodes = arrayFrom(this.childNodes);
if (filterFn) nodes = nodes.filter(function (node) {
return filterFn(node);
});
let nodes = arrayFrom(this.childNodes);
if (filterFn) nodes = nodes.filter(node => filterFn(node));
return nodes;
};
}
function wrapFunction(fn, _ref) {
var before = _ref.before,
after = _ref.after;
return function wrapped() {
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
var ctx = {
args: args
function wrapFunction(fn, {
before,
after
}) {
return function wrapped(...args) {
const ctx = {
args
};

@@ -232,3 +193,3 @@

ctx.result = fn.apply(void 0, args);
ctx.result = fn(...args);

@@ -244,4 +205,4 @@ try {

function defer() {
var obj = {};
obj.promise = new Promise(function (resolve, reject) {
const obj = {};
obj.promise = new Promise((resolve, reject) => {
obj.resolve = resolve;

@@ -253,10 +214,10 @@ obj.reject = reject;

function memoize(fn) {
var cache = {};
return function memoized() {
var key = "" + (arguments.length <= 0 ? undefined : arguments[0]);
var data = cache[key];
const cache = {};
return function memoized(...args) {
const key = `${args[0]}`;
let data = cache[key];
if (!data) {
data = {
value: fn.apply(void 0, arguments)
value: fn(...args)
};

@@ -270,15 +231,7 @@ cache[key] = data;

function _createForOfIteratorHelperLoose$1(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$1(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } it = o[Symbol.iterator](); return it.next.bind(it); }
function _unsupportedIterableToArray$1(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$1(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen); }
function _arrayLikeToArray$1(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
function createElement(tagName, props, attrs) {
var el = document.createElement(tagName);
const el = document.createElement(tagName);
if (props) {
Object.entries(props).forEach(function (_ref) {
var key = _ref[0],
value = _ref[1];
Object.entries(props).forEach(([key, value]) => {
el[key] = value;

@@ -289,5 +242,3 @@ });

if (attrs) {
Object.entries(attrs).forEach(function (_ref2) {
var key = _ref2[0],
value = _ref2[1];
Object.entries(attrs).forEach(([key, value]) => {
el.setAttribute(key, value);

@@ -300,3 +251,3 @@ });

var memoizedPreloadJS = memoize(function (url) {
const memoizedPreloadJS = memoize(url => {
document.head.append(createElement('link', {

@@ -311,3 +262,3 @@ rel: 'preload',

if (item.type === 'script') {
return new Promise(function (resolve, reject) {
return new Promise((resolve, reject) => {
document.head.append(createElement('script', _extends__default({}, item.data, {

@@ -321,6 +272,7 @@ onload: resolve,

if (item.type === 'iife') {
var _item$data = item.data,
fn = _item$data.fn,
getParams = _item$data.getParams;
fn.apply(void 0, (getParams == null ? void 0 : getParams(context)) || []);
const {
fn,
getParams
} = item.data;
fn(...((getParams == null ? void 0 : getParams(context)) || []));
}

@@ -341,54 +293,15 @@ }

function loadJS(_x, _x2) {
return _loadJS.apply(this, arguments);
}
async function loadJS(items, context) {
const needPreload = items.filter(item => item.type === 'script');
if (needPreload.length > 1) needPreload.forEach(item => memoizedPreloadJS(item.data.src));
context = _extends__default({
getMarkmap: () => window.markmap
}, context);
function _loadJS() {
_loadJS = _asyncToGenerator__default( /*#__PURE__*/_regeneratorRuntime__default.mark(function _callee(items, context) {
var needPreload, _iterator2, _step2, item;
return _regeneratorRuntime__default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
needPreload = items.filter(function (item) {
return item.type === 'script';
});
if (needPreload.length > 1) needPreload.forEach(function (item) {
return memoizedPreloadJS(item.data.src);
});
context = _extends__default({
getMarkmap: function getMarkmap() {
return window.markmap;
}
}, context);
_iterator2 = _createForOfIteratorHelperLoose$1(items);
case 4:
if ((_step2 = _iterator2()).done) {
_context.next = 10;
break;
}
item = _step2.value;
_context.next = 8;
return loadJSItem(item, context);
case 8:
_context.next = 4;
break;
case 10:
case "end":
return _context.stop();
}
}
}, _callee);
}));
return _loadJS.apply(this, arguments);
for (const item of items) {
await loadJSItem(item, context);
}
}
function loadCSS(items) {
for (var _iterator = _createForOfIteratorHelperLoose$1(items), _step; !(_step = _iterator()).done;) {
var item = _step.value;
for (const item of items) {
loadCSSItem(item);

@@ -395,0 +308,0 @@ }

{
"name": "markmap-common",
"version": "0.1.1-alpha.8+a8c283a",
"version": "0.1.1",
"description": "",

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

},
"gitHead": "a8c283a76f6984feb3f6ca1da2b63d2d6d1c29ca"
"gitHead": "d02c253a0cff97b604f96ffaec294e8da941c84b"
}
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