markmap-view 0.15.0-alpha.0 → 0.15.3-alpha.1

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,21 +1,70 @@
1
- /*! markmap-view v0.15.0-alpha.0 | MIT License */
1
+ /*! markmap-view v0.15.3-alpha.1+fb5e189 | MIT License */
2
2
  (function (exports, d3) {
3
3
  'use strict';
4
4
 
5
- function _interopNamespaceDefault(e) {
6
- var n = Object.create(null);
7
- if (e) {
8
- for (var k in e) {
9
- n[k] = e[k];
10
- }
5
+ /*! markmap-common v0.15.3-alpha.1+fb5e189 | MIT License */
6
+ function _extends$1() {
7
+ _extends$1 = Object.assign ? Object.assign.bind() : function (target) {
8
+ for (var i = 1; i < arguments.length; i++) {
9
+ var source = arguments[i];
10
+ for (var key in source) {
11
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
12
+ target[key] = source[key];
13
+ }
14
+ }
15
+ }
16
+ return target;
17
+ };
18
+ return _extends$1.apply(this, arguments);
11
19
  }
12
- n.default = e;
13
- return Object.freeze(n);
20
+ const testPath = "npm2url/dist/index.cjs";
21
+ const defaultProviders = {
22
+ jsdelivr: path => `https://cdn.jsdelivr.net/npm/${path}`,
23
+ unpkg: path => `https://unpkg.com/${path}`
24
+ };
25
+ class UrlBuilder {
26
+ constructor() {
27
+ this.providers = _extends$1({}, defaultProviders);
28
+ this.provider = "jsdelivr";
29
+ }
30
+ getFastestProvider(timeout = 5e3, path = testPath) {
31
+ return new Promise((resolve, reject) => {
32
+ Promise.all(Object.entries(this.providers).map(async ([name, factory]) => {
33
+ try {
34
+ const res = await fetch(factory(path));
35
+ if (!res.ok) {
36
+ throw res;
37
+ }
38
+ await res.text();
39
+ resolve(name);
40
+ } catch (_unused) {}
41
+ })).then(() => reject(new Error("All providers failed")));
42
+ setTimeout(reject, timeout, new Error("Timed out"));
43
+ });
44
+ }
45
+ async findFastestProvider(timeout) {
46
+ this.provider = await this.getFastestProvider(timeout);
47
+ return this.provider;
48
+ }
49
+ setProvider(name, factory) {
50
+ if (factory) {
51
+ this.providers[name] = factory;
52
+ } else {
53
+ delete this.providers[name];
54
+ }
55
+ }
56
+ getFullUrl(path, provider = this.provider) {
57
+ if (path.includes("://")) {
58
+ return path;
59
+ }
60
+ const factory = this.providers[provider];
61
+ if (!factory) {
62
+ throw new Error(`Provider ${provider} not found`);
63
+ }
64
+ return factory(path);
65
+ }
14
66
  }
15
-
16
- var d3__namespace = /*#__PURE__*/_interopNamespaceDefault(d3);
17
-
18
- /*! markmap-common v0.15.0-alpha.0 | MIT License */
67
+ new UrlBuilder();
19
68
  class Hook {
20
69
  constructor() {
21
70
  this.listeners = [];
@@ -37,20 +86,6 @@ class Hook {
37
86
  }
38
87
  }
39
88
  }
40
- function _extends$1() {
41
- _extends$1 = Object.assign ? Object.assign.bind() : function (target) {
42
- for (var i = 1; i < arguments.length; i++) {
43
- var source = arguments[i];
44
- for (var key in source) {
45
- if (Object.prototype.hasOwnProperty.call(source, key)) {
46
- target[key] = source[key];
47
- }
48
- }
49
- }
50
- return target;
51
- };
52
- return _extends$1.apply(this, arguments);
53
- }
54
89
  const uniqId = Math.random().toString(36).slice(2, 8);
55
90
  let globalIndex = 0;
56
91
  function getId() {
@@ -60,10 +95,10 @@ function getId() {
60
95
  function noop() {
61
96
  // noop
62
97
  }
63
- function walkTree(tree, callback, key = 'children') {
98
+ function walkTree(tree, callback) {
64
99
  const walk = (item, parent) => callback(item, () => {
65
- var _item$key;
66
- (_item$key = item[key]) == null ? void 0 : _item$key.forEach(child => {
100
+ var _item$children;
101
+ (_item$children = item.children) == null ? void 0 : _item$children.forEach(child => {
67
102
  walk(child, item);
68
103
  });
69
104
  }, parent);
@@ -102,41 +137,189 @@ function memoize(fn) {
102
137
  return data.value;
103
138
  };
104
139
  }
105
- function createElement(tagName, props, attrs) {
106
- const el = document.createElement(tagName);
107
- if (props) {
108
- Object.entries(props).forEach(([key, value]) => {
109
- el[key] = value;
110
- });
140
+
141
+ /*! @gera2ld/jsx-dom v2.2.2 | ISC License */
142
+ const VTYPE_ELEMENT$1 = 1;
143
+ const VTYPE_FUNCTION$1 = 2;
144
+ const SVG_NS$1 = 'http://www.w3.org/2000/svg';
145
+ const XLINK_NS$1 = 'http://www.w3.org/1999/xlink';
146
+ const NS_ATTRS$1 = {
147
+ show: XLINK_NS$1,
148
+ actuate: XLINK_NS$1,
149
+ href: XLINK_NS$1
150
+ };
151
+ const isLeaf$1 = c => typeof c === 'string' || typeof c === 'number';
152
+ const isElement$1 = c => (c == null ? void 0 : c.vtype) === VTYPE_ELEMENT$1;
153
+ const isRenderFunction$1 = c => (c == null ? void 0 : c.vtype) === VTYPE_FUNCTION$1;
154
+ function h(type, props, ...children) {
155
+ props = Object.assign({}, props, {
156
+ children: children.length === 1 ? children[0] : children
157
+ });
158
+ return jsx$1(type, props);
159
+ }
160
+ function jsx$1(type, props) {
161
+ let vtype;
162
+ if (typeof type === 'string') vtype = VTYPE_ELEMENT$1;else if (typeof type === 'function') vtype = VTYPE_FUNCTION$1;else throw new Error('Invalid VNode type');
163
+ return {
164
+ vtype,
165
+ type,
166
+ props
167
+ };
168
+ }
169
+ function Fragment$1(props) {
170
+ return props.children;
171
+ }
172
+ const DEFAULT_ENV$1 = {
173
+ isSvg: false
174
+ };
175
+ function insertDom$1(parent, nodes) {
176
+ if (!Array.isArray(nodes)) nodes = [nodes];
177
+ nodes = nodes.filter(Boolean);
178
+ if (nodes.length) parent.append(...nodes);
179
+ }
180
+ function mountAttributes$1(domElement, props, env) {
181
+ for (const key in props) {
182
+ if (key === 'key' || key === 'children' || key === 'ref') continue;
183
+ if (key === 'dangerouslySetInnerHTML') {
184
+ domElement.innerHTML = props[key].__html;
185
+ } else if (key === 'innerHTML' || key === 'textContent' || key === 'innerText' || key === 'value' && ['textarea', 'select'].includes(domElement.tagName)) {
186
+ const value = props[key];
187
+ if (value != null) domElement[key] = value;
188
+ } else if (key.startsWith('on')) {
189
+ domElement[key.toLowerCase()] = props[key];
190
+ } else {
191
+ setDOMAttribute$1(domElement, key, props[key], env.isSvg);
192
+ }
111
193
  }
112
- if (attrs) {
113
- Object.entries(attrs).forEach(([key, value]) => {
114
- el.setAttribute(key, value);
115
- });
194
+ }
195
+ const attrMap$1 = {
196
+ className: 'class',
197
+ labelFor: 'for'
198
+ };
199
+ function setDOMAttribute$1(el, attr, value, isSVG) {
200
+ attr = attrMap$1[attr] || attr;
201
+ if (value === true) {
202
+ el.setAttribute(attr, '');
203
+ } else if (value === false) {
204
+ el.removeAttribute(attr);
205
+ } else {
206
+ const namespace = isSVG ? NS_ATTRS$1[attr] : undefined;
207
+ if (namespace !== undefined) {
208
+ el.setAttributeNS(namespace, attr, value);
209
+ } else {
210
+ el.setAttribute(attr, value);
211
+ }
116
212
  }
117
- return el;
213
+ }
214
+ function flatten$1(arr) {
215
+ return arr.reduce((prev, item) => prev.concat(item), []);
216
+ }
217
+ function mountChildren$1(children, env) {
218
+ return Array.isArray(children) ? flatten$1(children.map(child => mountChildren$1(child, env))) : mount$1(children, env);
219
+ }
220
+ function mount$1(vnode, env = DEFAULT_ENV$1) {
221
+ if (vnode == null || typeof vnode === 'boolean') {
222
+ return null;
223
+ }
224
+ if (vnode instanceof Node) {
225
+ return vnode;
226
+ }
227
+ if (isRenderFunction$1(vnode)) {
228
+ const {
229
+ type,
230
+ props
231
+ } = vnode;
232
+ if (type === Fragment$1) {
233
+ const node = document.createDocumentFragment();
234
+ if (props.children) {
235
+ const children = mountChildren$1(props.children, env);
236
+ insertDom$1(node, children);
237
+ }
238
+ return node;
239
+ }
240
+ const childVNode = type(props);
241
+ return mount$1(childVNode, env);
242
+ }
243
+ if (isLeaf$1(vnode)) {
244
+ return document.createTextNode(`${vnode}`);
245
+ }
246
+ if (isElement$1(vnode)) {
247
+ let node;
248
+ const {
249
+ type,
250
+ props
251
+ } = vnode;
252
+ if (!env.isSvg && type === 'svg') {
253
+ env = Object.assign({}, env, {
254
+ isSvg: true
255
+ });
256
+ }
257
+ if (!env.isSvg) {
258
+ node = document.createElement(type);
259
+ } else {
260
+ node = document.createElementNS(SVG_NS$1, type);
261
+ }
262
+ mountAttributes$1(node, props, env);
263
+ if (props.children) {
264
+ let childEnv = env;
265
+ if (env.isSvg && type === 'foreignObject') {
266
+ childEnv = Object.assign({}, childEnv, {
267
+ isSvg: false
268
+ });
269
+ }
270
+ const children = mountChildren$1(props.children, childEnv);
271
+ if (children != null) insertDom$1(node, children);
272
+ }
273
+ const {
274
+ ref
275
+ } = props;
276
+ if (typeof ref === 'function') ref(node);
277
+ return node;
278
+ }
279
+ throw new Error('mount: Invalid Vnode!');
280
+ }
281
+
282
+ /**
283
+ * Mount vdom as real DOM nodes.
284
+ */
285
+ function mountDom$1(vnode) {
286
+ return mount$1(vnode);
287
+ }
288
+
289
+ /**
290
+ * Render and mount without returning VirtualDOM, useful when you don't need SVG support.
291
+ */
292
+ function hm(...args) {
293
+ return mountDom$1(h(...args));
118
294
  }
119
295
  const memoizedPreloadJS = memoize(url => {
120
- document.head.append(createElement('link', {
296
+ document.head.append(hm('link', {
121
297
  rel: 'preload',
122
298
  as: 'script',
123
299
  href: url
124
300
  }));
125
301
  });
302
+ const jsCache = {};
303
+ const cssCache = {};
126
304
  async function loadJSItem(item, context) {
305
+ var _item$data;
306
+ const src = item.type === 'script' && ((_item$data = item.data) == null ? void 0 : _item$data.src) || '';
307
+ item.loaded || (item.loaded = jsCache[src]);
127
308
  if (!item.loaded) {
128
309
  if (item.type === 'script') {
129
310
  item.loaded = new Promise((resolve, reject) => {
130
- var _item$data;
131
- document.head.append(createElement('script', _extends$1({}, item.data, {
132
- onload: resolve,
133
- onerror: reject
311
+ document.head.append(hm('script', _extends$1({}, item.data, {
312
+ onLoad: resolve,
313
+ onError: reject
134
314
  })));
135
- // Run inline script synchronously
136
- if (!((_item$data = item.data) != null && _item$data.src)) resolve(undefined);
315
+ if (!src) {
316
+ // Run inline script synchronously
317
+ resolve(undefined);
318
+ }
137
319
  }).then(() => {
138
320
  item.loaded = true;
139
321
  });
322
+ if (src) jsCache[src] = item.loaded;
140
323
  }
141
324
  if (item.type === 'iife') {
142
325
  const {
@@ -150,24 +333,28 @@ async function loadJSItem(item, context) {
150
333
  await item.loaded;
151
334
  }
152
335
  function loadCSSItem(item) {
336
+ const url = item.type === 'stylesheet' && item.data.href || '';
337
+ item.loaded || (item.loaded = cssCache[url]);
153
338
  if (item.loaded) return;
154
339
  item.loaded = true;
340
+ if (url) cssCache[url] = true;
155
341
  if (item.type === 'style') {
156
- document.head.append(createElement('style', {
342
+ document.head.append(hm('style', {
157
343
  textContent: item.data
158
344
  }));
159
345
  } else if (item.type === 'stylesheet') {
160
- document.head.append(createElement('link', _extends$1({
346
+ document.head.append(hm('link', _extends$1({
161
347
  rel: 'stylesheet'
162
348
  }, item.data)));
163
349
  }
164
350
  }
165
351
  async function loadJS(items, context) {
166
- const needPreload = items.filter(item => {
352
+ items.forEach(item => {
167
353
  var _item$data2;
168
- return item.type === 'script' && ((_item$data2 = item.data) == null ? void 0 : _item$data2.src);
354
+ if (item.type === 'script' && (_item$data2 = item.data) != null && _item$data2.src) {
355
+ memoizedPreloadJS(item.data.src);
356
+ }
169
357
  });
170
- if (needPreload.length > 1) needPreload.forEach(item => memoizedPreloadJS(item.data.src));
171
358
  context = _extends$1({
172
359
  getMarkmap: () => window.markmap
173
360
  }, context);
@@ -406,8 +593,87 @@ Node$1.prototype = hierarchy.prototype = {
406
593
  copy: node_copy
407
594
  };
408
595
 
409
- var version = "2.1.1";
596
+ var name = "d3-flextree";
597
+ var version$1 = "2.1.2";
598
+ var main = "build/d3-flextree.js";
599
+ var module = "index";
600
+ var author = {
601
+ name: "Chris Maloney",
602
+ url: "http://chrismaloney.org"
603
+ };
604
+ var description = "Flexible tree layout algorithm that allows for variable node sizes.";
605
+ var keywords = [
606
+ "d3",
607
+ "d3-module",
608
+ "layout",
609
+ "tree",
610
+ "hierarchy",
611
+ "d3-hierarchy",
612
+ "plugin",
613
+ "d3-plugin",
614
+ "infovis",
615
+ "visualization",
616
+ "2d"
617
+ ];
618
+ var homepage = "https://github.com/klortho/d3-flextree";
619
+ var license = "WTFPL";
620
+ var repository = {
621
+ type: "git",
622
+ url: "https://github.com/klortho/d3-flextree.git"
623
+ };
624
+ var scripts = {
625
+ clean: "rm -rf build demo test",
626
+ "build:demo": "rollup -c --environment BUILD:demo",
627
+ "build:dev": "rollup -c --environment BUILD:dev",
628
+ "build:prod": "rollup -c --environment BUILD:prod",
629
+ "build:test": "rollup -c --environment BUILD:test",
630
+ build: "rollup -c",
631
+ lint: "eslint index.js src",
632
+ "test:main": "node test/bundle.js",
633
+ "test:browser": "node test/browser-tests.js",
634
+ test: "npm-run-all test:*",
635
+ prepare: "npm-run-all clean build lint test"
636
+ };
637
+ var dependencies = {
638
+ "d3-hierarchy": "^1.1.5"
639
+ };
640
+ var devDependencies = {
641
+ "babel-plugin-external-helpers": "^6.22.0",
642
+ "babel-preset-es2015-rollup": "^3.0.0",
643
+ d3: "^4.13.0",
644
+ "d3-selection-multi": "^1.0.1",
645
+ eslint: "^4.19.1",
646
+ jsdom: "^11.6.2",
647
+ "npm-run-all": "^4.1.2",
648
+ rollup: "^0.55.3",
649
+ "rollup-plugin-babel": "^2.7.1",
650
+ "rollup-plugin-commonjs": "^8.0.2",
651
+ "rollup-plugin-copy": "^0.2.3",
652
+ "rollup-plugin-json": "^2.3.0",
653
+ "rollup-plugin-node-resolve": "^3.0.2",
654
+ "rollup-plugin-uglify": "^3.0.0",
655
+ "uglify-es": "^3.3.9"
656
+ };
657
+ var packageInfo = {
658
+ name: name,
659
+ version: version$1,
660
+ main: main,
661
+ module: module,
662
+ "jsnext:main": "index",
663
+ author: author,
664
+ description: description,
665
+ keywords: keywords,
666
+ homepage: homepage,
667
+ license: license,
668
+ repository: repository,
669
+ scripts: scripts,
670
+ dependencies: dependencies,
671
+ devDependencies: devDependencies
672
+ };
410
673
 
674
+ const {
675
+ version
676
+ } = packageInfo;
411
677
  const defaults = Object.freeze({
412
678
  children: data => data.children,
413
679
  nodeSize: node => node.data.size,
@@ -781,60 +1047,47 @@ const updateLows = (lowY, index, lastLows) => {
781
1047
  };
782
1048
  };
783
1049
 
784
- /*! @gera2ld/jsx-dom v2.1.1 | ISC License */
785
- var VTYPE_ELEMENT = 1;
786
- var VTYPE_FUNCTION = 2;
787
- var MOUNT_SINGLE = 1;
788
- var MOUNT_ARRAY = 4;
789
- var SVG_NS = 'http://www.w3.org/2000/svg';
790
- var XLINK_NS = 'http://www.w3.org/1999/xlink';
791
- var NS_ATTRS = {
1050
+ /*! @gera2ld/jsx-dom v2.2.2 | ISC License */
1051
+ const VTYPE_ELEMENT = 1;
1052
+ const VTYPE_FUNCTION = 2;
1053
+ const SVG_NS = 'http://www.w3.org/2000/svg';
1054
+ const XLINK_NS = 'http://www.w3.org/1999/xlink';
1055
+ const NS_ATTRS = {
792
1056
  show: XLINK_NS,
793
1057
  actuate: XLINK_NS,
794
1058
  href: XLINK_NS
795
1059
  };
796
- var isLeaf = function isLeaf(c) {
797
- return typeof c === 'string' || typeof c === 'number';
798
- };
799
- var isElement = function isElement(c) {
800
- return (c == null ? void 0 : c.vtype) === VTYPE_ELEMENT;
801
- };
802
- var isRenderFunction = function isRenderFunction(c) {
803
- return (c == null ? void 0 : c.vtype) === VTYPE_FUNCTION;
804
- };
1060
+ const isLeaf = c => typeof c === 'string' || typeof c === 'number';
1061
+ const isElement = c => (c == null ? void 0 : c.vtype) === VTYPE_ELEMENT;
1062
+ const isRenderFunction = c => (c == null ? void 0 : c.vtype) === VTYPE_FUNCTION;
805
1063
  function jsx(type, props) {
806
- var vtype;
1064
+ let vtype;
807
1065
  if (typeof type === 'string') vtype = VTYPE_ELEMENT;else if (typeof type === 'function') vtype = VTYPE_FUNCTION;else throw new Error('Invalid VNode type');
808
1066
  return {
809
- vtype: vtype,
810
- type: type,
811
- props: props
1067
+ vtype,
1068
+ type,
1069
+ props
812
1070
  };
813
1071
  }
814
1072
  function Fragment(props) {
815
1073
  return props.children;
816
1074
  }
817
- var DEFAULT_ENV = {
1075
+ const DEFAULT_ENV = {
818
1076
  isSvg: false
819
1077
  };
820
- function insertDom(parent, ref) {
821
- if (ref.type === MOUNT_SINGLE) {
822
- if (ref.node != null) parent.append(ref.node);
823
- } else if (ref.type === MOUNT_ARRAY) {
824
- ref.children.forEach(function (ch) {
825
- insertDom(parent, ch);
826
- });
827
- } else {
828
- throw new Error("Unkown ref type " + JSON.stringify(ref));
829
- }
1078
+ function insertDom(parent, nodes) {
1079
+ if (!Array.isArray(nodes)) nodes = [nodes];
1080
+ nodes = nodes.filter(Boolean);
1081
+ if (nodes.length) parent.append(...nodes);
830
1082
  }
831
1083
  function mountAttributes(domElement, props, env) {
832
- for (var key in props) {
1084
+ for (const key in props) {
833
1085
  if (key === 'key' || key === 'children' || key === 'ref') continue;
834
1086
  if (key === 'dangerouslySetInnerHTML') {
835
1087
  domElement.innerHTML = props[key].__html;
836
- } else if (key === 'innerHTML' || key === 'textContent' || key === 'innerText') {
837
- domElement[key] = props[key];
1088
+ } else if (key === 'innerHTML' || key === 'textContent' || key === 'innerText' || key === 'value' && ['textarea', 'select'].includes(domElement.tagName)) {
1089
+ const value = props[key];
1090
+ if (value != null) domElement[key] = value;
838
1091
  } else if (key.startsWith('on')) {
839
1092
  domElement[key.toLowerCase()] = props[key];
840
1093
  } else {
@@ -842,7 +1095,7 @@ function mountAttributes(domElement, props, env) {
842
1095
  }
843
1096
  }
844
1097
  }
845
- var attrMap = {
1098
+ const attrMap = {
846
1099
  className: 'class',
847
1100
  labelFor: 'for'
848
1101
  };
@@ -853,7 +1106,7 @@ function setDOMAttribute(el, attr, value, isSVG) {
853
1106
  } else if (value === false) {
854
1107
  el.removeAttribute(attr);
855
1108
  } else {
856
- var namespace = isSVG ? NS_ATTRS[attr] : undefined;
1109
+ const namespace = isSVG ? NS_ATTRS[attr] : undefined;
857
1110
  if (namespace !== undefined) {
858
1111
  el.setAttributeNS(namespace, attr, value);
859
1112
  } else {
@@ -861,116 +1114,82 @@ function setDOMAttribute(el, attr, value, isSVG) {
861
1114
  }
862
1115
  }
863
1116
  }
864
- function mount(vnode, env) {
865
- if (env === void 0) {
866
- env = DEFAULT_ENV;
867
- }
1117
+ function flatten(arr) {
1118
+ return arr.reduce((prev, item) => prev.concat(item), []);
1119
+ }
1120
+ function mountChildren(children, env) {
1121
+ return Array.isArray(children) ? flatten(children.map(child => mountChildren(child, env))) : mount(children, env);
1122
+ }
1123
+ function mount(vnode, env = DEFAULT_ENV) {
868
1124
  if (vnode == null || typeof vnode === 'boolean') {
869
- return {
870
- type: MOUNT_SINGLE,
871
- node: null
872
- };
1125
+ return null;
873
1126
  }
874
1127
  if (vnode instanceof Node) {
875
- return {
876
- type: MOUNT_SINGLE,
877
- node: vnode
878
- };
1128
+ return vnode;
879
1129
  }
880
1130
  if (isRenderFunction(vnode)) {
881
- var _ref = vnode,
882
- type = _ref.type,
883
- props = _ref.props;
1131
+ const {
1132
+ type,
1133
+ props
1134
+ } = vnode;
884
1135
  if (type === Fragment) {
885
- var node = document.createDocumentFragment();
1136
+ const node = document.createDocumentFragment();
886
1137
  if (props.children) {
887
- var childrenRef = mount(props.children, env);
888
- insertDom(node, childrenRef);
1138
+ const children = mountChildren(props.children, env);
1139
+ insertDom(node, children);
889
1140
  }
890
- return {
891
- type: MOUNT_SINGLE,
892
- node: node
893
- };
1141
+ return node;
894
1142
  }
895
- var childVNode = type(props);
1143
+ const childVNode = type(props);
896
1144
  return mount(childVNode, env);
897
1145
  }
898
1146
  if (isLeaf(vnode)) {
899
- return {
900
- type: MOUNT_SINGLE,
901
- node: document.createTextNode("" + vnode)
902
- };
1147
+ return document.createTextNode(`${vnode}`);
903
1148
  }
904
1149
  if (isElement(vnode)) {
905
- var _node;
906
- var _ref2 = vnode,
907
- _type = _ref2.type,
908
- _props = _ref2.props;
909
- if (!env.isSvg && _type === 'svg') {
1150
+ let node;
1151
+ const {
1152
+ type,
1153
+ props
1154
+ } = vnode;
1155
+ if (!env.isSvg && type === 'svg') {
910
1156
  env = Object.assign({}, env, {
911
1157
  isSvg: true
912
1158
  });
913
1159
  }
914
1160
  if (!env.isSvg) {
915
- _node = document.createElement(_type);
1161
+ node = document.createElement(type);
916
1162
  } else {
917
- _node = document.createElementNS(SVG_NS, _type);
1163
+ node = document.createElementNS(SVG_NS, type);
918
1164
  }
919
- mountAttributes(_node, _props, env);
920
- var _childrenRef;
921
- if (_props.children) {
922
- var childEnv = env;
923
- if (env.isSvg && _type === 'foreignObject') {
1165
+ mountAttributes(node, props, env);
1166
+ if (props.children) {
1167
+ let childEnv = env;
1168
+ if (env.isSvg && type === 'foreignObject') {
924
1169
  childEnv = Object.assign({}, childEnv, {
925
1170
  isSvg: false
926
1171
  });
927
1172
  }
928
- _childrenRef = mount(_props.children, childEnv);
1173
+ const children = mountChildren(props.children, childEnv);
1174
+ if (children != null) insertDom(node, children);
929
1175
  }
930
- if (_childrenRef != null) insertDom(_node, _childrenRef);
931
- var ref = _props.ref;
932
- if (typeof ref === 'function') ref(_node);
933
- return {
934
- type: MOUNT_SINGLE,
935
- node: _node
936
- };
937
- }
938
- if (Array.isArray(vnode)) {
939
- return {
940
- type: MOUNT_ARRAY,
941
- children: vnode.map(function (child) {
942
- return mount(child, env);
943
- })
944
- };
1176
+ const {
1177
+ ref
1178
+ } = props;
1179
+ if (typeof ref === 'function') ref(node);
1180
+ return node;
945
1181
  }
946
1182
  throw new Error('mount: Invalid Vnode!');
947
1183
  }
948
- function flattenWithoutNull(array) {
949
- var result = [];
950
- for (var i = 0; i < array.length; i += 1) {
951
- var item = array[i];
952
- if (Array.isArray(item)) result = result.concat(flattenWithoutNull(item));else if (item != null) result.push(item);
953
- }
954
- return result;
955
- }
956
- function asDom(result) {
957
- if (result.type === MOUNT_SINGLE) {
958
- return result.node;
959
- }
960
- return result.children.map(asDom);
961
- }
1184
+
962
1185
  /**
963
1186
  * Mount vdom as real DOM nodes.
964
1187
  */
965
-
966
1188
  function mountDom(vnode) {
967
- if (Array.isArray(vnode)) {
968
- return flattenWithoutNull(vnode.map(mountDom));
969
- }
970
- return asDom(mount(vnode));
1189
+ return mount(vnode);
971
1190
  }
972
1191
 
973
- var css_248z$1 = ".markmap{font:300 16px/20px sans-serif}.markmap-link{fill:none}.markmap-node>circle{cursor:pointer}.markmap-foreign{display:inline-block}.markmap-foreign a{color:#0097e6}.markmap-foreign a:hover{color:#00a8ff}.markmap-foreign code{background-color:#f0f0f0;border-radius:2px;color:#555;font-size:calc(1em - 2px)}.markmap-foreign :not(pre)>code{padding:.2em .4em}.markmap-foreign del{text-decoration:line-through}.markmap-foreign em{font-style:italic}.markmap-foreign strong{font-weight:700}.markmap-foreign mark{background:#ffeaa7}.markmap-foreign pre,.markmap-foreign pre[class*=language-]{margin:0;padding:.2em .4em}";
1192
+ var css_248z$1 = ".markmap{font:300 16px/20px sans-serif}.markmap-link{fill:none}.markmap-node>circle{cursor:pointer}.markmap-foreign{display:inline-block}.markmap-foreign a{color:#0097e6}.markmap-foreign a:hover{color:#00a8ff}.markmap-foreign code{background-color:#f0f0f0;border-radius:2px;color:#555;font-size:calc(1em - 2px);padding:.25em}.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:#ffeaa7}";
974
1193
 
975
1194
  var css_248z = ".markmap-container{height:0;left:-100px;overflow:hidden;position:absolute;top:-100px;width:0}.markmap-container>.markmap-foreign{display:inline-block}.markmap-container>.markmap-foreign>div:last-child{white-space:nowrap}";
976
1195
 
@@ -979,15 +1198,8 @@ function linkWidth(nodeData) {
979
1198
  const data = nodeData.data;
980
1199
  return Math.max(4 - 2 * data.depth, 1.5);
981
1200
  }
982
- function adjustSpacing(tree, spacing) {
983
- walkTree(tree, (d, next) => {
984
- d.ySizeInner = d.ySize - spacing;
985
- d.y += spacing;
986
- next();
987
- }, 'children');
988
- }
989
1201
  function minBy(numbers, by) {
990
- const index = d3__namespace.minIndex(numbers, by);
1202
+ const index = d3.minIndex(numbers, by);
991
1203
  return numbers[index];
992
1204
  }
993
1205
  function stopPropagation(e) {
@@ -1003,18 +1215,33 @@ function createViewHooks() {
1003
1215
  * A global hook to refresh all markmaps when called.
1004
1216
  */
1005
1217
  const refreshHook = new Hook();
1006
- const defaultColorFn = d3__namespace.scaleOrdinal(d3__namespace.schemeCategory10);
1218
+ const defaultColorFn = d3.scaleOrdinal(d3.schemeCategory10);
1007
1219
  const isMacintosh = typeof navigator !== 'undefined' && navigator.userAgent.includes('Macintosh');
1008
1220
  class Markmap {
1009
1221
  constructor(svg, opts) {
1222
+ this.options = Markmap.defaultOptions;
1010
1223
  this.revokers = [];
1011
- ['handleZoom', 'handleClick', 'handlePan'].forEach(key => {
1012
- this[key] = this[key].bind(this);
1013
- });
1224
+ this.handleZoom = e => {
1225
+ const {
1226
+ transform
1227
+ } = e;
1228
+ this.g.attr('transform', transform);
1229
+ };
1230
+ this.handlePan = e => {
1231
+ e.preventDefault();
1232
+ const transform = d3.zoomTransform(this.svg.node());
1233
+ const newTransform = transform.translate(-e.deltaX / transform.k, -e.deltaY / transform.k);
1234
+ this.svg.call(this.zoom.transform, newTransform);
1235
+ };
1236
+ this.handleClick = (e, d) => {
1237
+ let recursive = this.options.toggleRecursively;
1238
+ if (isMacintosh ? e.metaKey : e.ctrlKey) recursive = !recursive;
1239
+ this.toggleNode(d.data, recursive);
1240
+ };
1014
1241
  this.viewHooks = createViewHooks();
1015
- this.svg = svg.datum ? svg : d3__namespace.select(svg);
1242
+ this.svg = svg.datum ? svg : d3.select(svg);
1016
1243
  this.styleNode = this.svg.append('style');
1017
- this.zoom = d3__namespace.zoom().filter(event => {
1244
+ this.zoom = d3.zoom().filter(event => {
1018
1245
  if (this.options.scrollForPan) {
1019
1246
  // Pan with wheels, zoom with ctrl+wheels
1020
1247
  if (event.type === 'wheel') return event.ctrlKey && !event.button;
@@ -1023,7 +1250,11 @@ class Markmap {
1023
1250
  }).on('zoom', this.handleZoom);
1024
1251
  this.setOptions(opts);
1025
1252
  this.state = {
1026
- id: this.options.id || this.svg.attr('id') || getId()
1253
+ id: this.options.id || this.svg.attr('id') || getId(),
1254
+ minX: 0,
1255
+ maxX: 0,
1256
+ minY: 0,
1257
+ maxY: 0
1027
1258
  };
1028
1259
  this.g = this.svg.append('g');
1029
1260
  this.revokers.push(refreshHook.tap(() => {
@@ -1045,18 +1276,6 @@ class Markmap {
1045
1276
  const style = this.getStyleContent();
1046
1277
  this.styleNode.text(style);
1047
1278
  }
1048
- handleZoom(e) {
1049
- const {
1050
- transform
1051
- } = e;
1052
- this.g.attr('transform', transform);
1053
- }
1054
- handlePan(e) {
1055
- e.preventDefault();
1056
- const transform = d3__namespace.zoomTransform(this.svg.node());
1057
- const newTransform = transform.translate(-e.deltaX / transform.k, -e.deltaY / transform.k);
1058
- this.svg.call(this.zoom.transform, newTransform);
1059
- }
1060
1279
  toggleNode(data, recursive = false) {
1061
1280
  var _data$payload;
1062
1281
  const fold = (_data$payload = data.payload) != null && _data$payload.fold ? 0 : 1;
@@ -1076,9 +1295,6 @@ class Markmap {
1076
1295
  }
1077
1296
  this.renderData(data);
1078
1297
  }
1079
- handleClick(e, d) {
1080
- this.toggleNode(d.data, e.ctrlKey);
1081
- }
1082
1298
  initializeData(node) {
1083
1299
  let nodeId = 0;
1084
1300
  const {
@@ -1138,14 +1354,16 @@ class Markmap {
1138
1354
  // `white-space: nowrap` gets re-layouted, then we will get the expected layout, with
1139
1355
  // content in one line as much as possible, and subjecting to the given max-width.
1140
1356
  nodes.forEach(node => {
1141
- node.parentNode.append(node.cloneNode(true));
1357
+ var _node$parentNode;
1358
+ (_node$parentNode = node.parentNode) == null ? void 0 : _node$parentNode.append(node.cloneNode(true));
1142
1359
  });
1143
1360
  walkTree(node, (item, next, parent) => {
1144
1361
  var _parent$state2;
1145
- const rect = item.state.el.getBoundingClientRect();
1146
- item.content = item.state.el.innerHTML;
1147
- item.state.size = [Math.ceil(rect.width) + 1, Math.max(Math.ceil(rect.height), nodeMinHeight)];
1148
- item.state.key = [parent == null || (_parent$state2 = parent.state) == null ? void 0 : _parent$state2.id, item.state.id].filter(Boolean).join('.') +
1362
+ const state = item.state;
1363
+ const rect = state.el.getBoundingClientRect();
1364
+ item.content = state.el.innerHTML;
1365
+ state.size = [Math.ceil(rect.width) + 1, Math.max(Math.ceil(rect.height), nodeMinHeight)];
1366
+ state.key = [parent == null || (_parent$state2 = parent.state) == null ? void 0 : _parent$state2.id, state.id].filter(Boolean).join('.') +
1149
1367
  // FIXME: find a way to check content hash
1150
1368
  item.content;
1151
1369
  next();
@@ -1154,17 +1372,22 @@ class Markmap {
1154
1372
  style.remove();
1155
1373
  }
1156
1374
  setOptions(opts) {
1157
- this.options = _extends({}, Markmap.defaultOptions, opts);
1375
+ this.options = _extends({}, this.options, opts);
1158
1376
  if (this.options.zoom) {
1159
1377
  this.svg.call(this.zoom);
1160
1378
  } else {
1161
1379
  this.svg.on('.zoom', null);
1162
1380
  }
1163
- this.svg.on('wheel', this.options.pan ? this.handlePan : null);
1381
+ if (this.options.pan) {
1382
+ this.svg.on('wheel', this.handlePan);
1383
+ } else {
1384
+ this.svg.on('wheel', null);
1385
+ }
1164
1386
  }
1165
1387
  setData(data, opts) {
1166
- if (data) this.state.data = data;
1167
1388
  if (opts) this.setOptions(opts);
1389
+ if (data) this.state.data = data;
1390
+ if (!this.state.data) return;
1168
1391
  this.initializeData(this.state.data);
1169
1392
  this.updateStyle();
1170
1393
  this.renderData();
@@ -1179,25 +1402,24 @@ class Markmap {
1179
1402
  autoFit,
1180
1403
  color
1181
1404
  } = this.options;
1182
- const layout = flextree().children(d => {
1405
+ const layout = flextree({}).children(d => {
1183
1406
  var _d$payload;
1184
- return !((_d$payload = d.payload) != null && _d$payload.fold) && d.children;
1185
- }).nodeSize(d => {
1186
- const [width, height] = d.data.state.size;
1407
+ if (!((_d$payload = d.payload) != null && _d$payload.fold)) return d.children;
1408
+ }).nodeSize(node => {
1409
+ const [width, height] = node.data.state.size;
1187
1410
  return [height, width + (width ? paddingX * 2 : 0) + spacingHorizontal];
1188
1411
  }).spacing((a, b) => {
1189
1412
  return a.parent === b.parent ? spacingVertical : spacingVertical * 2;
1190
1413
  });
1191
1414
  const tree = layout.hierarchy(this.state.data);
1192
1415
  layout(tree);
1193
- adjustSpacing(tree, spacingHorizontal);
1194
1416
  const descendants = tree.descendants().reverse();
1195
1417
  const links = tree.links();
1196
- const linkShape = d3__namespace.linkHorizontal();
1197
- const minX = d3__namespace.min(descendants, d => d.x - d.xSize / 2);
1198
- const maxX = d3__namespace.max(descendants, d => d.x + d.xSize / 2);
1199
- const minY = d3__namespace.min(descendants, d => d.y);
1200
- const maxY = d3__namespace.max(descendants, d => d.y + d.ySizeInner);
1418
+ const linkShape = d3.linkHorizontal();
1419
+ const minX = d3.min(descendants, d => d.x - d.xSize / 2);
1420
+ const maxX = d3.max(descendants, d => d.x + d.xSize / 2);
1421
+ const minY = d3.min(descendants, d => d.y);
1422
+ const maxY = d3.max(descendants, d => d.y + d.ySize - spacingHorizontal);
1201
1423
  Object.assign(this.state, {
1202
1424
  minX,
1203
1425
  maxX,
@@ -1211,11 +1433,11 @@ class Markmap {
1211
1433
 
1212
1434
  // Update the nodes
1213
1435
  const node = this.g.selectAll(childSelector('g')).data(descendants, d => d.data.state.key);
1214
- const nodeEnter = node.enter().append('g').attr('data-depth', d => d.data.depth).attr('data-path', d => d.data.state.path).attr('transform', d => `translate(${y0 + origin.ySizeInner - d.ySizeInner},${x0 + origin.xSize / 2 - d.xSize})`);
1436
+ const nodeEnter = node.enter().append('g').attr('data-depth', d => d.data.depth).attr('data-path', d => d.data.state.path).attr('transform', d => `translate(${y0 + origin.ySize - d.ySize},${x0 + origin.xSize / 2 - d.xSize})`);
1215
1437
  const nodeExit = this.transition(node.exit());
1216
- nodeExit.select('line').attr('x1', d => d.ySizeInner).attr('x2', d => d.ySizeInner);
1438
+ nodeExit.select('line').attr('x1', d => d.ySize - spacingHorizontal).attr('x2', d => d.ySize - spacingHorizontal);
1217
1439
  nodeExit.select('foreignObject').style('opacity', 0);
1218
- nodeExit.attr('transform', d => `translate(${origin.y + origin.ySizeInner - d.ySizeInner},${origin.x + origin.xSize / 2 - d.xSize})`).remove();
1440
+ nodeExit.attr('transform', d => `translate(${origin.y + origin.ySize - d.ySize},${origin.x + origin.xSize / 2 - d.xSize})`).remove();
1219
1441
  const nodeMerge = node.merge(nodeEnter).attr('class', d => {
1220
1442
  var _d$data$payload;
1221
1443
  return ['markmap-node', ((_d$data$payload = d.data.payload) == null ? void 0 : _d$data$payload.fold) && 'markmap-fold'].filter(Boolean).join(' ');
@@ -1224,15 +1446,18 @@ class Markmap {
1224
1446
 
1225
1447
  // Update lines under the content
1226
1448
  const line = nodeMerge.selectAll(childSelector('line')).data(d => [d], d => d.data.state.key).join(enter => {
1227
- return enter.append('line').attr('x1', d => d.ySizeInner).attr('x2', d => d.ySizeInner);
1449
+ return enter.append('line').attr('x1', d => d.ySize - spacingHorizontal).attr('x2', d => d.ySize - spacingHorizontal);
1228
1450
  }, update => update, exit => exit.remove());
1229
- this.transition(line).attr('x1', -1).attr('x2', d => d.ySizeInner + 2).attr('y1', d => d.xSize).attr('y2', d => d.xSize).attr('stroke', d => color(d.data)).attr('stroke-width', linkWidth);
1451
+ this.transition(line).attr('x1', -1).attr('x2', d => d.ySize - spacingHorizontal + 2).attr('y1', d => d.xSize).attr('y2', d => d.xSize).attr('stroke', d => color(d.data)).attr('stroke-width', linkWidth);
1230
1452
 
1231
1453
  // Circle to link to children of the node
1232
- const circle = nodeMerge.selectAll(childSelector('circle')).data(d => d.data.children ? [d] : [], d => d.data.state.key).join(enter => {
1233
- return enter.append('circle').attr('stroke-width', '1.5').attr('cx', d => d.ySizeInner).attr('cy', d => d.xSize).attr('r', 0).on('click', (e, d) => this.handleClick(e, d)).on('mousedown', stopPropagation);
1454
+ const circle = nodeMerge.selectAll(childSelector('circle')).data(d => {
1455
+ var _d$data$children;
1456
+ return (_d$data$children = d.data.children) != null && _d$data$children.length ? [d] : [];
1457
+ }, d => d.data.state.key).join(enter => {
1458
+ return enter.append('circle').attr('stroke-width', '1.5').attr('cx', d => d.ySize - spacingHorizontal).attr('cy', d => d.xSize).attr('r', 0).on('click', (e, d) => this.handleClick(e, d)).on('mousedown', stopPropagation);
1234
1459
  }, update => update, exit => exit.remove());
1235
- this.transition(circle).attr('r', 6).attr('cx', d => d.ySizeInner).attr('cy', d => d.xSize).attr('stroke', d => color(d.data)).attr('fill', d => {
1460
+ this.transition(circle).attr('r', 6).attr('cx', d => d.ySize - spacingHorizontal).attr('cy', d => d.xSize).attr('stroke', d => color(d.data)).attr('fill', d => {
1236
1461
  var _d$data$payload2;
1237
1462
  return (_d$data$payload2 = d.data.payload) != null && _d$data$payload2.fold && d.data.children ? color(d.data) : '#fff';
1238
1463
  });
@@ -1244,26 +1469,28 @@ class Markmap {
1244
1469
  return clone;
1245
1470
  }).attr('xmlns', 'http://www.w3.org/1999/xhtml');
1246
1471
  return fo;
1247
- }, update => update, exit => exit.remove()).attr('width', d => Math.max(0, d.ySizeInner - paddingX * 2)).attr('height', d => d.xSize);
1472
+ }, update => update, exit => exit.remove()).attr('width', d => Math.max(0, d.ySize - spacingHorizontal - paddingX * 2)).attr('height', d => d.xSize);
1248
1473
  this.transition(foreignObject).style('opacity', 1);
1249
1474
 
1250
1475
  // Update the links
1251
1476
  const path = this.g.selectAll(childSelector('path')).data(links, d => d.target.data.state.key).join(enter => {
1252
- const source = [y0 + origin.ySizeInner, x0 + origin.xSize / 2];
1477
+ const source = [y0 + origin.ySize - spacingHorizontal, x0 + origin.xSize / 2];
1253
1478
  return enter.insert('path', 'g').attr('class', 'markmap-link').attr('data-depth', d => d.target.data.depth).attr('data-path', d => d.target.data.state.path).attr('d', linkShape({
1254
1479
  source,
1255
1480
  target: source
1256
1481
  }));
1257
1482
  }, update => update, exit => {
1258
- const source = [origin.y + origin.ySizeInner, origin.x + origin.xSize / 2];
1483
+ const source = [origin.y + origin.ySize - spacingHorizontal, origin.x + origin.xSize / 2];
1259
1484
  return this.transition(exit).attr('d', linkShape({
1260
1485
  source,
1261
1486
  target: source
1262
1487
  })).remove();
1263
1488
  });
1264
1489
  this.transition(path).attr('stroke', d => color(d.target.data)).attr('stroke-width', d => linkWidth(d.target)).attr('d', d => {
1265
- const source = [d.source.y + d.source.ySizeInner, d.source.x + d.source.xSize / 2];
1266
- const target = [d.target.y, d.target.x + d.target.xSize / 2];
1490
+ const origSource = d.source;
1491
+ const origTarget = d.target;
1492
+ const source = [origSource.y + origSource.ySize - spacingHorizontal, origSource.x + origSource.xSize / 2];
1493
+ const target = [origTarget.y, origTarget.x + origTarget.xSize / 2];
1267
1494
  return linkShape({
1268
1495
  source,
1269
1496
  target
@@ -1302,7 +1529,7 @@ class Markmap {
1302
1529
  const naturalWidth = maxY - minY;
1303
1530
  const naturalHeight = maxX - minX;
1304
1531
  const scale = Math.min(offsetWidth / naturalWidth * fitRatio, offsetHeight / naturalHeight * fitRatio, 2);
1305
- const initialZoom = d3__namespace.zoomIdentity.translate((offsetWidth - naturalWidth * scale) / 2 - minY * scale, (offsetHeight - naturalHeight * scale) / 2 - minX * scale).scale(scale);
1532
+ const initialZoom = d3.zoomIdentity.translate((offsetWidth - naturalWidth * scale) / 2 - minY * scale, (offsetHeight - naturalHeight * scale) / 2 - minX * scale).scale(scale);
1306
1533
  return this.transition(this.svg).call(this.zoom.transform, initialZoom).end().catch(noop);
1307
1534
  }
1308
1535
 
@@ -1318,9 +1545,12 @@ class Markmap {
1318
1545
  });
1319
1546
  if (!itemData) return;
1320
1547
  const svgNode = this.svg.node();
1548
+ const {
1549
+ spacingHorizontal
1550
+ } = this.options;
1321
1551
  const relRect = svgNode.getBoundingClientRect();
1322
- const transform = d3__namespace.zoomTransform(svgNode);
1323
- const [left, right] = [itemData.y, itemData.y + itemData.ySizeInner + 2].map(x => x * transform.k + transform.x);
1552
+ const transform = d3.zoomTransform(svgNode);
1553
+ const [left, right] = [itemData.y, itemData.y + itemData.ySize - spacingHorizontal + 2].map(x => x * transform.k + transform.x);
1324
1554
  const [top, bottom] = [itemData.x - itemData.xSize / 2, itemData.x + itemData.xSize / 2].map(y => y * transform.k + transform.y);
1325
1555
  // Skip if the node includes or is included in the container.
1326
1556
  const pd = _extends({
@@ -1350,7 +1580,7 @@ class Markmap {
1350
1580
  } = svgNode.getBoundingClientRect();
1351
1581
  const halfWidth = offsetWidth / 2;
1352
1582
  const halfHeight = offsetHeight / 2;
1353
- const transform = d3__namespace.zoomTransform(svgNode);
1583
+ const transform = d3.zoomTransform(svgNode);
1354
1584
  const newTransform = transform.translate((halfWidth - transform.x) * (1 - scale) / transform.k, (halfHeight - transform.y) * (1 - scale) / transform.k).scale(scale);
1355
1585
  return this.transition(this.svg).call(this.zoom.transform, newTransform).end().catch(noop);
1356
1586
  }
@@ -1361,7 +1591,7 @@ class Markmap {
1361
1591
  fn();
1362
1592
  });
1363
1593
  }
1364
- static create(svg, opts, data) {
1594
+ static create(svg, opts, data = null) {
1365
1595
  const mm = new Markmap(svg, opts);
1366
1596
  if (data) {
1367
1597
  mm.setData(data);
@@ -1373,7 +1603,10 @@ class Markmap {
1373
1603
  }
1374
1604
  Markmap.defaultOptions = {
1375
1605
  autoFit: false,
1376
- color: node => defaultColorFn(`${node.state.path}`),
1606
+ color: node => {
1607
+ var _node$state;
1608
+ return defaultColorFn(`${((_node$state = node.state) == null ? void 0 : _node$state.path) || ''}`);
1609
+ },
1377
1610
  duration: 500,
1378
1611
  embedGlobalCSS: true,
1379
1612
  fitRatio: 0.95,
@@ -1385,25 +1618,26 @@ Markmap.defaultOptions = {
1385
1618
  spacingVertical: 5,
1386
1619
  initialExpandLevel: -1,
1387
1620
  zoom: true,
1388
- pan: true
1621
+ pan: true,
1622
+ toggleRecursively: false
1389
1623
  };
1390
1624
  function deriveOptions(jsonOptions) {
1391
- const opts = {};
1392
- jsonOptions || (jsonOptions = {});
1625
+ const derivedOptions = {};
1626
+ const options = _extends({}, jsonOptions);
1393
1627
  const {
1394
1628
  color,
1395
1629
  colorFreezeLevel
1396
- } = jsonOptions;
1630
+ } = options;
1397
1631
  if ((color == null ? void 0 : color.length) === 1) {
1398
1632
  const solidColor = color[0];
1399
- opts.color = () => solidColor;
1633
+ derivedOptions.color = () => solidColor;
1400
1634
  } else if (color != null && color.length) {
1401
- const colorFn = d3__namespace.scaleOrdinal(color);
1402
- opts.color = node => colorFn(`${node.state.path}`);
1635
+ const colorFn = d3.scaleOrdinal(color);
1636
+ derivedOptions.color = node => colorFn(`${node.state.path}`);
1403
1637
  }
1404
1638
  if (colorFreezeLevel) {
1405
- const color = opts.color || Markmap.defaultOptions.color;
1406
- opts.color = node => {
1639
+ const color = derivedOptions.color || Markmap.defaultOptions.color;
1640
+ derivedOptions.color = node => {
1407
1641
  node = _extends({}, node, {
1408
1642
  state: _extends({}, node.state, {
1409
1643
  path: node.state.path.split('.').slice(0, colorFreezeLevel).join('.')
@@ -1414,15 +1648,15 @@ function deriveOptions(jsonOptions) {
1414
1648
  }
1415
1649
  const numberKeys = ['duration', 'maxWidth', 'initialExpandLevel'];
1416
1650
  numberKeys.forEach(key => {
1417
- const value = jsonOptions[key];
1418
- if (typeof value === 'number') opts[key] = value;
1651
+ const value = options[key];
1652
+ if (typeof value === 'number') derivedOptions[key] = value;
1419
1653
  });
1420
1654
  const booleanKeys = ['zoom', 'pan'];
1421
1655
  booleanKeys.forEach(key => {
1422
- const value = jsonOptions[key];
1423
- if (value != null) opts[key] = !!value;
1656
+ const value = options[key];
1657
+ if (value != null) derivedOptions[key] = !!value;
1424
1658
  });
1425
- return opts;
1659
+ return derivedOptions;
1426
1660
  }
1427
1661
 
1428
1662
  exports.Markmap = Markmap;