markmap-common
Advanced tools
Comparing version 0.1.6 to 0.13.0-alpha.0
@@ -1,2 +0,2 @@ | ||
/*! markmap-common v0.1.6 | MIT License */ | ||
/*! markmap-common v0.13.0-alpha.0 | MIT License */ | ||
class Hook { | ||
@@ -73,9 +73,2 @@ constructor() { | ||
} | ||
function wrapStyle(text, style) { | ||
if (style.code) text = wrapHtml('code', text); | ||
if (style.del) text = wrapHtml('del', text); | ||
if (style.em) text = wrapHtml('em', text); | ||
if (style.strong) text = wrapHtml('strong', text); | ||
return text; | ||
} | ||
function buildCode(fn, args) { | ||
@@ -125,3 +118,3 @@ const params = args.map(arg => { | ||
} | ||
function walkTree(tree, callback, key = 'c') { | ||
function walkTree(tree, callback, key = 'children') { | ||
const walk = (item, parent) => callback(item, () => { | ||
@@ -311,2 +304,2 @@ var _item$key; | ||
export { Hook, addClass, arrayFrom, buildCode, childSelector, defer, escapeHtml, escapeScript, flatMap, getId, htmlClose, htmlOpen, loadCSS, loadJS, memoize, noop, persistCSS, persistJS, walkTree, wrapFunction, wrapHtml, wrapStyle }; | ||
export { Hook, addClass, arrayFrom, buildCode, childSelector, defer, escapeHtml, escapeScript, flatMap, getId, htmlClose, htmlOpen, loadCSS, loadJS, memoize, noop, persistCSS, persistJS, walkTree, wrapFunction, wrapHtml }; |
@@ -1,2 +0,2 @@ | ||
/*! markmap-common v0.1.6 | MIT License */ | ||
/*! markmap-common v0.13.0-alpha.0 | MIT License */ | ||
'use strict'; | ||
@@ -77,9 +77,2 @@ | ||
} | ||
function wrapStyle(text, style) { | ||
if (style.code) text = wrapHtml('code', text); | ||
if (style.del) text = wrapHtml('del', text); | ||
if (style.em) text = wrapHtml('em', text); | ||
if (style.strong) text = wrapHtml('strong', text); | ||
return text; | ||
} | ||
function buildCode(fn, args) { | ||
@@ -129,3 +122,3 @@ const params = args.map(arg => { | ||
} | ||
function walkTree(tree, callback, key = 'c') { | ||
function walkTree(tree, callback, key = 'children') { | ||
const walk = (item, parent) => callback(item, () => { | ||
@@ -336,2 +329,1 @@ var _item$key; | ||
exports.wrapHtml = wrapHtml; | ||
exports.wrapStyle = wrapStyle; |
{ | ||
"name": "markmap-common", | ||
"version": "0.1.6", | ||
"version": "0.13.0-alpha.0", | ||
"description": "", | ||
@@ -27,3 +27,3 @@ "author": "", | ||
}, | ||
"gitHead": "fbec667e1706813f9f60bea6a971f3820858ca40" | ||
"gitHead": "969aa149f36580954e77b7ba434e5c48b409cfc2" | ||
} |
@@ -1,3 +0,3 @@ | ||
export declare type HookCallback<T extends any[]> = (...args: T) => void; | ||
export declare class Hook<T extends any[]> { | ||
export declare type HookCallback<T extends unknown[]> = (...args: T) => void; | ||
export declare class Hook<T extends unknown[]> { | ||
protected listeners: Array<HookCallback<T>>; | ||
@@ -4,0 +4,0 @@ tap(fn: HookCallback<T>): () => void; |
import { JSItem, CSSItem } from './types'; | ||
export declare function escapeHtml(html: string): string; | ||
export declare function escapeScript(content: string): string; | ||
export declare function htmlOpen(tagName: string, attrs?: any): string; | ||
export declare function htmlOpen(tagName: string, attrs?: Record<string, string | boolean>): string; | ||
export declare function htmlClose(tagName: string): string; | ||
export declare function wrapHtml(tagName: string, content?: string, attrs?: any): string; | ||
export declare function wrapStyle(text: string, style: any): string; | ||
export declare function buildCode(fn: Function, args: any[]): string; | ||
export declare function persistJS(items: JSItem[], context?: any): string[]; | ||
export declare function wrapHtml(tagName: string, content?: string, 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[]; |
import { JSItem, CSSItem } from './types'; | ||
export declare function loadJS(items: JSItem[], context?: any): Promise<void>; | ||
export declare function loadJS(items: JSItem[], context?: object): Promise<void>; | ||
export declare function loadCSS(items: CSSItem[]): void; |
export interface IHierarchy<T> { | ||
type: string; | ||
/** | ||
* type | ||
* Additional data created on transformation. | ||
*/ | ||
t: string; | ||
payload?: { | ||
/** | ||
* Whether the node's children are fold. | ||
*/ | ||
fold?: boolean; | ||
/** | ||
* Index of list items. | ||
*/ | ||
index?: number; | ||
/** | ||
* Start index of an ordered list. | ||
*/ | ||
startIndex?: number; | ||
/** | ||
* First and last lines of the source generating the node. | ||
*/ | ||
lines?: [startLine: number, endLine: number]; | ||
}; | ||
/** | ||
* payload | ||
* Store temporary data that helps rendering. | ||
*/ | ||
p?: any; | ||
/** | ||
* children | ||
*/ | ||
c?: T[]; | ||
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[]; | ||
} | ||
export interface INode extends IHierarchy<INode> { | ||
depth?: number; | ||
/** | ||
* depth | ||
* HTML of the node content. | ||
*/ | ||
d?: number; | ||
/** | ||
* value | ||
*/ | ||
v: string; | ||
content: string; | ||
} | ||
@@ -36,15 +65,22 @@ export declare type JSScriptItem = { | ||
data: { | ||
fn: (...args: any[]) => void; | ||
getParams?: (context: any) => void | any[]; | ||
fn: (...args: unknown[]) => void; | ||
getParams?: (context: unknown) => void | unknown[]; | ||
}; | ||
}; | ||
export declare type JSItem = JSScriptItem | JSIIFEItem; | ||
export declare type CSSItem = { | ||
type: 'style' | 'stylesheet'; | ||
data: any; | ||
export declare type CSSStyleItem = { | ||
type: 'style'; | ||
data: string; | ||
}; | ||
export interface IWrapContext<T extends (...args: any[]) => any> { | ||
thisObj: any; | ||
args: Parameters<T>; | ||
result?: ReturnType<T>; | ||
export declare type CSSStylesheetItem = { | ||
type: 'stylesheet'; | ||
data: { | ||
href: string; | ||
}; | ||
}; | ||
export declare type CSSItem = CSSStyleItem | CSSStylesheetItem; | ||
export interface IWrapContext<T extends unknown[], U> { | ||
thisObj: unknown; | ||
args: T; | ||
result?: U; | ||
} | ||
@@ -54,3 +90,3 @@ export interface IDeferred<T> { | ||
resolve: (value: T) => void; | ||
reject: (error?: any) => void; | ||
reject: (error?: unknown) => void; | ||
} |
@@ -9,7 +9,7 @@ import { IWrapContext, IDeferred } from './types'; | ||
export declare function childSelector<T extends Element>(filter?: string | ((el: T) => boolean)): () => T[]; | ||
export declare function wrapFunction<T extends (...args: any[]) => any>(fn: T, { before, after, }: { | ||
before?: (ctx: IWrapContext<T>) => void; | ||
after?: (ctx: IWrapContext<T>) => void; | ||
}): 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 defer<T>(): IDeferred<T>; | ||
export declare function memoize<T extends (...args: any[]) => any>(fn: T): T; | ||
export declare function memoize<T extends unknown[], U>(fn: (...args: T) => U): (...args: T) => U; |
20811
670