New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

markmap-common

Package Overview
Dependencies
Maintainers
1
Versions
61
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.0 to 0.1.1-alpha.8

types/loader.d.ts

160

dist/index.esm.js

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

/*! markmap-common v0.1.0 | MIT License */
/*! markmap-common v0.1.1-alpha.8+a8c283a | MIT License */
import _extends from '@babel/runtime/helpers/esm/extends';
import _regeneratorRuntime from '@babel/runtime/regenerator';
import _asyncToGenerator from '@babel/runtime/helpers/esm/asyncToGenerator';

@@ -89,18 +91,2 @@ 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 memoize(fn) {
var cache = {};
return function memoized() {
var key = "" + (arguments.length <= 0 ? undefined : arguments[0]);
var data = cache[key];
if (!data) {
data = {
value: fn.apply(void 0, arguments)
};
cache[key] = data;
}
return data.value;
};
}
function persistJS(items, context) {

@@ -245,3 +231,141 @@ return items.map(function (item) {

}
function memoize(fn) {
var cache = {};
return function memoized() {
var key = "" + (arguments.length <= 0 ? undefined : arguments[0]);
var data = cache[key];
export { Hook, addClass, arrayFrom, buildCode, childSelector, defer, escapeHtml, escapeScript, flatMap, getId, htmlClose, htmlOpen, memoize, noop, persistCSS, persistJS, walkTree, wrapFunction, wrapHtml, wrapStyle };
if (!data) {
data = {
value: fn.apply(void 0, arguments)
};
cache[key] = data;
}
return data.value;
};
}
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);
if (props) {
Object.entries(props).forEach(function (_ref) {
var key = _ref[0],
value = _ref[1];
el[key] = value;
});
}
if (attrs) {
Object.entries(attrs).forEach(function (_ref2) {
var key = _ref2[0],
value = _ref2[1];
el.setAttribute(key, value);
});
}
return el;
}
var memoizedPreloadJS = memoize(function (url) {
document.head.append(createElement('link', {
rel: 'preload',
as: 'script',
href: url
}));
});
function loadJSItem(item, context) {
if (item.type === 'script') {
return new Promise(function (resolve, reject) {
document.head.append(createElement('script', _extends({}, item.data, {
onload: resolve,
onerror: reject
})));
});
}
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)) || []);
}
}
function loadCSSItem(item) {
if (item.type === 'style') {
document.head.append(createElement('style', {
textContent: item.data
}));
} else if (item.type === 'stylesheet') {
document.head.append(createElement('link', _extends({
rel: 'stylesheet'
}, item.data)));
}
}
function loadJS(_x, _x2) {
return _loadJS.apply(this, arguments);
}
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);
}
function loadCSS(items) {
for (var _iterator = _createForOfIteratorHelperLoose$1(items), _step; !(_step = _iterator()).done;) {
var item = _step.value;
loadCSSItem(item);
}
}
export { Hook, addClass, arrayFrom, buildCode, childSelector, defer, escapeHtml, escapeScript, flatMap, getId, htmlClose, htmlOpen, loadCSS, loadJS, memoize, noop, persistCSS, persistJS, walkTree, wrapFunction, wrapHtml, wrapStyle };

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

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

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

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

@@ -12,2 +14,4 @@ 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);

@@ -99,18 +103,2 @@ 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 memoize(fn) {
var cache = {};
return function memoized() {
var key = "" + (arguments.length <= 0 ? undefined : arguments[0]);
var data = cache[key];
if (!data) {
data = {
value: fn.apply(void 0, arguments)
};
cache[key] = data;
}
return data.value;
};
}
function persistJS(items, context) {

@@ -255,3 +243,141 @@ return items.map(function (item) {

}
function memoize(fn) {
var cache = {};
return function memoized() {
var key = "" + (arguments.length <= 0 ? undefined : arguments[0]);
var data = cache[key];
if (!data) {
data = {
value: fn.apply(void 0, arguments)
};
cache[key] = data;
}
return data.value;
};
}
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);
if (props) {
Object.entries(props).forEach(function (_ref) {
var key = _ref[0],
value = _ref[1];
el[key] = value;
});
}
if (attrs) {
Object.entries(attrs).forEach(function (_ref2) {
var key = _ref2[0],
value = _ref2[1];
el.setAttribute(key, value);
});
}
return el;
}
var memoizedPreloadJS = memoize(function (url) {
document.head.append(createElement('link', {
rel: 'preload',
as: 'script',
href: url
}));
});
function loadJSItem(item, context) {
if (item.type === 'script') {
return new Promise(function (resolve, reject) {
document.head.append(createElement('script', _extends__default({}, item.data, {
onload: resolve,
onerror: reject
})));
});
}
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)) || []);
}
}
function loadCSSItem(item) {
if (item.type === 'style') {
document.head.append(createElement('style', {
textContent: item.data
}));
} else if (item.type === 'stylesheet') {
document.head.append(createElement('link', _extends__default({
rel: 'stylesheet'
}, item.data)));
}
}
function loadJS(_x, _x2) {
return _loadJS.apply(this, arguments);
}
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);
}
function loadCSS(items) {
for (var _iterator = _createForOfIteratorHelperLoose$1(items), _step; !(_step = _iterator()).done;) {
var item = _step.value;
loadCSSItem(item);
}
}
exports.Hook = Hook;

@@ -269,2 +395,4 @@ exports.addClass = addClass;

exports.htmlOpen = htmlOpen;
exports.loadCSS = loadCSS;
exports.loadJS = loadJS;
exports.memoize = memoize;

@@ -271,0 +399,0 @@ exports.noop = noop;

17

package.json
{
"name": "markmap-common",
"version": "0.1.0",
"version": "0.1.1-alpha.8+a8c283a",
"description": "",
"author": "",
"license": "MIT",
"husky": {
"hooks": {
"pre-push": "yarn lint"
}
},
"scripts": {

@@ -16,7 +11,7 @@ "dev": "rollup -wc rollup.conf.js",

"build:js": "rollup -c rollup.conf.js",
"prebuild": "yarn ci && yarn clean",
"prepublishOnly": "yarn build",
"ci": "yarn lint",
"prebuild": "npm run ci && npm run clean",
"prepublishOnly": "npm run build",
"ci": "npm run lint",
"lint": "eslint --ext .ts,.tsx .",
"build": "tsc && yarn build:js"
"build": "tsc && npm run build:js"
},

@@ -37,3 +32,3 @@ "main": "dist/index.js",

},
"gitHead": "a8f734bf0ecba98dd125756785f084562e263ac1"
"gitHead": "a8c283a76f6984feb3f6ca1da2b63d2d6d1c29ca"
}
# markmap-common
This project is generated from [@gera2ld/generator-rollup](https://github.com/gera2ld/generator-rollup).
## Development
``` sh
$ yarn dev
```
## Building
```sh
$ yarn build
```
## Lint
``` sh
$ yarn lint
```
Common types and utility functions used by markmap packages.

@@ -9,4 +9,3 @@ import { JSItem, CSSItem } from './types';

export declare function buildCode(fn: Function, args: any[]): string;
export declare function memoize<T extends (...args: any[]) => any>(fn: T): T;
export declare function persistJS(items: JSItem[], context?: any): string[];
export declare function persistCSS(items: CSSItem[]): string[];
export * from './hook';
export * from './html';
export * from './util';
export * from './loader';
export * from './types';

@@ -14,1 +14,2 @@ import { IWrapContext, IDeferred } from './types';

export declare function defer<T>(): IDeferred<T>;
export declare function memoize<T extends (...args: any[]) => any>(fn: T): T;
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