markmap-view 0.15.0-alpha.0 → 0.15.0

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