markmap-view 0.18.4-alpha.3 → 0.18.4-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,342 +1,5 @@
1
1
  (function(exports, d32) {
2
2
  "use strict";
3
- class Hook {
4
- constructor() {
5
- this.listeners = [];
6
- }
7
- tap(fn) {
8
- this.listeners.push(fn);
9
- return () => this.revoke(fn);
10
- }
11
- revoke(fn) {
12
- const i = this.listeners.indexOf(fn);
13
- if (i >= 0) this.listeners.splice(i, 1);
14
- }
15
- revokeAll() {
16
- this.listeners.splice(0);
17
- }
18
- call(...args) {
19
- for (const fn of this.listeners) {
20
- fn(...args);
21
- }
22
- }
23
- }
24
- const uniqId = Math.random().toString(36).slice(2, 8);
25
- let globalIndex = 0;
26
- function getId() {
27
- globalIndex += 1;
28
- return `mm-${uniqId}-${globalIndex}`;
29
- }
30
- function noop() {
31
- }
32
- function walkTree(tree, callback) {
33
- const walk = (item, parent) => callback(
34
- item,
35
- () => {
36
- var _a;
37
- return (_a = item.children) == null ? void 0 : _a.map((child) => walk(child, item));
38
- },
39
- parent
40
- );
41
- return walk(tree);
42
- }
43
- function addClass(className, ...rest) {
44
- const classList = (className || "").split(" ").filter(Boolean);
45
- rest.forEach((item) => {
46
- if (item && classList.indexOf(item) < 0) classList.push(item);
47
- });
48
- return classList.join(" ");
49
- }
50
- function childSelector(filter) {
51
- if (typeof filter === "string") {
52
- const tagName = filter;
53
- filter = (el) => el.tagName === tagName;
54
- }
55
- const filterFn = filter;
56
- return function selector() {
57
- let nodes = Array.from(this.childNodes);
58
- if (filterFn) nodes = nodes.filter((node) => filterFn(node));
59
- return nodes;
60
- };
61
- }
62
- function defer() {
63
- const obj = {};
64
- obj.promise = new Promise((resolve, reject) => {
65
- obj.resolve = resolve;
66
- obj.reject = reject;
67
- });
68
- return obj;
69
- }
70
- function memoize(fn) {
71
- const cache = {};
72
- return function memoized(...args) {
73
- const key = `${args[0]}`;
74
- let data = cache[key];
75
- if (!data) {
76
- data = {
77
- value: fn(...args)
78
- };
79
- cache[key] = data;
80
- }
81
- return data.value;
82
- };
83
- }
84
- function debounce(fn, time) {
85
- const state = {
86
- timer: 0
87
- };
88
- function reset() {
89
- if (state.timer) {
90
- window.clearTimeout(state.timer);
91
- state.timer = 0;
92
- }
93
- }
94
- function run() {
95
- reset();
96
- if (state.args) state.result = fn(...state.args);
97
- }
98
- return function debounced(...args) {
99
- reset();
100
- state.args = args;
101
- state.timer = window.setTimeout(run, time);
102
- return state.result;
103
- };
104
- }
105
- /*! @gera2ld/jsx-dom v2.2.2 | ISC License */
106
- const VTYPE_ELEMENT = 1;
107
- const VTYPE_FUNCTION = 2;
108
- const SVG_NS = "http://www.w3.org/2000/svg";
109
- const XLINK_NS = "http://www.w3.org/1999/xlink";
110
- const NS_ATTRS = {
111
- show: XLINK_NS,
112
- actuate: XLINK_NS,
113
- href: XLINK_NS
114
- };
115
- const isLeaf = (c) => typeof c === "string" || typeof c === "number";
116
- const isElement = (c) => (c == null ? void 0 : c.vtype) === VTYPE_ELEMENT;
117
- const isRenderFunction = (c) => (c == null ? void 0 : c.vtype) === VTYPE_FUNCTION;
118
- function h(type, props, ...children) {
119
- props = Object.assign({}, props, {
120
- children: children.length === 1 ? children[0] : children
121
- });
122
- return jsx(type, props);
123
- }
124
- function jsx(type, props) {
125
- let vtype;
126
- if (typeof type === "string") vtype = VTYPE_ELEMENT;
127
- else if (typeof type === "function") vtype = VTYPE_FUNCTION;
128
- else throw new Error("Invalid VNode type");
129
- return {
130
- vtype,
131
- type,
132
- props
133
- };
134
- }
135
- function Fragment(props) {
136
- return props.children;
137
- }
138
- const DEFAULT_ENV = {
139
- isSvg: false
140
- };
141
- function insertDom(parent, nodes) {
142
- if (!Array.isArray(nodes)) nodes = [nodes];
143
- nodes = nodes.filter(Boolean);
144
- if (nodes.length) parent.append(...nodes);
145
- }
146
- function mountAttributes(domElement, props, env) {
147
- for (const key in props) {
148
- if (key === "key" || key === "children" || key === "ref") continue;
149
- if (key === "dangerouslySetInnerHTML") {
150
- domElement.innerHTML = props[key].__html;
151
- } else if (key === "innerHTML" || key === "textContent" || key === "innerText" || key === "value" && ["textarea", "select"].includes(domElement.tagName)) {
152
- const value = props[key];
153
- if (value != null) domElement[key] = value;
154
- } else if (key.startsWith("on")) {
155
- domElement[key.toLowerCase()] = props[key];
156
- } else {
157
- setDOMAttribute(domElement, key, props[key], env.isSvg);
158
- }
159
- }
160
- }
161
- const attrMap = {
162
- className: "class",
163
- labelFor: "for"
164
- };
165
- function setDOMAttribute(el, attr, value, isSVG) {
166
- attr = attrMap[attr] || attr;
167
- if (value === true) {
168
- el.setAttribute(attr, "");
169
- } else if (value === false) {
170
- el.removeAttribute(attr);
171
- } else {
172
- const namespace = isSVG ? NS_ATTRS[attr] : void 0;
173
- if (namespace !== void 0) {
174
- el.setAttributeNS(namespace, attr, value);
175
- } else {
176
- el.setAttribute(attr, value);
177
- }
178
- }
179
- }
180
- function flatten(arr) {
181
- return arr.reduce((prev, item) => prev.concat(item), []);
182
- }
183
- function mountChildren(children, env) {
184
- return Array.isArray(children) ? flatten(children.map((child) => mountChildren(child, env))) : mount(children, env);
185
- }
186
- function mount(vnode, env = DEFAULT_ENV) {
187
- if (vnode == null || typeof vnode === "boolean") {
188
- return null;
189
- }
190
- if (vnode instanceof Node) {
191
- return vnode;
192
- }
193
- if (isRenderFunction(vnode)) {
194
- const {
195
- type,
196
- props
197
- } = vnode;
198
- if (type === Fragment) {
199
- const node = document.createDocumentFragment();
200
- if (props.children) {
201
- const children = mountChildren(props.children, env);
202
- insertDom(node, children);
203
- }
204
- return node;
205
- }
206
- const childVNode = type(props);
207
- return mount(childVNode, env);
208
- }
209
- if (isLeaf(vnode)) {
210
- return document.createTextNode(`${vnode}`);
211
- }
212
- if (isElement(vnode)) {
213
- let node;
214
- const {
215
- type,
216
- props
217
- } = vnode;
218
- if (!env.isSvg && type === "svg") {
219
- env = Object.assign({}, env, {
220
- isSvg: true
221
- });
222
- }
223
- if (!env.isSvg) {
224
- node = document.createElement(type);
225
- } else {
226
- node = document.createElementNS(SVG_NS, type);
227
- }
228
- mountAttributes(node, props, env);
229
- if (props.children) {
230
- let childEnv = env;
231
- if (env.isSvg && type === "foreignObject") {
232
- childEnv = Object.assign({}, childEnv, {
233
- isSvg: false
234
- });
235
- }
236
- const children = mountChildren(props.children, childEnv);
237
- if (children != null) insertDom(node, children);
238
- }
239
- const {
240
- ref
241
- } = props;
242
- if (typeof ref === "function") ref(node);
243
- return node;
244
- }
245
- throw new Error("mount: Invalid Vnode!");
246
- }
247
- function mountDom(vnode) {
248
- return mount(vnode);
249
- }
250
- function hm(...args) {
251
- return mountDom(h(...args));
252
- }
253
- const memoizedPreloadJS = memoize((url) => {
254
- document.head.append(
255
- hm("link", {
256
- rel: "preload",
257
- as: "script",
258
- href: url
259
- })
260
- );
261
- });
262
- const jsCache = {};
263
- const cssCache = {};
264
- async function loadJSItem(item, context) {
265
- var _a;
266
- const src = item.type === "script" && ((_a = item.data) == null ? void 0 : _a.src) || "";
267
- item.loaded || (item.loaded = jsCache[src]);
268
- if (!item.loaded) {
269
- const deferred = defer();
270
- item.loaded = deferred.promise;
271
- if (item.type === "script") {
272
- document.head.append(
273
- hm("script", {
274
- ...item.data,
275
- onLoad: () => deferred.resolve(),
276
- onError: deferred.reject
277
- })
278
- );
279
- if (!src) {
280
- deferred.resolve();
281
- } else {
282
- jsCache[src] = item.loaded;
283
- }
284
- }
285
- if (item.type === "iife") {
286
- const { fn, getParams } = item.data;
287
- fn(...(getParams == null ? void 0 : getParams(context)) || []);
288
- deferred.resolve();
289
- }
290
- }
291
- await item.loaded;
292
- }
293
- async function loadCSSItem(item) {
294
- const url = item.type === "stylesheet" && item.data.href || "";
295
- item.loaded || (item.loaded = cssCache[url]);
296
- if (!item.loaded) {
297
- const deferred = defer();
298
- item.loaded = deferred.promise;
299
- if (url) cssCache[url] = item.loaded;
300
- if (item.type === "style") {
301
- document.head.append(
302
- hm("style", {
303
- textContent: item.data
304
- })
305
- );
306
- deferred.resolve();
307
- } else if (url) {
308
- document.head.append(
309
- hm("link", {
310
- rel: "stylesheet",
311
- ...item.data
312
- })
313
- );
314
- fetch(url).then((res) => {
315
- if (res.ok) return res.text();
316
- throw res;
317
- }).then(() => deferred.resolve(), deferred.reject);
318
- }
319
- }
320
- await item.loaded;
321
- }
322
- async function loadJS(items, context) {
323
- items.forEach((item) => {
324
- var _a;
325
- if (item.type === "script" && ((_a = item.data) == null ? void 0 : _a.src)) {
326
- memoizedPreloadJS(item.data.src);
327
- }
328
- });
329
- context = {
330
- getMarkmap: () => window.markmap,
331
- ...context
332
- };
333
- for (const item of items) {
334
- await loadJSItem(item, context);
335
- }
336
- }
337
- async function loadCSS(items) {
338
- await Promise.all(items.map((item) => loadCSSItem(item)));
339
- }
340
3
  const isMacintosh = typeof navigator !== "undefined" && navigator.userAgent.includes("Macintosh");
341
4
  const defaultColorFn = d32.scaleOrdinal(d32.schemeCategory10);
342
5
  const defaultOptions = {
@@ -530,14 +193,14 @@
530
193
  return links;
531
194
  }
532
195
  function hierarchy(data, children) {
533
- var root = new Node$1(data), valued = +data.value && (root.value = data.value), node, nodes = [root], child, childs, i, n;
196
+ var root = new Node(data), valued = +data.value && (root.value = data.value), node, nodes = [root], child, childs, i, n;
534
197
  if (children == null) children = defaultChildren;
535
198
  while (node = nodes.pop()) {
536
199
  if (valued) node.value = +node.data.value;
537
200
  if ((childs = children(node.data)) && (n = childs.length)) {
538
201
  node.children = new Array(n);
539
202
  for (i = n - 1; i >= 0; --i) {
540
- nodes.push(child = node.children[i] = new Node$1(childs[i]));
203
+ nodes.push(child = node.children[i] = new Node(childs[i]));
541
204
  child.parent = node;
542
205
  child.depth = node.depth + 1;
543
206
  }
@@ -560,13 +223,13 @@
560
223
  node.height = height;
561
224
  while ((node = node.parent) && node.height < ++height);
562
225
  }
563
- function Node$1(data) {
226
+ function Node(data) {
564
227
  this.data = data;
565
228
  this.depth = this.height = 0;
566
229
  this.parent = null;
567
230
  }
568
- Node$1.prototype = hierarchy.prototype = {
569
- constructor: Node$1,
231
+ Node.prototype = hierarchy.prototype = {
232
+ constructor: Node,
570
233
  count: node_count,
571
234
  each: node_each,
572
235
  eachAfter: node_eachAfter,
@@ -942,6 +605,86 @@
942
605
  next: lastLows
943
606
  };
944
607
  };
608
+ class Hook {
609
+ constructor() {
610
+ this.listeners = [];
611
+ }
612
+ tap(fn) {
613
+ this.listeners.push(fn);
614
+ return () => this.revoke(fn);
615
+ }
616
+ revoke(fn) {
617
+ const i = this.listeners.indexOf(fn);
618
+ if (i >= 0) this.listeners.splice(i, 1);
619
+ }
620
+ revokeAll() {
621
+ this.listeners.splice(0);
622
+ }
623
+ call(...args) {
624
+ for (const fn of this.listeners) {
625
+ fn(...args);
626
+ }
627
+ }
628
+ }
629
+ const uniqId = Math.random().toString(36).slice(2, 8);
630
+ let globalIndex = 0;
631
+ function getId() {
632
+ globalIndex += 1;
633
+ return `mm-${uniqId}-${globalIndex}`;
634
+ }
635
+ function noop() {
636
+ }
637
+ function walkTree(tree, callback) {
638
+ const walk = (item, parent) => callback(
639
+ item,
640
+ () => {
641
+ var _a;
642
+ return (_a = item.children) == null ? void 0 : _a.map((child) => walk(child, item));
643
+ },
644
+ parent
645
+ );
646
+ return walk(tree);
647
+ }
648
+ function addClass(className, ...rest) {
649
+ const classList = (className || "").split(" ").filter(Boolean);
650
+ rest.forEach((item) => {
651
+ if (item && classList.indexOf(item) < 0) classList.push(item);
652
+ });
653
+ return classList.join(" ");
654
+ }
655
+ function childSelector(filter) {
656
+ if (typeof filter === "string") {
657
+ const tagName = filter;
658
+ filter = (el) => el.tagName === tagName;
659
+ }
660
+ const filterFn = filter;
661
+ return function selector() {
662
+ let nodes = Array.from(this.childNodes);
663
+ if (filterFn) nodes = nodes.filter((node) => filterFn(node));
664
+ return nodes;
665
+ };
666
+ }
667
+ function debounce(fn, time) {
668
+ const state = {
669
+ timer: 0
670
+ };
671
+ function reset() {
672
+ if (state.timer) {
673
+ window.clearTimeout(state.timer);
674
+ state.timer = 0;
675
+ }
676
+ }
677
+ function run() {
678
+ reset();
679
+ if (state.args) state.result = fn(...state.args);
680
+ }
681
+ return function debounced(...args) {
682
+ reset();
683
+ state.args = args;
684
+ state.timer = window.setTimeout(run, time);
685
+ return state.result;
686
+ };
687
+ }
945
688
  const css = ".markmap {\n --markmap-max-width: 9999px;\n --markmap-a-color: #0097e6;\n --markmap-a-hover-color: #00a8ff;\n --markmap-code-bg: #f0f0f0;\n --markmap-code-color: #555;\n --markmap-highlight-bg: #ffeaa7;\n --markmap-table-border: 1px solid currentColor;\n --markmap-font: 300 16px/20px sans-serif;\n --markmap-circle-open-bg: #fff;\n --markmap-text-color: #333;\n\n font: var(--markmap-font);\n color: var(--markmap-text-color);\n}\n\n .markmap-link {\n fill: none;\n }\n\n .markmap-node > circle {\n cursor: pointer;\n }\n\n .markmap-foreign {\n display: inline-block;\n }\n\n .markmap-foreign p {\n margin: 0;\n }\n\n .markmap-foreign a {\n color: var(--markmap-a-color);\n }\n\n .markmap-foreign a:hover {\n color: var(--markmap-a-hover-color);\n }\n\n .markmap-foreign code {\n padding: 0.25em;\n font-size: calc(1em - 2px);\n color: var(--markmap-code-color);\n background-color: var(--markmap-code-bg);\n border-radius: 2px;\n }\n\n .markmap-foreign pre {\n margin: 0;\n }\n\n .markmap-foreign pre > code {\n display: block;\n }\n\n .markmap-foreign del {\n text-decoration: line-through;\n }\n\n .markmap-foreign em {\n font-style: italic;\n }\n\n .markmap-foreign strong {\n font-weight: bold;\n }\n\n .markmap-foreign mark {\n background: var(--markmap-highlight-bg);\n }\n\n .markmap-foreign table,\n .markmap-foreign th,\n .markmap-foreign td {\n border-collapse: collapse;\n border: var(--markmap-table-border);\n }\n\n .markmap-foreign img {\n display: inline-block;\n }\n\n .markmap-foreign svg {\n fill: currentColor;\n }\n\n .markmap-foreign > div {\n width: var(--markmap-max-width);\n text-align: left;\n }\n\n .markmap-foreign > div > div {\n display: inline-block;\n }\n\n.markmap-dark .markmap {\n --markmap-code-bg: #1a1b26;\n --markmap-code-color: #ddd;\n --markmap-circle-open-bg: #444;\n --markmap-text-color: #eee;\n}\n";
946
689
  const globalCSS = css;
947
690
  const linkShape = d32.linkHorizontal();
@@ -1441,8 +1184,6 @@
1441
1184
  exports.deriveOptions = deriveOptions;
1442
1185
  exports.globalCSS = globalCSS;
1443
1186
  exports.isMacintosh = isMacintosh;
1444
- exports.loadCSS = loadCSS;
1445
- exports.loadJS = loadJS;
1446
1187
  exports.refreshHook = refreshHook;
1447
1188
  exports.simpleHash = simpleHash;
1448
1189
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export { loadJS, loadCSS } from 'markmap-common';
2
1
  export * from './types';
3
2
  export * from './constants';
4
3
  export * from './util';
package/dist/index.js CHANGED
@@ -1,7 +1,6 @@
1
- import { Hook as at, getId as lt, debounce as ct, addClass as ht, walkTree as C, childSelector as v, noop as w } from "markmap-common";
2
- import { loadCSS as xe, loadJS as ye } from "markmap-common";
3
- import { scaleOrdinal as G, schemeCategory10 as dt, linkHorizontal as pt, zoomTransform as S, select as ut, zoom as mt, min as P, max as W, zoomIdentity as gt, minIndex as ft } from "d3";
4
- const V = typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), xt = G(dt), U = {
1
+ import { scaleOrdinal as G, schemeCategory10 as at, linkHorizontal as lt, zoomTransform as w, select as ct, zoom as ht, min as P, max as W, zoomIdentity as dt, minIndex as pt } from "d3";
2
+ import { Hook as ut, getId as mt, debounce as gt, addClass as ft, walkTree as C, childSelector as v, noop as S } from "markmap-common";
3
+ const V = typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), xt = G(at), U = {
5
4
  autoFit: !1,
6
5
  color: (e) => {
7
6
  var t;
@@ -97,13 +96,13 @@ function Et(e) {
97
96
  e(t);
98
97
  return this;
99
98
  }
100
- function Ct(e) {
99
+ function wt(e) {
101
100
  return this.eachAfter(function(t) {
102
101
  for (var s = +e(t.data) || 0, n = t.children, o = n && n.length; --o >= 0; ) s += n[o].value;
103
102
  t.value = s;
104
103
  });
105
104
  }
106
- function wt(e) {
105
+ function Ct(e) {
107
106
  return this.eachBefore(function(t) {
108
107
  t.children && t.children.sort(e);
109
108
  });
@@ -177,8 +176,8 @@ R.prototype = B.prototype = {
177
176
  each: bt,
178
177
  eachAfter: Et,
179
178
  eachBefore: zt,
180
- sum: Ct,
181
- sort: wt,
179
+ sum: wt,
180
+ sort: Ct,
182
181
  path: St,
183
182
  ancestors: Xt,
184
183
  descendants: Mt,
@@ -447,18 +446,18 @@ const q = (e, t = 0) => (e.y = t, (e.children || []).reduce((s, n) => {
447
446
  index: t,
448
447
  next: s
449
448
  };
450
- }, Q = ".markmap{--markmap-max-width: 9999px;--markmap-a-color: #0097e6;--markmap-a-hover-color: #00a8ff;--markmap-code-bg: #f0f0f0;--markmap-code-color: #555;--markmap-highlight-bg: #ffeaa7;--markmap-table-border: 1px solid currentColor;--markmap-font: 300 16px/20px sans-serif;--markmap-circle-open-bg: #fff;--markmap-text-color: #333;font:var(--markmap-font);color:var(--markmap-text-color)}.markmap-link{fill:none}.markmap-node>circle{cursor:pointer}.markmap-foreign{display:inline-block}.markmap-foreign p{margin:0}.markmap-foreign a{color:var(--markmap-a-color)}.markmap-foreign a:hover{color:var(--markmap-a-hover-color)}.markmap-foreign code{padding:.25em;font-size:calc(1em - 2px);color:var(--markmap-code-color);background-color:var(--markmap-code-bg);border-radius:2px}.markmap-foreign pre{margin:0}.markmap-foreign pre>code{display:block}.markmap-foreign del{text-decoration:line-through}.markmap-foreign em{font-style:italic}.markmap-foreign strong{font-weight:700}.markmap-foreign mark{background:var(--markmap-highlight-bg)}.markmap-foreign table,.markmap-foreign th,.markmap-foreign td{border-collapse:collapse;border:var(--markmap-table-border)}.markmap-foreign img{display:inline-block}.markmap-foreign svg{fill:currentColor}.markmap-foreign>div{width:var(--markmap-max-width);text-align:left}.markmap-foreign>div>div{display:inline-block}.markmap-dark .markmap{--markmap-code-bg: #1a1b26;--markmap-code-color: #ddd;--markmap-circle-open-bg: #444;--markmap-text-color: #eee}", me = Q, j = pt();
449
+ }, Q = ".markmap{--markmap-max-width: 9999px;--markmap-a-color: #0097e6;--markmap-a-hover-color: #00a8ff;--markmap-code-bg: #f0f0f0;--markmap-code-color: #555;--markmap-highlight-bg: #ffeaa7;--markmap-table-border: 1px solid currentColor;--markmap-font: 300 16px/20px sans-serif;--markmap-circle-open-bg: #fff;--markmap-text-color: #333;font:var(--markmap-font);color:var(--markmap-text-color)}.markmap-link{fill:none}.markmap-node>circle{cursor:pointer}.markmap-foreign{display:inline-block}.markmap-foreign p{margin:0}.markmap-foreign a{color:var(--markmap-a-color)}.markmap-foreign a:hover{color:var(--markmap-a-hover-color)}.markmap-foreign code{padding:.25em;font-size:calc(1em - 2px);color:var(--markmap-code-color);background-color:var(--markmap-code-bg);border-radius:2px}.markmap-foreign pre{margin:0}.markmap-foreign pre>code{display:block}.markmap-foreign del{text-decoration:line-through}.markmap-foreign em{font-style:italic}.markmap-foreign strong{font-weight:700}.markmap-foreign mark{background:var(--markmap-highlight-bg)}.markmap-foreign table,.markmap-foreign th,.markmap-foreign td{border-collapse:collapse;border:var(--markmap-table-border)}.markmap-foreign img{display:inline-block}.markmap-foreign svg{fill:currentColor}.markmap-foreign>div{width:var(--markmap-max-width);text-align:left}.markmap-foreign>div>div{display:inline-block}.markmap-dark .markmap{--markmap-code-bg: #1a1b26;--markmap-code-color: #ddd;--markmap-circle-open-bg: #444;--markmap-text-color: #eee}", me = Q, j = lt();
451
450
  function I(e) {
452
451
  return Math.max(4 - 2 * e.state.depth, 1.5);
453
452
  }
454
453
  function K(e, t) {
455
- const s = ft(e, t);
454
+ const s = pt(e, t);
456
455
  return e[s];
457
456
  }
458
457
  function O(e) {
459
458
  e.stopPropagation();
460
459
  }
461
- const le = new at();
460
+ const le = new ut();
462
461
  class tt {
463
462
  constructor(t, s) {
464
463
  this.options = U, this.revokers = [], this.handleZoom = (n) => {
@@ -466,7 +465,7 @@ class tt {
466
465
  this.g.attr("transform", o);
467
466
  }, this.handlePan = (n) => {
468
467
  n.preventDefault();
469
- const o = S(this.svg.node()), a = o.translate(
468
+ const o = w(this.svg.node()), a = o.translate(
470
469
  -n.deltaX / o.k,
471
470
  -n.deltaY / o.k
472
471
  );
@@ -474,11 +473,11 @@ class tt {
474
473
  }, this.handleClick = (n, o) => {
475
474
  let a = this.options.toggleRecursively;
476
475
  (V ? n.metaKey : n.ctrlKey) && (a = !a), this.toggleNode(o, a);
477
- }, this.ensureView = this.ensureVisible, this.svg = t.datum ? t : ut(t), this.styleNode = this.svg.append("style"), this.zoom = mt().filter((n) => this.options.scrollForPan && n.type === "wheel" ? n.ctrlKey && !n.button : (!n.ctrlKey || n.type === "wheel") && !n.button).on("zoom", this.handleZoom), this.setOptions(s), this.state = {
478
- id: this.options.id || this.svg.attr("id") || lt(),
476
+ }, this.ensureView = this.ensureVisible, this.svg = t.datum ? t : ct(t), this.styleNode = this.svg.append("style"), this.zoom = ht().filter((n) => this.options.scrollForPan && n.type === "wheel" ? n.ctrlKey && !n.button : (!n.ctrlKey || n.type === "wheel") && !n.button).on("zoom", this.handleZoom), this.setOptions(s), this.state = {
477
+ id: this.options.id || this.svg.attr("id") || mt(),
479
478
  rect: { x1: 0, y1: 0, x2: 0, y2: 0 }
480
479
  }, this.g = this.svg.append("g"), this.observer = new ResizeObserver(
481
- ct(() => {
480
+ gt(() => {
482
481
  this.renderData();
483
482
  }, 100)
484
483
  ), this.revokers.push(
@@ -496,7 +495,7 @@ class tt {
496
495
  updateStyle() {
497
496
  this.svg.attr(
498
497
  "class",
499
- ht(this.svg.attr("class"), "markmap", this.state.id)
498
+ ft(this.svg.attr("class"), "markmap", this.state.id)
500
499
  );
501
500
  const t = this.getStyleContent();
502
501
  this.styleNode.text(t);
@@ -703,11 +702,11 @@ class tt {
703
702
  n / h * a,
704
703
  o / u * a,
705
704
  t
706
- ), g = gt.translate(
705
+ ), g = dt.translate(
707
706
  (n - h * m) / 2 - l * m,
708
707
  (o - u * m) / 2 - r * m
709
708
  ).scale(m);
710
- return this.transition(this.svg).call(this.zoom.transform, g).end().catch(w);
709
+ return this.transition(this.svg).call(this.zoom.transform, g).end().catch(S);
711
710
  }
712
711
  findElement(t) {
713
712
  let s;
@@ -725,7 +724,7 @@ class tt {
725
724
  var b;
726
725
  const n = (b = this.findElement(t)) == null ? void 0 : b.data;
727
726
  if (!n) return;
728
- const o = this.svg.node(), a = o.getBoundingClientRect(), l = S(o), [r, c] = [
727
+ const o = this.svg.node(), a = o.getBoundingClientRect(), l = w(o), [r, c] = [
729
728
  n.state.rect.x,
730
729
  n.state.rect.x + n.state.rect.width + 2
731
730
  ].map((k) => k * l.k + l.x), [p, h] = [
@@ -740,14 +739,14 @@ class tt {
740
739
  }, m = [u.left - r, a.width - u.right - c], g = [u.top - p, a.height - u.bottom - h], y = m[0] * m[1] > 0 ? K(m, Math.abs) / l.k : 0, x = g[0] * g[1] > 0 ? K(g, Math.abs) / l.k : 0;
741
740
  if (y || x) {
742
741
  const k = l.translate(y, x);
743
- return this.transition(this.svg).call(this.zoom.transform, k).end().catch(w);
742
+ return this.transition(this.svg).call(this.zoom.transform, k).end().catch(S);
744
743
  }
745
744
  }
746
745
  async centerNode(t, s) {
747
746
  var y;
748
747
  const n = (y = this.findElement(t)) == null ? void 0 : y.data;
749
748
  if (!n) return;
750
- const o = this.svg.node(), a = o.getBoundingClientRect(), l = S(o), r = (n.state.rect.x + n.state.rect.width / 2) * l.k + l.x, c = (n.state.rect.y + n.state.rect.height / 2) * l.k + l.y, p = {
749
+ const o = this.svg.node(), a = o.getBoundingClientRect(), l = w(o), r = (n.state.rect.x + n.state.rect.width / 2) * l.k + l.x, c = (n.state.rect.y + n.state.rect.height / 2) * l.k + l.y, p = {
751
750
  left: 0,
752
751
  right: 0,
753
752
  top: 0,
@@ -756,18 +755,18 @@ class tt {
756
755
  }, h = (p.left + a.width - p.right) / 2, u = (p.top + a.height - p.bottom) / 2, m = (h - r) / l.k, g = (u - c) / l.k;
757
756
  if (m || g) {
758
757
  const x = l.translate(m, g);
759
- return this.transition(this.svg).call(this.zoom.transform, x).end().catch(w);
758
+ return this.transition(this.svg).call(this.zoom.transform, x).end().catch(S);
760
759
  }
761
760
  }
762
761
  /**
763
762
  * Scale content with it pinned at the center of the viewport.
764
763
  */
765
764
  async rescale(t) {
766
- const s = this.svg.node(), { width: n, height: o } = s.getBoundingClientRect(), a = n / 2, l = o / 2, r = S(s), c = r.translate(
765
+ const s = this.svg.node(), { width: n, height: o } = s.getBoundingClientRect(), a = n / 2, l = o / 2, r = w(s), c = r.translate(
767
766
  (a - r.x) * (1 - t) / r.k,
768
767
  (l - r.y) * (1 - t) / r.k
769
768
  ).scale(t);
770
- return this.transition(this.svg).call(this.zoom.transform, c).end().catch(w);
769
+ return this.transition(this.svg).call(this.zoom.transform, c).end().catch(S);
771
770
  }
772
771
  destroy() {
773
772
  this.svg.on(".zoom", null), this.svg.html(null), this.revokers.forEach((t) => {
@@ -788,8 +787,6 @@ export {
788
787
  ue as deriveOptions,
789
788
  me as globalCSS,
790
789
  V as isMacintosh,
791
- xe as loadCSS,
792
- ye as loadJS,
793
790
  le as refreshHook,
794
791
  yt as simpleHash
795
792
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markmap-view",
3
- "version": "0.18.4-alpha.3+be73b69",
3
+ "version": "0.18.4-alpha.4+8f90d3c",
4
4
  "description": "View markmaps in browser",
5
5
  "author": "Gerald <gera2ld@live.com>",
6
6
  "license": "MIT",
@@ -51,5 +51,5 @@
51
51
  "peerDependencies": {
52
52
  "markmap-common": "*"
53
53
  },
54
- "gitHead": "be73b698cdf408b0a16aea2fe860fe92d8c458bc"
54
+ "gitHead": "8f90d3cef5816b56ad80fc1db35caea8df330789"
55
55
  }