markmap-view 0.2.6 → 0.13.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.
package/dist/index.cjs.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! markmap-view v0.2.6 | MIT License */
1
+ /*! markmap-view v0.13.0 | MIT License */
2
2
  'use strict';
3
3
 
4
4
  var d3 = require('d3');
@@ -7,16 +7,44 @@ function _interopNamespace(e) {
7
7
  if (e && e.__esModule) return e;
8
8
  var n = Object.create(null);
9
9
  if (e) {
10
- Object.keys(e).forEach(function (k) {
10
+ for (var k in e) {
11
11
  n[k] = e[k];
12
- });
13
12
  }
14
- n['default'] = e;
13
+ }
14
+ n["default"] = e;
15
15
  return Object.freeze(n);
16
16
  }
17
17
 
18
18
  var d3__namespace = /*#__PURE__*/_interopNamespace(d3);
19
19
 
20
+ /*! markmap-common v0.13.0 | MIT License */
21
+ class Hook {
22
+ constructor() {
23
+ this.listeners = [];
24
+ }
25
+
26
+ tap(fn) {
27
+ this.listeners.push(fn);
28
+ return () => this.revoke(fn);
29
+ }
30
+
31
+ revoke(fn) {
32
+ const i = this.listeners.indexOf(fn);
33
+ if (i >= 0) this.listeners.splice(i, 1);
34
+ }
35
+
36
+ revokeAll() {
37
+ this.listeners.splice(0);
38
+ }
39
+
40
+ call(...args) {
41
+ for (const fn of this.listeners) {
42
+ fn(...args);
43
+ }
44
+ }
45
+
46
+ }
47
+
20
48
  function _extends$1() {
21
49
  _extends$1 = Object.assign || function (target) {
22
50
  for (var i = 1; i < arguments.length; i++) {
@@ -35,52 +63,186 @@ function _extends$1() {
35
63
  return _extends$1.apply(this, arguments);
36
64
  }
37
65
 
38
- function _assertThisInitialized(self) {
39
- if (self === void 0) {
40
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
41
- }
66
+ const uniqId = Math.random().toString(36).slice(2, 8);
67
+ let globalIndex = 0;
42
68
 
43
- return self;
69
+ function getId() {
70
+ globalIndex += 1;
71
+ return `mm-${uniqId}-${globalIndex}`;
72
+ }
73
+
74
+ function noop() {// noop
75
+ }
76
+
77
+ function walkTree(tree, callback, key = 'children') {
78
+ const walk = (item, parent) => callback(item, () => {
79
+ var _item$key;
80
+
81
+ (_item$key = item[key]) == null ? void 0 : _item$key.forEach(child => {
82
+ walk(child, item);
83
+ });
84
+ }, parent);
85
+
86
+ walk(tree);
44
87
  }
45
88
 
46
- function _defineProperties(target, props) {
47
- for (var i = 0; i < props.length; i++) {
48
- var descriptor = props[i];
49
- descriptor.enumerable = descriptor.enumerable || false;
50
- descriptor.configurable = true;
51
- if ("value" in descriptor) descriptor.writable = true;
52
- Object.defineProperty(target, descriptor.key, descriptor);
89
+ function arrayFrom(arrayLike) {
90
+ if (Array.from) return Array.from(arrayLike);
91
+ const array = [];
92
+
93
+ for (let i = 0; i < arrayLike.length; i += 1) {
94
+ array.push(arrayLike[i]);
53
95
  }
96
+
97
+ return array;
98
+ }
99
+
100
+ function addClass(className, ...rest) {
101
+ const classList = (className || '').split(' ').filter(Boolean);
102
+ rest.forEach(item => {
103
+ if (item && classList.indexOf(item) < 0) classList.push(item);
104
+ });
105
+ return classList.join(' ');
54
106
  }
55
107
 
56
- function _createClass(Constructor, protoProps, staticProps) {
57
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
58
- if (staticProps) _defineProperties(Constructor, staticProps);
59
- return Constructor;
108
+ function childSelector(filter) {
109
+ if (typeof filter === 'string') {
110
+ const tagName = filter;
111
+
112
+ filter = el => el.tagName === tagName;
113
+ }
114
+
115
+ const filterFn = filter;
116
+ return function selector() {
117
+ let nodes = arrayFrom(this.childNodes);
118
+ if (filterFn) nodes = nodes.filter(node => filterFn(node));
119
+ return nodes;
120
+ };
60
121
  }
61
122
 
62
- function _setPrototypeOf(o, p) {
63
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
64
- o.__proto__ = p;
65
- return o;
123
+ function memoize(fn) {
124
+ const cache = {};
125
+ return function memoized(...args) {
126
+ const key = `${args[0]}`;
127
+ let data = cache[key];
128
+
129
+ if (!data) {
130
+ data = {
131
+ value: fn(...args)
132
+ };
133
+ cache[key] = data;
134
+ }
135
+
136
+ return data.value;
66
137
  };
138
+ }
139
+
140
+ function createElement(tagName, props, attrs) {
141
+ const el = document.createElement(tagName);
142
+
143
+ if (props) {
144
+ Object.entries(props).forEach(([key, value]) => {
145
+ el[key] = value;
146
+ });
147
+ }
148
+
149
+ if (attrs) {
150
+ Object.entries(attrs).forEach(([key, value]) => {
151
+ el.setAttribute(key, value);
152
+ });
153
+ }
154
+
155
+ return el;
156
+ }
157
+
158
+ const memoizedPreloadJS = memoize(url => {
159
+ document.head.append(createElement('link', {
160
+ rel: 'preload',
161
+ as: 'script',
162
+ href: url
163
+ }));
164
+ });
165
+
166
+ function loadJSItem(item, context) {
167
+ if (item.type === 'script') {
168
+ return new Promise((resolve, reject) => {
169
+ var _item$data;
170
+
171
+ document.head.append(createElement('script', _extends$1({}, item.data, {
172
+ onload: resolve,
173
+ onerror: reject
174
+ }))); // Run inline script synchronously
67
175
 
68
- return _setPrototypeOf(o, p);
176
+ if (!((_item$data = item.data) != null && _item$data.src)) resolve();
177
+ });
178
+ }
179
+
180
+ if (item.type === 'iife') {
181
+ const {
182
+ fn,
183
+ getParams
184
+ } = item.data;
185
+ fn(...((getParams == null ? void 0 : getParams(context)) || []));
186
+ }
187
+ }
188
+
189
+ function loadCSSItem(item) {
190
+ if (item.type === 'style') {
191
+ document.head.append(createElement('style', {
192
+ textContent: item.data
193
+ }));
194
+ } else if (item.type === 'stylesheet') {
195
+ document.head.append(createElement('link', _extends$1({
196
+ rel: 'stylesheet'
197
+ }, item.data)));
198
+ }
199
+ }
200
+
201
+ async function loadJS(items, context) {
202
+ const needPreload = items.filter(item => {
203
+ var _item$data2;
204
+
205
+ return item.type === 'script' && ((_item$data2 = item.data) == null ? void 0 : _item$data2.src);
206
+ });
207
+ if (needPreload.length > 1) needPreload.forEach(item => memoizedPreloadJS(item.data.src));
208
+ context = _extends$1({
209
+ getMarkmap: () => window.markmap
210
+ }, context);
211
+
212
+ for (const item of items) {
213
+ await loadJSItem(item, context);
214
+ }
215
+ }
216
+
217
+ function loadCSS(items) {
218
+ for (const item of items) {
219
+ loadCSSItem(item);
220
+ }
69
221
  }
70
222
 
71
- function _inheritsLoose(subClass, superClass) {
72
- subClass.prototype = Object.create(superClass.prototype);
73
- subClass.prototype.constructor = subClass;
74
- _setPrototypeOf(subClass, superClass);
223
+ function _extends() {
224
+ _extends = Object.assign || function (target) {
225
+ for (var i = 1; i < arguments.length; i++) {
226
+ var source = arguments[i];
227
+
228
+ for (var key in source) {
229
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
230
+ target[key] = source[key];
231
+ }
232
+ }
233
+ }
234
+
235
+ return target;
236
+ };
237
+
238
+ return _extends.apply(this, arguments);
75
239
  }
76
240
 
77
241
  function count(node) {
78
242
  var sum = 0,
79
243
  children = node.children,
80
244
  i = children && children.length;
81
- if (!i) sum = 1;else while (--i >= 0) {
82
- sum += children[i].value;
83
- }
245
+ if (!i) sum = 1;else while (--i >= 0) sum += children[i].value;
84
246
  node.value = sum;
85
247
  }
86
248
 
@@ -154,9 +316,7 @@ function node_sum (value) {
154
316
  children = node.children,
155
317
  i = children && children.length;
156
318
 
157
- while (--i >= 0) {
158
- sum += children[i].value;
159
- }
319
+ while (--i >= 0) sum += children[i].value;
160
320
 
161
321
  node.value = sum;
162
322
  });
@@ -252,7 +412,7 @@ function node_links () {
252
412
  }
253
413
 
254
414
  function hierarchy(data, children) {
255
- var root = new Node(data),
415
+ var root = new Node$1(data),
256
416
  valued = +data.value && (root.value = data.value),
257
417
  node,
258
418
  nodes = [root],
@@ -269,7 +429,7 @@ function hierarchy(data, children) {
269
429
  node.children = new Array(n);
270
430
 
271
431
  for (i = n - 1; i >= 0; --i) {
272
- nodes.push(child = node.children[i] = new Node(childs[i]));
432
+ nodes.push(child = node.children[i] = new Node$1(childs[i]));
273
433
  child.parent = node;
274
434
  child.depth = node.depth + 1;
275
435
  }
@@ -294,17 +454,15 @@ function copyData(node) {
294
454
  function computeHeight(node) {
295
455
  var height = 0;
296
456
 
297
- do {
298
- node.height = height;
299
- } while ((node = node.parent) && node.height < ++height);
457
+ do node.height = height; while ((node = node.parent) && node.height < ++height);
300
458
  }
301
- function Node(data) {
459
+ function Node$1(data) {
302
460
  this.data = data;
303
461
  this.depth = this.height = 0;
304
462
  this.parent = null;
305
463
  }
306
- Node.prototype = hierarchy.prototype = {
307
- constructor: Node,
464
+ Node$1.prototype = hierarchy.prototype = {
465
+ constructor: Node$1,
308
466
  count: node_count,
309
467
  each: node_each,
310
468
  eachAfter: node_eachAfter,
@@ -319,15 +477,90 @@ Node.prototype = hierarchy.prototype = {
319
477
  copy: node_copy
320
478
  };
321
479
 
322
- var version = "2.1.1";
480
+ var name = "d3-flextree";
481
+ var version$1 = "2.1.2";
482
+ var main = "build/d3-flextree.js";
483
+ var module$1 = "index";
484
+ var author = {
485
+ name: "Chris Maloney",
486
+ url: "http://chrismaloney.org"
487
+ };
488
+ var description = "Flexible tree layout algorithm that allows for variable node sizes.";
489
+ var keywords = [
490
+ "d3",
491
+ "d3-module",
492
+ "layout",
493
+ "tree",
494
+ "hierarchy",
495
+ "d3-hierarchy",
496
+ "plugin",
497
+ "d3-plugin",
498
+ "infovis",
499
+ "visualization",
500
+ "2d"
501
+ ];
502
+ var homepage = "https://github.com/klortho/d3-flextree";
503
+ var license = "WTFPL";
504
+ var repository = {
505
+ type: "git",
506
+ url: "https://github.com/klortho/d3-flextree.git"
507
+ };
508
+ var scripts = {
509
+ clean: "rm -rf build demo test",
510
+ "build:demo": "rollup -c --environment BUILD:demo",
511
+ "build:dev": "rollup -c --environment BUILD:dev",
512
+ "build:prod": "rollup -c --environment BUILD:prod",
513
+ "build:test": "rollup -c --environment BUILD:test",
514
+ build: "rollup -c",
515
+ lint: "eslint index.js src",
516
+ "test:main": "node test/bundle.js",
517
+ "test:browser": "node test/browser-tests.js",
518
+ test: "npm-run-all test:*",
519
+ prepare: "npm-run-all clean build lint test"
520
+ };
521
+ var dependencies = {
522
+ "d3-hierarchy": "^1.1.5"
523
+ };
524
+ var devDependencies = {
525
+ "babel-plugin-external-helpers": "^6.22.0",
526
+ "babel-preset-es2015-rollup": "^3.0.0",
527
+ d3: "^4.13.0",
528
+ "d3-selection-multi": "^1.0.1",
529
+ eslint: "^4.19.1",
530
+ jsdom: "^11.6.2",
531
+ "npm-run-all": "^4.1.2",
532
+ rollup: "^0.55.3",
533
+ "rollup-plugin-babel": "^2.7.1",
534
+ "rollup-plugin-commonjs": "^8.0.2",
535
+ "rollup-plugin-copy": "^0.2.3",
536
+ "rollup-plugin-json": "^2.3.0",
537
+ "rollup-plugin-node-resolve": "^3.0.2",
538
+ "rollup-plugin-uglify": "^3.0.0",
539
+ "uglify-es": "^3.3.9"
540
+ };
541
+ var packageInfo = {
542
+ name: name,
543
+ version: version$1,
544
+ main: main,
545
+ module: module$1,
546
+ "jsnext:main": "index",
547
+ author: author,
548
+ description: description,
549
+ keywords: keywords,
550
+ homepage: homepage,
551
+ license: license,
552
+ repository: repository,
553
+ scripts: scripts,
554
+ dependencies: dependencies,
555
+ devDependencies: devDependencies
556
+ };
323
557
 
324
- var defaults = Object.freeze({
325
- children: function children(data) {
326
- return data.children;
327
- },
328
- nodeSize: function nodeSize(node) {
329
- return node.data.size;
330
- },
558
+ const {
559
+ version
560
+ } = packageInfo;
561
+ const defaults = Object.freeze({
562
+ children: data => data.children,
563
+ nodeSize: node => node.data.size,
331
564
  spacing: 0
332
565
  }); // Create a layout function with customizable options. Per D3-style, the
333
566
  // options can be set at any time using setter methods. The layout function
@@ -335,244 +568,192 @@ var defaults = Object.freeze({
335
568
  // time it is called.
336
569
 
337
570
  function flextree(options) {
338
- var opts = Object.assign({}, defaults, options);
571
+ const opts = Object.assign({}, defaults, options);
339
572
 
340
573
  function accessor(name) {
341
- var opt = opts[name];
342
- return typeof opt === 'function' ? opt : function () {
343
- return opt;
344
- };
574
+ const opt = opts[name];
575
+ return typeof opt === 'function' ? opt : () => opt;
345
576
  }
346
577
 
347
578
  function layout(tree) {
348
- var wtree = wrap(getWrapper(), tree, function (node) {
349
- return node.children;
350
- });
579
+ const wtree = wrap(getWrapper(), tree, node => node.children);
351
580
  wtree.update();
352
581
  return wtree.data;
353
582
  }
354
583
 
355
584
  function getFlexNode() {
356
- var nodeSize = accessor('nodeSize');
585
+ const nodeSize = accessor('nodeSize');
586
+ const spacing = accessor('spacing');
587
+ return class FlexNode extends hierarchy.prototype.constructor {
588
+ constructor(data) {
589
+ super(data);
590
+ }
357
591
 
358
- var _spacing = accessor('spacing');
592
+ copy() {
593
+ const c = wrap(this.constructor, this, node => node.children);
594
+ c.each(node => node.data = node.data.data);
595
+ return c;
596
+ }
359
597
 
360
- return /*#__PURE__*/function (_hierarchy$prototype$) {
361
- _inheritsLoose(FlexNode, _hierarchy$prototype$);
598
+ get size() {
599
+ return nodeSize(this);
600
+ }
362
601
 
363
- function FlexNode(data) {
364
- return _hierarchy$prototype$.call(this, data) || this;
602
+ spacing(oNode) {
603
+ return spacing(this, oNode);
365
604
  }
366
605
 
367
- var _proto = FlexNode.prototype;
606
+ get nodes() {
607
+ return this.descendants();
608
+ }
368
609
 
369
- _proto.copy = function copy() {
370
- var c = wrap(this.constructor, this, function (node) {
371
- return node.children;
372
- });
373
- c.each(function (node) {
374
- return node.data = node.data.data;
375
- });
376
- return c;
377
- };
610
+ get xSize() {
611
+ return this.size[0];
612
+ }
378
613
 
379
- _proto.spacing = function spacing(oNode) {
380
- return _spacing(this, oNode);
381
- };
614
+ get ySize() {
615
+ return this.size[1];
616
+ }
617
+
618
+ get top() {
619
+ return this.y;
620
+ }
621
+
622
+ get bottom() {
623
+ return this.y + this.ySize;
624
+ }
625
+
626
+ get left() {
627
+ return this.x - this.xSize / 2;
628
+ }
629
+
630
+ get right() {
631
+ return this.x + this.xSize / 2;
632
+ }
633
+
634
+ get root() {
635
+ const ancs = this.ancestors();
636
+ return ancs[ancs.length - 1];
637
+ }
638
+
639
+ get numChildren() {
640
+ return this.hasChildren ? this.children.length : 0;
641
+ }
642
+
643
+ get hasChildren() {
644
+ return !this.noChildren;
645
+ }
382
646
 
383
- FlexNode.maxExtents = function maxExtents(e0, e1) {
647
+ get noChildren() {
648
+ return this.children === null;
649
+ }
650
+
651
+ get firstChild() {
652
+ return this.hasChildren ? this.children[0] : null;
653
+ }
654
+
655
+ get lastChild() {
656
+ return this.hasChildren ? this.children[this.numChildren - 1] : null;
657
+ }
658
+
659
+ get extents() {
660
+ return (this.children || []).reduce((acc, kid) => FlexNode.maxExtents(acc, kid.extents), this.nodeExtents);
661
+ }
662
+
663
+ get nodeExtents() {
664
+ return {
665
+ top: this.top,
666
+ bottom: this.bottom,
667
+ left: this.left,
668
+ right: this.right
669
+ };
670
+ }
671
+
672
+ static maxExtents(e0, e1) {
384
673
  return {
385
674
  top: Math.min(e0.top, e1.top),
386
675
  bottom: Math.max(e0.bottom, e1.bottom),
387
676
  left: Math.min(e0.left, e1.left),
388
677
  right: Math.max(e0.right, e1.right)
389
678
  };
390
- };
391
-
392
- _createClass(FlexNode, [{
393
- key: "size",
394
- get: function get() {
395
- return nodeSize(this);
396
- }
397
- }, {
398
- key: "nodes",
399
- get: function get() {
400
- return this.descendants();
401
- }
402
- }, {
403
- key: "xSize",
404
- get: function get() {
405
- return this.size[0];
406
- }
407
- }, {
408
- key: "ySize",
409
- get: function get() {
410
- return this.size[1];
411
- }
412
- }, {
413
- key: "top",
414
- get: function get() {
415
- return this.y;
416
- }
417
- }, {
418
- key: "bottom",
419
- get: function get() {
420
- return this.y + this.ySize;
421
- }
422
- }, {
423
- key: "left",
424
- get: function get() {
425
- return this.x - this.xSize / 2;
426
- }
427
- }, {
428
- key: "right",
429
- get: function get() {
430
- return this.x + this.xSize / 2;
431
- }
432
- }, {
433
- key: "root",
434
- get: function get() {
435
- var ancs = this.ancestors();
436
- return ancs[ancs.length - 1];
437
- }
438
- }, {
439
- key: "numChildren",
440
- get: function get() {
441
- return this.hasChildren ? this.children.length : 0;
442
- }
443
- }, {
444
- key: "hasChildren",
445
- get: function get() {
446
- return !this.noChildren;
447
- }
448
- }, {
449
- key: "noChildren",
450
- get: function get() {
451
- return this.children === null;
452
- }
453
- }, {
454
- key: "firstChild",
455
- get: function get() {
456
- return this.hasChildren ? this.children[0] : null;
457
- }
458
- }, {
459
- key: "lastChild",
460
- get: function get() {
461
- return this.hasChildren ? this.children[this.numChildren - 1] : null;
462
- }
463
- }, {
464
- key: "extents",
465
- get: function get() {
466
- return (this.children || []).reduce(function (acc, kid) {
467
- return FlexNode.maxExtents(acc, kid.extents);
468
- }, this.nodeExtents);
469
- }
470
- }, {
471
- key: "nodeExtents",
472
- get: function get() {
473
- return {
474
- top: this.top,
475
- bottom: this.bottom,
476
- left: this.left,
477
- right: this.right
478
- };
479
- }
480
- }]);
679
+ }
481
680
 
482
- return FlexNode;
483
- }(hierarchy.prototype.constructor);
681
+ };
484
682
  }
485
683
 
486
684
  function getWrapper() {
487
- var FlexNode = getFlexNode();
488
- var nodeSize = accessor('nodeSize');
489
-
490
- var _spacing2 = accessor('spacing');
491
-
492
- return /*#__PURE__*/function (_FlexNode) {
493
- _inheritsLoose(_class, _FlexNode);
494
-
495
- function _class(data) {
496
- var _this;
497
-
498
- _this = _FlexNode.call(this, data) || this;
499
- Object.assign(_assertThisInitialized(_this), {
685
+ const FlexNode = getFlexNode();
686
+ const nodeSize = accessor('nodeSize');
687
+ const spacing = accessor('spacing');
688
+ return class extends FlexNode {
689
+ constructor(data) {
690
+ super(data);
691
+ Object.assign(this, {
500
692
  x: 0,
501
693
  y: 0,
502
694
  relX: 0,
503
695
  prelim: 0,
504
696
  shift: 0,
505
697
  change: 0,
506
- lExt: _assertThisInitialized(_this),
698
+ lExt: this,
507
699
  lExtRelX: 0,
508
700
  lThr: null,
509
- rExt: _assertThisInitialized(_this),
701
+ rExt: this,
510
702
  rExtRelX: 0,
511
703
  rThr: null
512
704
  });
513
- return _this;
514
705
  }
515
706
 
516
- var _proto2 = _class.prototype;
707
+ get size() {
708
+ return nodeSize(this.data);
709
+ }
517
710
 
518
- _proto2.spacing = function spacing(oNode) {
519
- return _spacing2(this.data, oNode.data);
520
- };
711
+ spacing(oNode) {
712
+ return spacing(this.data, oNode.data);
713
+ }
714
+
715
+ get x() {
716
+ return this.data.x;
717
+ }
718
+
719
+ set x(v) {
720
+ this.data.x = v;
721
+ }
722
+
723
+ get y() {
724
+ return this.data.y;
725
+ }
726
+
727
+ set y(v) {
728
+ this.data.y = v;
729
+ }
521
730
 
522
- _proto2.update = function update() {
731
+ update() {
523
732
  layoutChildren(this);
524
733
  resolveX(this);
525
734
  return this;
526
- };
527
-
528
- _createClass(_class, [{
529
- key: "size",
530
- get: function get() {
531
- return nodeSize(this.data);
532
- }
533
- }, {
534
- key: "x",
535
- get: function get() {
536
- return this.data.x;
537
- },
538
- set: function set(v) {
539
- this.data.x = v;
540
- }
541
- }, {
542
- key: "y",
543
- get: function get() {
544
- return this.data.y;
545
- },
546
- set: function set(v) {
547
- this.data.y = v;
548
- }
549
- }]);
735
+ }
550
736
 
551
- return _class;
552
- }(FlexNode);
737
+ };
553
738
  }
554
739
 
555
740
  function wrap(FlexClass, treeData, children) {
556
- var _wrap = function _wrap(data, parent) {
557
- var node = new FlexClass(data);
741
+ const _wrap = (data, parent) => {
742
+ const node = new FlexClass(data);
558
743
  Object.assign(node, {
559
- parent: parent,
744
+ parent,
560
745
  depth: parent === null ? 0 : parent.depth + 1,
561
746
  height: 0,
562
747
  length: 1
563
748
  });
564
- var kidsData = children(data) || [];
565
- node.children = kidsData.length === 0 ? null : kidsData.map(function (kd) {
566
- return _wrap(kd, node);
567
- });
749
+ const kidsData = children(data) || [];
750
+ node.children = kidsData.length === 0 ? null : kidsData.map(kd => _wrap(kd, node));
568
751
 
569
752
  if (node.children) {
570
- Object.assign(node, node.children.reduce(function (hl, kid) {
571
- return {
572
- height: Math.max(hl.height, kid.height + 1),
573
- length: hl.length + kid.length
574
- };
575
- }, node));
753
+ Object.assign(node, node.children.reduce((hl, kid) => ({
754
+ height: Math.max(hl.height, kid.height + 1),
755
+ length: hl.length + kid.length
756
+ }), node));
576
757
  }
577
758
 
578
759
  return node;
@@ -582,57 +763,57 @@ function flextree(options) {
582
763
  }
583
764
 
584
765
  Object.assign(layout, {
585
- nodeSize: function nodeSize(arg) {
766
+ nodeSize(arg) {
586
767
  return arguments.length ? (opts.nodeSize = arg, layout) : opts.nodeSize;
587
768
  },
588
- spacing: function spacing(arg) {
769
+
770
+ spacing(arg) {
589
771
  return arguments.length ? (opts.spacing = arg, layout) : opts.spacing;
590
772
  },
591
- children: function children(arg) {
773
+
774
+ children(arg) {
592
775
  return arguments.length ? (opts.children = arg, layout) : opts.children;
593
776
  },
594
- hierarchy: function hierarchy(treeData, children) {
595
- var kids = typeof children === 'undefined' ? opts.children : children;
777
+
778
+ hierarchy(treeData, children) {
779
+ const kids = typeof children === 'undefined' ? opts.children : children;
596
780
  return wrap(getFlexNode(), treeData, kids);
597
781
  },
598
- dump: function dump(tree) {
599
- var nodeSize = accessor('nodeSize');
600
-
601
- var _dump = function _dump(i0) {
602
- return function (node) {
603
- var i1 = i0 + ' ';
604
- var i2 = i0 + ' ';
605
- var x = node.x,
606
- y = node.y;
607
- var size = nodeSize(node);
608
- var kids = node.children || [];
609
- var kdumps = kids.length === 0 ? ' ' : "," + i1 + "children: [" + i2 + kids.map(_dump(i2)).join(i2) + i1 + "]," + i0;
610
- return "{ size: [" + size.join(', ') + "]," + i1 + "x: " + x + ", y: " + y + kdumps + "},";
611
- };
782
+
783
+ dump(tree) {
784
+ const nodeSize = accessor('nodeSize');
785
+
786
+ const _dump = i0 => node => {
787
+ const i1 = i0 + ' ';
788
+ const i2 = i0 + ' ';
789
+ const {
790
+ x,
791
+ y
792
+ } = node;
793
+ const size = nodeSize(node);
794
+ const kids = node.children || [];
795
+ const kdumps = kids.length === 0 ? ' ' : `,${i1}children: [${i2}${kids.map(_dump(i2)).join(i2)}${i1}],${i0}`;
796
+ return `{ size: [${size.join(', ')}],${i1}x: ${x}, y: ${y}${kdumps}},`;
612
797
  };
613
798
 
614
799
  return _dump('\n')(tree);
615
800
  }
801
+
616
802
  });
617
803
  return layout;
618
804
  }
619
805
  flextree.version = version;
620
806
 
621
- var layoutChildren = function layoutChildren(w, y) {
622
- if (y === void 0) {
623
- y = 0;
624
- }
625
-
807
+ const layoutChildren = (w, y = 0) => {
626
808
  w.y = y;
627
- (w.children || []).reduce(function (acc, kid) {
628
- var i = acc[0],
629
- lastLows = acc[1];
809
+ (w.children || []).reduce((acc, kid) => {
810
+ const [i, lastLows] = acc;
630
811
  layoutChildren(kid, w.y + w.ySize); // The lowest vertical coordinate while extreme nodes still point
631
812
  // in current subtree.
632
813
 
633
- var lowY = (i === 0 ? kid.lExt : kid.rExt).bottom;
814
+ const lowY = (i === 0 ? kid.lExt : kid.rExt).bottom;
634
815
  if (i !== 0) separate(w, i, lastLows);
635
- var lows = updateLows(lowY, i, lastLows);
816
+ const lows = updateLows(lowY, i, lastLows);
636
817
  return [i + 1, lows];
637
818
  }, [0, null]);
638
819
  shiftChange(w);
@@ -644,7 +825,7 @@ var layoutChildren = function layoutChildren(w, y) {
644
825
  // to its parent.
645
826
 
646
827
 
647
- var resolveX = function resolveX(w, prevSum, parentX) {
828
+ const resolveX = (w, prevSum, parentX) => {
648
829
  // A call to resolveX without arguments is assumed to be for the root of
649
830
  // the tree. This will set the root's x-coord to zero.
650
831
  if (typeof prevSum === 'undefined') {
@@ -652,24 +833,21 @@ var resolveX = function resolveX(w, prevSum, parentX) {
652
833
  parentX = 0;
653
834
  }
654
835
 
655
- var sum = prevSum + w.relX;
836
+ const sum = prevSum + w.relX;
656
837
  w.relX = sum + w.prelim - parentX;
657
838
  w.prelim = 0;
658
839
  w.x = parentX + w.relX;
659
- (w.children || []).forEach(function (k) {
660
- return resolveX(k, sum, w.x);
661
- });
840
+ (w.children || []).forEach(k => resolveX(k, sum, w.x));
662
841
  return w;
663
842
  }; // Process shift and change for all children, to add intermediate spacing to
664
843
  // each child's modifier.
665
844
 
666
845
 
667
- var shiftChange = function shiftChange(w) {
668
- (w.children || []).reduce(function (acc, child) {
669
- var lastShiftSum = acc[0],
670
- lastChangeSum = acc[1];
671
- var shiftSum = lastShiftSum + child.shift;
672
- var changeSum = lastChangeSum + shiftSum + child.change;
846
+ const shiftChange = w => {
847
+ (w.children || []).reduce((acc, child) => {
848
+ const [lastShiftSum, lastChangeSum] = acc;
849
+ const shiftSum = lastShiftSum + child.shift;
850
+ const changeSum = lastChangeSum + shiftSum + child.change;
673
851
  child.relX += changeSum;
674
852
  return [shiftSum, changeSum];
675
853
  }, [0, 0]);
@@ -678,21 +856,21 @@ var shiftChange = function shiftChange(w) {
678
856
  /* eslint-disable complexity */
679
857
 
680
858
 
681
- var separate = function separate(w, i, lows) {
682
- var lSib = w.children[i - 1];
683
- var curSubtree = w.children[i];
684
- var rContour = lSib;
685
- var rSumMods = lSib.relX;
686
- var lContour = curSubtree;
687
- var lSumMods = curSubtree.relX;
688
- var isFirst = true;
859
+ const separate = (w, i, lows) => {
860
+ const lSib = w.children[i - 1];
861
+ const curSubtree = w.children[i];
862
+ let rContour = lSib;
863
+ let rSumMods = lSib.relX;
864
+ let lContour = curSubtree;
865
+ let lSumMods = curSubtree.relX;
866
+ let isFirst = true;
689
867
 
690
868
  while (rContour && lContour) {
691
869
  if (rContour.bottom > lows.lowY) lows = lows.next; // How far to the left of the right side of rContour is the left side
692
870
  // of lContour? First compute the center-to-center distance, then add
693
871
  // the "spacing"
694
872
 
695
- var dist = rSumMods + rContour.prelim - (lSumMods + lContour.prelim) + rContour.xSize / 2 + lContour.xSize / 2 + rContour.spacing(lContour);
873
+ const dist = rSumMods + rContour.prelim - (lSumMods + lContour.prelim) + rContour.xSize / 2 + lContour.xSize / 2 + rContour.spacing(lContour);
696
874
 
697
875
  if (dist > 0 || dist < 0 && isFirst) {
698
876
  lSumMods += dist; // Move subtree by changing relX.
@@ -703,8 +881,8 @@ var separate = function separate(w, i, lows) {
703
881
 
704
882
  isFirst = false; // Advance highest node(s) and sum(s) of modifiers
705
883
 
706
- var rightBottom = rContour.bottom;
707
- var leftBottom = lContour.bottom;
884
+ const rightBottom = rContour.bottom;
885
+ const leftBottom = lContour.bottom;
708
886
 
709
887
  if (rightBottom <= leftBottom) {
710
888
  rContour = nextRContour(rContour);
@@ -726,39 +904,39 @@ var separate = function separate(w, i, lows) {
726
904
  // Move subtree by changing relX.
727
905
 
728
906
 
729
- var moveSubtree = function moveSubtree(subtree, distance) {
907
+ const moveSubtree = (subtree, distance) => {
730
908
  subtree.relX += distance;
731
909
  subtree.lExtRelX += distance;
732
910
  subtree.rExtRelX += distance;
733
911
  };
734
912
 
735
- var distributeExtra = function distributeExtra(w, curSubtreeI, leftSibI, dist) {
736
- var curSubtree = w.children[curSubtreeI];
737
- var n = curSubtreeI - leftSibI; // Are there intermediate children?
913
+ const distributeExtra = (w, curSubtreeI, leftSibI, dist) => {
914
+ const curSubtree = w.children[curSubtreeI];
915
+ const n = curSubtreeI - leftSibI; // Are there intermediate children?
738
916
 
739
917
  if (n > 1) {
740
- var delta = dist / n;
918
+ const delta = dist / n;
741
919
  w.children[leftSibI + 1].shift += delta;
742
920
  curSubtree.shift -= delta;
743
921
  curSubtree.change -= dist - delta;
744
922
  }
745
923
  };
746
924
 
747
- var nextLContour = function nextLContour(w) {
925
+ const nextLContour = w => {
748
926
  return w.hasChildren ? w.firstChild : w.lThr;
749
927
  };
750
928
 
751
- var nextRContour = function nextRContour(w) {
929
+ const nextRContour = w => {
752
930
  return w.hasChildren ? w.lastChild : w.rThr;
753
931
  };
754
932
 
755
- var setLThr = function setLThr(w, i, lContour, lSumMods) {
756
- var firstChild = w.firstChild;
757
- var lExt = firstChild.lExt;
758
- var curSubtree = w.children[i];
933
+ const setLThr = (w, i, lContour, lSumMods) => {
934
+ const firstChild = w.firstChild;
935
+ const lExt = firstChild.lExt;
936
+ const curSubtree = w.children[i];
759
937
  lExt.lThr = lContour; // Change relX so that the sum of modifier after following thread is correct.
760
938
 
761
- var diff = lSumMods - lContour.relX - firstChild.lExtRelX;
939
+ const diff = lSumMods - lContour.relX - firstChild.lExtRelX;
762
940
  lExt.relX += diff; // Change preliminary x coordinate so that the node does not move.
763
941
 
764
942
  lExt.prelim -= diff; // Update extreme node and its sum of modifiers.
@@ -768,12 +946,12 @@ var setLThr = function setLThr(w, i, lContour, lSumMods) {
768
946
  }; // Mirror image of setLThr.
769
947
 
770
948
 
771
- var setRThr = function setRThr(w, i, rContour, rSumMods) {
772
- var curSubtree = w.children[i];
773
- var rExt = curSubtree.rExt;
774
- var lSib = w.children[i - 1];
949
+ const setRThr = (w, i, rContour, rSumMods) => {
950
+ const curSubtree = w.children[i];
951
+ const rExt = curSubtree.rExt;
952
+ const lSib = w.children[i - 1];
775
953
  rExt.rThr = rContour;
776
- var diff = rSumMods - rContour.relX - curSubtree.rExtRelX;
954
+ const diff = rSumMods - rContour.relX - curSubtree.rExtRelX;
777
955
  rExt.relX += diff;
778
956
  rExt.prelim -= diff;
779
957
  curSubtree.rExt = lSib.rExt;
@@ -781,13 +959,13 @@ var setRThr = function setRThr(w, i, rContour, rSumMods) {
781
959
  }; // Position root between children, taking into account their modifiers
782
960
 
783
961
 
784
- var positionRoot = function positionRoot(w) {
962
+ const positionRoot = w => {
785
963
  if (w.hasChildren) {
786
- var k0 = w.firstChild;
787
- var kf = w.lastChild;
788
- var prelim = (k0.prelim + k0.relX - k0.xSize / 2 + kf.relX + kf.prelim + kf.xSize / 2) / 2;
964
+ const k0 = w.firstChild;
965
+ const kf = w.lastChild;
966
+ const prelim = (k0.prelim + k0.relX - k0.xSize / 2 + kf.relX + kf.prelim + kf.xSize / 2) / 2;
789
967
  Object.assign(w, {
790
- prelim: prelim,
968
+ prelim,
791
969
  lExt: k0.lExt,
792
970
  lExtRelX: k0.lExtRelX,
793
971
  rExt: kf.rExt,
@@ -798,226 +976,257 @@ var positionRoot = function positionRoot(w) {
798
976
  // lowest vertical coordinate.
799
977
 
800
978
 
801
- var updateLows = function updateLows(lowY, index, lastLows) {
979
+ const updateLows = (lowY, index, lastLows) => {
802
980
  // Remove siblings that are hidden by the new subtree.
803
- while (lastLows !== null && lowY >= lastLows.lowY) {
804
- lastLows = lastLows.next;
805
- } // Prepend the new subtree.
981
+ while (lastLows !== null && lowY >= lastLows.lowY) lastLows = lastLows.next; // Prepend the new subtree.
806
982
 
807
983
 
808
984
  return {
809
- lowY: lowY,
810
- index: index,
985
+ lowY,
986
+ index,
811
987
  next: lastLows
812
988
  };
813
989
  };
814
990
 
815
- /*! markmap-common v0.1.5 | MIT License */
816
- class Hook {
817
- constructor() {
818
- this.listeners = [];
819
- }
991
+ /*! @gera2ld/jsx-dom v2.1.1 | ISC License */
992
+ var VTYPE_ELEMENT = 1;
993
+ var VTYPE_FUNCTION = 2;
994
+ var MOUNT_SINGLE = 1;
995
+ var MOUNT_ARRAY = 4;
996
+ var SVG_NS = 'http://www.w3.org/2000/svg';
997
+ var XLINK_NS = 'http://www.w3.org/1999/xlink';
998
+ var NS_ATTRS = {
999
+ show: XLINK_NS,
1000
+ actuate: XLINK_NS,
1001
+ href: XLINK_NS
1002
+ };
820
1003
 
821
- tap(fn) {
822
- this.listeners.push(fn);
823
- return () => this.revoke(fn);
824
- }
1004
+ var isLeaf = function isLeaf(c) {
1005
+ return typeof c === 'string' || typeof c === 'number';
1006
+ };
825
1007
 
826
- revoke(fn) {
827
- const i = this.listeners.indexOf(fn);
828
- if (i >= 0) this.listeners.splice(i, 1);
829
- }
1008
+ var isElement = function isElement(c) {
1009
+ return (c == null ? void 0 : c.vtype) === VTYPE_ELEMENT;
1010
+ };
830
1011
 
831
- revokeAll() {
832
- this.listeners.splice(0);
1012
+ var isRenderFunction = function isRenderFunction(c) {
1013
+ return (c == null ? void 0 : c.vtype) === VTYPE_FUNCTION;
1014
+ };
1015
+
1016
+ function jsx(type, props) {
1017
+ var vtype;
1018
+ if (typeof type === 'string') vtype = VTYPE_ELEMENT;else if (typeof type === 'function') vtype = VTYPE_FUNCTION;else throw new Error('Invalid VNode type');
1019
+ return {
1020
+ vtype: vtype,
1021
+ type: type,
1022
+ props: props
1023
+ };
1024
+ }
1025
+
1026
+ function Fragment(props) {
1027
+ return props.children;
1028
+ }
1029
+
1030
+ var DEFAULT_ENV = {
1031
+ isSvg: false
1032
+ };
1033
+
1034
+ function insertDom(parent, ref) {
1035
+ if (ref.type === MOUNT_SINGLE) {
1036
+ if (ref.node != null) parent.append(ref.node);
1037
+ } else if (ref.type === MOUNT_ARRAY) {
1038
+ ref.children.forEach(function (ch) {
1039
+ insertDom(parent, ch);
1040
+ });
1041
+ } else {
1042
+ throw new Error("Unkown ref type " + JSON.stringify(ref));
833
1043
  }
1044
+ }
834
1045
 
835
- call(...args) {
836
- for (const fn of this.listeners) {
837
- fn(...args);
1046
+ function mountAttributes(domElement, props, env) {
1047
+ for (var key in props) {
1048
+ if (key === 'key' || key === 'children' || key === 'ref') continue;
1049
+
1050
+ if (key === 'dangerouslySetInnerHTML') {
1051
+ domElement.innerHTML = props[key].__html;
1052
+ } else if (key === 'innerHTML' || key === 'textContent' || key === 'innerText') {
1053
+ domElement[key] = props[key];
1054
+ } else if (key.startsWith('on')) {
1055
+ domElement[key.toLowerCase()] = props[key];
1056
+ } else {
1057
+ setDOMAttribute(domElement, key, props[key], env.isSvg);
838
1058
  }
839
1059
  }
840
-
841
1060
  }
842
1061
 
843
- function _extends() {
844
- _extends = Object.assign || function (target) {
845
- for (var i = 1; i < arguments.length; i++) {
846
- var source = arguments[i];
1062
+ var attrMap = {
1063
+ className: 'class',
1064
+ labelFor: 'for'
1065
+ };
847
1066
 
848
- for (var key in source) {
849
- if (Object.prototype.hasOwnProperty.call(source, key)) {
850
- target[key] = source[key];
851
- }
852
- }
853
- }
1067
+ function setDOMAttribute(el, attr, value, isSVG) {
1068
+ attr = attrMap[attr] || attr;
854
1069
 
855
- return target;
856
- };
1070
+ if (value === true) {
1071
+ el.setAttribute(attr, '');
1072
+ } else if (value === false) {
1073
+ el.removeAttribute(attr);
1074
+ } else {
1075
+ var namespace = isSVG ? NS_ATTRS[attr] : undefined;
857
1076
 
858
- return _extends.apply(this, arguments);
1077
+ if (namespace !== undefined) {
1078
+ el.setAttributeNS(namespace, attr, value);
1079
+ } else {
1080
+ el.setAttribute(attr, value);
1081
+ }
1082
+ }
859
1083
  }
860
1084
 
861
- const uniqId = Math.random().toString(36).slice(2, 8);
862
- let globalIndex = 0;
1085
+ function mount(vnode, env) {
1086
+ if (env === void 0) {
1087
+ env = DEFAULT_ENV;
1088
+ }
863
1089
 
864
- function getId() {
865
- globalIndex += 1;
866
- return `mm-${uniqId}-${globalIndex}`;
867
- }
1090
+ if (vnode == null || typeof vnode === 'boolean') {
1091
+ return {
1092
+ type: MOUNT_SINGLE,
1093
+ node: null
1094
+ };
1095
+ }
868
1096
 
869
- function noop() {// noop
870
- }
1097
+ if (vnode instanceof Node) {
1098
+ return {
1099
+ type: MOUNT_SINGLE,
1100
+ node: vnode
1101
+ };
1102
+ }
871
1103
 
872
- function walkTree(tree, callback, key = 'c') {
873
- const walk = (item, parent) => callback(item, () => {
874
- var _item$key;
1104
+ if (isRenderFunction(vnode)) {
1105
+ var _ref = vnode,
1106
+ type = _ref.type,
1107
+ props = _ref.props;
875
1108
 
876
- (_item$key = item[key]) == null ? void 0 : _item$key.forEach(child => {
877
- walk(child, item);
878
- });
879
- }, parent);
1109
+ if (type === Fragment) {
1110
+ var node = document.createDocumentFragment();
880
1111
 
881
- walk(tree);
882
- }
1112
+ if (props.children) {
1113
+ var childrenRef = mount(props.children, env);
1114
+ insertDom(node, childrenRef);
1115
+ }
883
1116
 
884
- function arrayFrom(arrayLike) {
885
- if (Array.from) return Array.from(arrayLike);
886
- const array = [];
1117
+ return {
1118
+ type: MOUNT_SINGLE,
1119
+ node: node
1120
+ };
1121
+ }
887
1122
 
888
- for (let i = 0; i < arrayLike.length; i += 1) {
889
- array.push(arrayLike[i]);
1123
+ var childVNode = type(props);
1124
+ return mount(childVNode, env);
890
1125
  }
891
1126
 
892
- return array;
893
- }
1127
+ if (isLeaf(vnode)) {
1128
+ return {
1129
+ type: MOUNT_SINGLE,
1130
+ node: document.createTextNode("" + vnode)
1131
+ };
1132
+ }
894
1133
 
895
- function addClass(className, ...rest) {
896
- const classList = (className || '').split(' ').filter(Boolean);
897
- rest.forEach(item => {
898
- if (item && classList.indexOf(item) < 0) classList.push(item);
899
- });
900
- return classList.join(' ');
901
- }
1134
+ if (isElement(vnode)) {
1135
+ var _node;
902
1136
 
903
- function childSelector(filter) {
904
- if (typeof filter === 'string') {
905
- const tagName = filter;
1137
+ var _ref2 = vnode,
1138
+ _type = _ref2.type,
1139
+ _props = _ref2.props;
906
1140
 
907
- filter = el => el.tagName === tagName;
908
- }
1141
+ if (!env.isSvg && _type === 'svg') {
1142
+ env = Object.assign({}, env, {
1143
+ isSvg: true
1144
+ });
1145
+ }
909
1146
 
910
- const filterFn = filter;
911
- return function selector() {
912
- let nodes = arrayFrom(this.childNodes);
913
- if (filterFn) nodes = nodes.filter(node => filterFn(node));
914
- return nodes;
915
- };
916
- }
1147
+ if (!env.isSvg) {
1148
+ _node = document.createElement(_type);
1149
+ } else {
1150
+ _node = document.createElementNS(SVG_NS, _type);
1151
+ }
917
1152
 
918
- function memoize(fn) {
919
- const cache = {};
920
- return function memoized(...args) {
921
- const key = `${args[0]}`;
922
- let data = cache[key];
1153
+ mountAttributes(_node, _props, env);
923
1154
 
924
- if (!data) {
925
- data = {
926
- value: fn(...args)
927
- };
928
- cache[key] = data;
929
- }
1155
+ var _childrenRef;
930
1156
 
931
- return data.value;
932
- };
933
- }
1157
+ if (_props.children) {
1158
+ var childEnv = env;
934
1159
 
935
- function createElement(tagName, props, attrs) {
936
- const el = document.createElement(tagName);
1160
+ if (env.isSvg && _type === 'foreignObject') {
1161
+ childEnv = Object.assign({}, childEnv, {
1162
+ isSvg: false
1163
+ });
1164
+ }
937
1165
 
938
- if (props) {
939
- Object.entries(props).forEach(([key, value]) => {
940
- el[key] = value;
941
- });
1166
+ _childrenRef = mount(_props.children, childEnv);
1167
+ }
1168
+
1169
+ if (_childrenRef != null) insertDom(_node, _childrenRef);
1170
+ var ref = _props.ref;
1171
+ if (typeof ref === 'function') ref(_node);
1172
+ return {
1173
+ type: MOUNT_SINGLE,
1174
+ node: _node
1175
+ };
942
1176
  }
943
1177
 
944
- if (attrs) {
945
- Object.entries(attrs).forEach(([key, value]) => {
946
- el.setAttribute(key, value);
947
- });
1178
+ if (Array.isArray(vnode)) {
1179
+ return {
1180
+ type: MOUNT_ARRAY,
1181
+ children: vnode.map(function (child) {
1182
+ return mount(child, env);
1183
+ })
1184
+ };
948
1185
  }
949
1186
 
950
- return el;
1187
+ throw new Error('mount: Invalid Vnode!');
951
1188
  }
952
1189
 
953
- const memoizedPreloadJS = memoize(url => {
954
- document.head.append(createElement('link', {
955
- rel: 'preload',
956
- as: 'script',
957
- href: url
958
- }));
959
- });
960
-
961
- function loadJSItem(item, context) {
962
- if (item.type === 'script') {
963
- return new Promise((resolve, reject) => {
964
- var _item$data;
965
-
966
- document.head.append(createElement('script', _extends({}, item.data, {
967
- onload: resolve,
968
- onerror: reject
969
- }))); // Run inline script synchronously
1190
+ function flattenWithoutNull(array) {
1191
+ var result = [];
970
1192
 
971
- if (!((_item$data = item.data) != null && _item$data.src)) resolve();
972
- });
1193
+ for (var i = 0; i < array.length; i += 1) {
1194
+ var item = array[i];
1195
+ if (Array.isArray(item)) result = result.concat(flattenWithoutNull(item));else if (item != null) result.push(item);
973
1196
  }
974
1197
 
975
- if (item.type === 'iife') {
976
- const {
977
- fn,
978
- getParams
979
- } = item.data;
980
- fn(...((getParams == null ? void 0 : getParams(context)) || []));
981
- }
1198
+ return result;
982
1199
  }
983
1200
 
984
- function loadCSSItem(item) {
985
- if (item.type === 'style') {
986
- document.head.append(createElement('style', {
987
- textContent: item.data
988
- }));
989
- } else if (item.type === 'stylesheet') {
990
- document.head.append(createElement('link', _extends({
991
- rel: 'stylesheet'
992
- }, item.data)));
1201
+ function asDom(result) {
1202
+ if (result.type === MOUNT_SINGLE) {
1203
+ return result.node;
993
1204
  }
994
- }
995
1205
 
996
- async function loadJS(items, context) {
997
- const needPreload = items.filter(item => {
998
- var _item$data2;
1206
+ return result.children.map(asDom);
1207
+ }
1208
+ /**
1209
+ * Mount vdom as real DOM nodes.
1210
+ */
999
1211
 
1000
- return item.type === 'script' && ((_item$data2 = item.data) == null ? void 0 : _item$data2.src);
1001
- });
1002
- if (needPreload.length > 1) needPreload.forEach(item => memoizedPreloadJS(item.data.src));
1003
- context = _extends({
1004
- getMarkmap: () => window.markmap
1005
- }, context);
1006
1212
 
1007
- for (const item of items) {
1008
- await loadJSItem(item, context);
1213
+ function mountDom(vnode) {
1214
+ if (Array.isArray(vnode)) {
1215
+ return flattenWithoutNull(vnode.map(mountDom));
1009
1216
  }
1010
- }
1011
1217
 
1012
- function loadCSS(items) {
1013
- for (const item of items) {
1014
- loadCSSItem(item);
1015
- }
1218
+ return asDom(mount(vnode));
1016
1219
  }
1017
1220
 
1221
+ 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:bolder}.markmap-foreign mark{background:#ffeaa7}.markmap-foreign pre,.markmap-foreign pre[class*=language-]{margin:0;padding:.2em .4em}";
1222
+
1223
+ var css_248z = ".markmap-container{height:0;left:-100px;overflow:hidden;position:absolute;top:-100px;width:0}.markmap-container>*{display:inline-block}.markmap-container>*>.markmap-foreign:last-child{white-space:nowrap}";
1224
+
1225
+ const globalCSS = css_248z$1;
1226
+
1018
1227
  function linkWidth(nodeData) {
1019
1228
  const data = nodeData.data;
1020
- return Math.max(6 - 2 * data.d, 1.5);
1229
+ return Math.max(6 - 2 * data.depth, 1.5);
1021
1230
  }
1022
1231
 
1023
1232
  function adjustSpacing(tree, spacing) {
@@ -1048,30 +1257,32 @@ function createViewHooks() {
1048
1257
 
1049
1258
 
1050
1259
  const refreshHook = new Hook();
1260
+ const defaultColorFn = d3__namespace.scaleOrdinal(d3__namespace.schemeCategory10);
1261
+ const isMacintosh = typeof navigator !== 'undefined' && navigator.userAgent.includes('Macintosh');
1051
1262
  class Markmap {
1052
1263
  constructor(svg, opts) {
1053
- this.options = void 0;
1054
- this.state = void 0;
1055
- this.svg = void 0;
1056
- this.styleNode = void 0;
1057
- this.g = void 0;
1058
- this.zoom = void 0;
1059
- this.viewHooks = void 0;
1060
1264
  this.revokers = [];
1061
- ['handleZoom', 'handleClick'].forEach(key => {
1265
+ ['handleZoom', 'handleClick', 'handlePan'].forEach(key => {
1062
1266
  this[key] = this[key].bind(this);
1063
1267
  });
1064
1268
  this.viewHooks = createViewHooks();
1065
1269
  this.svg = svg.datum ? svg : d3__namespace.select(svg);
1066
1270
  this.styleNode = this.svg.append('style');
1067
- this.zoom = d3__namespace.zoom().on('zoom', this.handleZoom);
1068
- this.options = _extends$1({}, Markmap.defaultOptions, opts);
1271
+ this.zoom = d3__namespace.zoom().filter(event => {
1272
+ if (this.options.scrollForPan) {
1273
+ // Pan with wheels, zoom with ctrl+wheels
1274
+ if (event.type === 'wheel') return event.ctrlKey && !event.button;
1275
+ }
1276
+
1277
+ return (!event.ctrlKey || event.type === 'wheel') && !event.button;
1278
+ }).on('zoom', this.handleZoom);
1279
+ this.setOptions(opts);
1069
1280
  this.state = {
1070
- id: this.options.id || getId()
1281
+ id: this.options.id || this.svg.attr('id') || getId()
1071
1282
  };
1072
- this.g = this.svg.append('g').attr('class', `${this.state.id}-g`);
1283
+ this.g = this.svg.append('g');
1073
1284
  this.updateStyle();
1074
- this.svg.call(this.zoom);
1285
+ this.svg.call(this.zoom).on('wheel', this.handlePan);
1075
1286
  this.revokers.push(refreshHook.tap(() => {
1076
1287
  this.setData();
1077
1288
  }));
@@ -1079,34 +1290,19 @@ class Markmap {
1079
1290
 
1080
1291
  getStyleContent() {
1081
1292
  const {
1082
- style,
1083
- nodeFont
1293
+ style
1084
1294
  } = this.options;
1085
1295
  const {
1086
1296
  id
1087
1297
  } = this.state;
1088
- const extraStyle = typeof style === 'function' ? style(id) : '';
1089
- const styleText = `\
1090
- .${id} { line-height: 1; }
1091
- .${id} a { color: #0097e6; }
1092
- .${id} a:hover { color: #00a8ff; }
1093
- .${id}-g > path { fill: none; }
1094
- .${id}-g > g > circle { cursor: pointer; }
1095
- .${id}-fo > div { display: inline-block; font: ${nodeFont}; white-space: nowrap; }
1096
- .${id}-fo code { font-size: calc(1em - 2px); color: #555; background-color: #f0f0f0; border-radius: 2px; }
1097
- .${id}-fo :not(pre) > code { padding: .2em .4em; }
1098
- .${id}-fo del { text-decoration: line-through; }
1099
- .${id}-fo em { font-style: italic; }
1100
- .${id}-fo strong { font-weight: bolder; }
1101
- .${id}-fo pre { margin: 0; padding: .2em .4em; }
1102
- ${extraStyle}
1103
- `;
1104
- return styleText;
1298
+ const styleText = typeof style === 'function' ? style(id) : '';
1299
+ return [this.options.embedGlobalCSS && css_248z$1, styleText].filter(Boolean).join('\n');
1105
1300
  }
1106
1301
 
1107
1302
  updateStyle() {
1108
- this.svg.attr('class', addClass(this.svg.attr('class'), this.state.id));
1109
- this.styleNode.text(this.getStyleContent());
1303
+ this.svg.attr('class', addClass(this.svg.attr('class'), 'markmap', this.state.id));
1304
+ const style = this.getStyleContent();
1305
+ this.styleNode.text(style);
1110
1306
  }
1111
1307
 
1112
1308
  handleZoom(e) {
@@ -1116,76 +1312,84 @@ ${extraStyle}
1116
1312
  this.g.attr('transform', transform);
1117
1313
  }
1118
1314
 
1119
- handleClick(e, d) {
1120
- var _data$p;
1315
+ handlePan(e) {
1316
+ e.preventDefault();
1317
+ const transform = d3__namespace.zoomTransform(this.svg.node());
1318
+ const newTransform = transform.translate(-e.deltaX, -e.deltaY);
1319
+ this.svg.call(this.zoom.transform, newTransform);
1320
+ }
1321
+
1322
+ handleClick(_, d) {
1323
+ var _data$payload;
1121
1324
 
1122
1325
  const {
1123
1326
  data
1124
1327
  } = d;
1125
- data.p = _extends$1({}, data.p, {
1126
- f: !((_data$p = data.p) != null && _data$p.f)
1328
+ data.payload = _extends({}, data.payload, {
1329
+ fold: !((_data$payload = data.payload) != null && _data$payload.fold)
1127
1330
  });
1128
1331
  this.renderData(d.data);
1129
1332
  }
1130
1333
 
1131
1334
  initializeData(node) {
1132
- let i = 0;
1335
+ let nodeId = 0;
1133
1336
  const {
1134
- nodeFont,
1135
1337
  color,
1136
- nodeMinHeight
1338
+ nodeMinHeight,
1339
+ maxWidth
1137
1340
  } = this.options;
1138
1341
  const {
1139
1342
  id
1140
1343
  } = this.state;
1141
- const container = document.createElement('div');
1142
- const containerClass = `${id}-container`;
1143
- container.className = addClass(container.className, `${id}-fo`, containerClass);
1144
- const style = document.createElement('style');
1145
- style.textContent = `
1146
- ${this.getStyleContent()}
1147
- .${containerClass} {
1148
- position: absolute;
1149
- width: 0;
1150
- height: 0;
1151
- top: -100px;
1152
- left: -100px;
1153
- overflow: hidden;
1154
- font: ${nodeFont};
1155
- }
1156
- .${containerClass} > div {
1157
- display: inline-block;
1158
- }
1159
- `;
1160
- document.body.append(style, container);
1344
+ const container = mountDom(jsx("div", {
1345
+ className: `markmap-container markmap ${id}-g`
1346
+ }));
1347
+ const style = mountDom(jsx("style", {
1348
+ children: [this.getStyleContent(), css_248z].join('\n')
1349
+ }));
1350
+ document.body.append(container, style);
1351
+ const groupStyle = maxWidth ? `max-width: ${maxWidth}px` : null;
1161
1352
  walkTree(node, (item, next) => {
1162
- var _item$c;
1163
-
1164
- item.c = (_item$c = item.c) == null ? void 0 : _item$c.map(child => _extends$1({}, child));
1165
- i += 1;
1166
- const el = document.createElement('div');
1167
- el.innerHTML = item.v;
1168
- container.append(el);
1169
- item.p = _extends$1({}, item.p, {
1170
- // unique ID
1171
- i,
1172
- el
1353
+ var _item$children;
1354
+
1355
+ item.children = (_item$children = item.children) == null ? void 0 : _item$children.map(child => _extends({}, child));
1356
+ nodeId += 1;
1357
+ const group = mountDom(jsx("div", {
1358
+ style: groupStyle,
1359
+ children: jsx("div", {
1360
+ className: "markmap-foreign",
1361
+ dangerouslySetInnerHTML: {
1362
+ __html: item.content
1363
+ }
1364
+ })
1365
+ }));
1366
+ container.append(group);
1367
+ item.state = _extends({}, item.state, {
1368
+ id: nodeId,
1369
+ el: group.firstChild
1173
1370
  });
1174
1371
  color(item); // preload colors
1175
1372
 
1176
1373
  next();
1177
1374
  });
1178
- const nodes = arrayFrom(container.childNodes);
1179
- this.viewHooks.transformHtml.call(this, nodes);
1375
+ const nodes = arrayFrom(container.childNodes).map(group => group.firstChild);
1376
+ this.viewHooks.transformHtml.call(this, nodes); // Clone the rendered HTML and set `white-space: nowrap` to it to detect its max-width.
1377
+ // The parent node will have a width of the max-width and the original content without
1378
+ // `white-space: nowrap` gets re-layouted, then we will get the expected layout, with
1379
+ // content in one line as much as possible, and subjecting to the given max-width.
1380
+
1381
+ nodes.forEach(node => {
1382
+ node.parentNode.append(node.cloneNode(true));
1383
+ });
1180
1384
  walkTree(node, (item, next, parent) => {
1181
- var _parent$p;
1182
-
1183
- const rect = item.p.el.getBoundingClientRect();
1184
- item.v = item.p.el.innerHTML;
1185
- item.p.s = [Math.ceil(rect.width), Math.max(Math.ceil(rect.height), nodeMinHeight)]; // TODO keep keys for unchanged objects
1186
- // unique key, should be based on content
1187
-
1188
- item.p.k = `${(parent == null ? void 0 : (_parent$p = parent.p) == null ? void 0 : _parent$p.i) || ''}.${item.p.i}:${item.v}`;
1385
+ var _parent$state, _parent$state2;
1386
+
1387
+ const rect = item.state.el.getBoundingClientRect();
1388
+ item.content = item.state.el.innerHTML;
1389
+ item.state.size = [Math.ceil(rect.width) + 1, Math.max(Math.ceil(rect.height), nodeMinHeight)];
1390
+ item.state.path = [parent == null ? void 0 : (_parent$state = parent.state) == null ? void 0 : _parent$state.path, item.state.id].filter(Boolean).join('.');
1391
+ item.state.key = [parent == null ? void 0 : (_parent$state2 = parent.state) == null ? void 0 : _parent$state2.id, item.state.id].filter(Boolean).join('.') + // FIXME: find a way to check content hash
1392
+ item.content;
1189
1393
  next();
1190
1394
  });
1191
1395
  container.remove();
@@ -1193,7 +1397,7 @@ ${this.getStyleContent()}
1193
1397
  }
1194
1398
 
1195
1399
  setOptions(opts) {
1196
- Object.assign(this.options, opts);
1400
+ this.options = _extends({}, Markmap.defaultOptions, opts);
1197
1401
  }
1198
1402
 
1199
1403
  setData(data, opts) {
@@ -1204,7 +1408,7 @@ ${this.getStyleContent()}
1204
1408
  }
1205
1409
 
1206
1410
  renderData(originData) {
1207
- var _origin$data$p$x, _origin$data$p$y;
1411
+ var _origin$data$state$x, _origin$data$state$y;
1208
1412
 
1209
1413
  if (!this.state.data) return;
1210
1414
  const {
@@ -1214,15 +1418,12 @@ ${this.getStyleContent()}
1214
1418
  autoFit,
1215
1419
  color
1216
1420
  } = this.options;
1217
- const {
1218
- id
1219
- } = this.state;
1220
1421
  const layout = flextree().children(d => {
1221
- var _d$p;
1422
+ var _d$payload;
1222
1423
 
1223
- return !((_d$p = d.p) != null && _d$p.f) && d.c;
1424
+ return !((_d$payload = d.payload) != null && _d$payload.fold) && d.children;
1224
1425
  }).nodeSize(d => {
1225
- const [width, height] = d.data.p.s;
1426
+ const [width, height] = d.data.state.size;
1226
1427
  return [height, width + (width ? paddingX * 2 : 0) + spacingHorizontal];
1227
1428
  }).spacing((a, b) => {
1228
1429
  return a.parent === b.parent ? spacingVertical : spacingVertical * 2;
@@ -1245,43 +1446,45 @@ ${this.getStyleContent()}
1245
1446
  });
1246
1447
  if (autoFit) this.fit();
1247
1448
  const origin = originData && descendants.find(item => item.data === originData) || tree;
1248
- const x0 = (_origin$data$p$x = origin.data.p.x0) != null ? _origin$data$p$x : origin.x;
1249
- const y0 = (_origin$data$p$y = origin.data.p.y0) != null ? _origin$data$p$y : origin.y; // Update the nodes
1449
+ const x0 = (_origin$data$state$x = origin.data.state.x0) != null ? _origin$data$state$x : origin.x;
1450
+ const y0 = (_origin$data$state$y = origin.data.state.y0) != null ? _origin$data$state$y : origin.y; // Update the nodes
1250
1451
 
1251
- const node = this.g.selectAll(childSelector('g')).data(descendants, d => d.data.p.k);
1252
- const nodeEnter = node.enter().append('g').attr('transform', d => `translate(${y0 + origin.ySizeInner - d.ySizeInner},${x0 + origin.xSize / 2 - d.xSize})`);
1452
+ const node = this.g.selectAll(childSelector('g')).data(descendants, d => d.data.state.key);
1453
+ const nodeEnter = node.enter().append('g').attr('class', 'markmap-node').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})`);
1253
1454
  const nodeExit = this.transition(node.exit());
1254
- nodeExit.select('rect').attr('width', 0).attr('x', d => d.ySizeInner);
1455
+ nodeExit.select('line').attr('x1', d => d.ySizeInner).attr('x2', d => d.ySizeInner);
1255
1456
  nodeExit.select('foreignObject').style('opacity', 0);
1256
1457
  nodeExit.attr('transform', d => `translate(${origin.y + origin.ySizeInner - d.ySizeInner},${origin.x + origin.xSize / 2 - d.xSize})`).remove();
1257
1458
  const nodeMerge = node.merge(nodeEnter);
1258
- this.transition(nodeMerge).attr('transform', d => `translate(${d.y},${d.x - d.xSize / 2})`);
1259
- const rect = nodeMerge.selectAll(childSelector('rect')).data(d => [d], d => d.data.p.k).join(enter => {
1260
- return enter.append('rect').attr('x', d => d.ySizeInner).attr('y', d => d.xSize - linkWidth(d) / 2).attr('width', 0).attr('height', linkWidth);
1459
+ this.transition(nodeMerge).attr('transform', d => `translate(${d.y},${d.x - d.xSize / 2})`); // Update lines under the content
1460
+
1461
+ const line = nodeMerge.selectAll(childSelector('line')).data(d => [d], d => d.data.state.key).join(enter => {
1462
+ return enter.append('line').attr('x1', d => d.ySizeInner).attr('y1', d => d.xSize).attr('x2', d => d.ySizeInner).attr('y2', d => d.xSize);
1261
1463
  }, update => update, exit => exit.remove());
1262
- this.transition(rect).attr('x', -1).attr('width', d => d.ySizeInner + 2).attr('fill', d => color(d.data));
1263
- const circle = nodeMerge.selectAll(childSelector('circle')).data(d => d.data.c ? [d] : [], d => d.data.p.k).join(enter => {
1464
+ this.transition(line).attr('x1', -1).attr('x2', d => d.ySizeInner + 2).attr('stroke', d => color(d.data)).attr('stroke-width', linkWidth); // Circle to link to children of the node
1465
+
1466
+ const circle = nodeMerge.selectAll(childSelector('circle')).data(d => d.data.children ? [d] : [], d => d.data.state.key).join(enter => {
1264
1467
  return enter.append('circle').attr('stroke-width', '1.5').attr('cx', d => d.ySizeInner).attr('cy', d => d.xSize).attr('r', 0).on('click', this.handleClick);
1265
1468
  }, update => update, exit => exit.remove());
1266
1469
  this.transition(circle).attr('r', 6).attr('stroke', d => color(d.data)).attr('fill', d => {
1267
- var _d$data$p;
1470
+ var _d$data$payload;
1268
1471
 
1269
- return (_d$data$p = d.data.p) != null && _d$data$p.f && d.data.c ? color(d.data) : '#fff';
1472
+ return (_d$data$payload = d.data.payload) != null && _d$data$payload.fold && d.data.children ? color(d.data) : '#fff';
1270
1473
  });
1271
- const foreignObject = nodeMerge.selectAll(childSelector('foreignObject')).data(d => [d], d => d.data.p.k).join(enter => {
1272
- const fo = enter.append('foreignObject').attr('class', `${id}-fo`).attr('x', paddingX).attr('y', 0).style('opacity', 0).attr('height', d => d.xSize).on('mousedown', stopPropagation).on('dblclick', stopPropagation);
1474
+ const foreignObject = nodeMerge.selectAll(childSelector('foreignObject')).data(d => [d], d => d.data.state.key).join(enter => {
1475
+ const fo = enter.append('foreignObject').attr('class', 'markmap-foreign').attr('x', paddingX).attr('y', 0).style('opacity', 0).attr('height', d => d.xSize).on('mousedown', stopPropagation).on('dblclick', stopPropagation);
1273
1476
  fo.append('xhtml:div').select(function select(d) {
1274
- const node = d.data.p.el.cloneNode(true);
1275
- this.replaceWith(node);
1276
- return node;
1477
+ const clone = d.data.state.el.cloneNode(true);
1478
+ this.replaceWith(clone);
1479
+ return clone;
1277
1480
  }).attr('xmlns', 'http://www.w3.org/1999/xhtml');
1278
1481
  return fo;
1279
1482
  }, update => update, exit => exit.remove()).attr('width', d => Math.max(0, d.ySizeInner - paddingX * 2));
1280
1483
  this.transition(foreignObject).style('opacity', 1); // Update the links
1281
1484
 
1282
- const path = this.g.selectAll(childSelector('path')).data(links, d => d.target.data.p.k).join(enter => {
1485
+ const path = this.g.selectAll(childSelector('path')).data(links, d => d.target.data.state.key).join(enter => {
1283
1486
  const source = [y0 + origin.ySizeInner, x0 + origin.xSize / 2];
1284
- return enter.insert('path', 'g').attr('d', linkShape({
1487
+ 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({
1285
1488
  source,
1286
1489
  target: source
1287
1490
  }));
@@ -1301,8 +1504,8 @@ ${this.getStyleContent()}
1301
1504
  });
1302
1505
  });
1303
1506
  descendants.forEach(d => {
1304
- d.data.p.x0 = d.x;
1305
- d.data.p.y0 = d.y;
1507
+ d.data.state.x0 = d.x;
1508
+ d.data.state.y0 = d.y;
1306
1509
  });
1307
1510
  }
1308
1511
 
@@ -1359,7 +1562,7 @@ ${this.getStyleContent()}
1359
1562
  const [left, right] = [itemData.y, itemData.y + itemData.ySizeInner + 2].map(x => x * transform.k + transform.x);
1360
1563
  const [top, bottom] = [itemData.x - itemData.xSize / 2, itemData.x + itemData.xSize / 2].map(y => y * transform.k + transform.y); // Skip if the node includes or is included in the container.
1361
1564
 
1362
- const pd = _extends$1({
1565
+ const pd = _extends({
1363
1566
  left: 0,
1364
1567
  right: 0,
1365
1568
  top: 0,
@@ -1395,7 +1598,8 @@ ${this.getStyleContent()}
1395
1598
  }
1396
1599
 
1397
1600
  destroy() {
1398
- this.svg.remove();
1601
+ this.svg.on('.zoom', null);
1602
+ this.svg.html(null);
1399
1603
  this.revokers.forEach(fn => {
1400
1604
  fn();
1401
1605
  });
@@ -1414,18 +1618,55 @@ ${this.getStyleContent()}
1414
1618
 
1415
1619
  }
1416
1620
  Markmap.defaultOptions = {
1621
+ autoFit: false,
1622
+ color: node => defaultColorFn(`${node.state.id}`),
1417
1623
  duration: 500,
1418
- nodeFont: '300 16px/20px sans-serif',
1624
+ embedGlobalCSS: true,
1625
+ fitRatio: 0.95,
1626
+ maxWidth: 0,
1419
1627
  nodeMinHeight: 16,
1420
- spacingVertical: 5,
1628
+ paddingX: 8,
1629
+ scrollForPan: isMacintosh,
1421
1630
  spacingHorizontal: 80,
1422
- autoFit: false,
1423
- fitRatio: 0.95,
1424
- color: (colorFn => node => colorFn(node.p.i))(d3__namespace.scaleOrdinal(d3__namespace.schemeCategory10)),
1425
- paddingX: 8
1631
+ spacingVertical: 5
1426
1632
  };
1633
+ function deriveOptions(jsonOptions) {
1634
+ const {
1635
+ color,
1636
+ duration,
1637
+ maxWidth
1638
+ } = jsonOptions || {};
1639
+ let opts;
1640
+
1641
+ if (typeof color === 'string') {
1642
+ opts = _extends({}, opts, {
1643
+ color: () => color
1644
+ });
1645
+ } else if (color != null && color.length) {
1646
+ opts = _extends({}, opts, {
1647
+ color: node => color[node.state.id % color.length]
1648
+ });
1649
+ }
1650
+
1651
+ if (typeof duration === 'number') {
1652
+ opts = _extends({}, opts, {
1653
+ duration
1654
+ });
1655
+ }
1656
+
1657
+ if (typeof maxWidth === 'number') {
1658
+ opts = _extends({}, opts, {
1659
+ maxWidth
1660
+ });
1661
+ }
1662
+
1663
+ return opts;
1664
+ }
1427
1665
 
1428
1666
  exports.Markmap = Markmap;
1667
+ exports.defaultColorFn = defaultColorFn;
1668
+ exports.deriveOptions = deriveOptions;
1669
+ exports.globalCSS = globalCSS;
1429
1670
  exports.loadCSS = loadCSS;
1430
1671
  exports.loadJS = loadJS;
1431
1672
  exports.refreshHook = refreshHook;