markmap-view 0.14.5-alpha.22 → 0.14.5-alpha.24

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,8 +1,8 @@
1
- /*! markmap-view v0.14.5-alpha.22+04afb38 | MIT License */
1
+ /*! markmap-view v0.14.5-alpha.24+08dd40c | MIT License */
2
2
  (function (exports, d3) {
3
3
  'use strict';
4
4
 
5
- /*! markmap-common v0.14.5-alpha.22+04afb38 | MIT License */
5
+ /*! markmap-common v0.14.5-alpha.24+08dd40c | MIT License */
6
6
  function _extends$1() {
7
7
  _extends$1 = Object.assign ? Object.assign.bind() : function (target) {
8
8
  for (var i = 1; i < arguments.length; i++) {
@@ -294,20 +294,27 @@ const memoizedPreloadJS = memoize(url => {
294
294
  href: url
295
295
  }));
296
296
  });
297
+ const jsCache = {};
298
+ const cssCache = {};
297
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]);
298
303
  if (!item.loaded) {
299
304
  if (item.type === 'script') {
300
305
  item.loaded = new Promise((resolve, reject) => {
301
- var _item$data;
302
306
  document.head.append(hm('script', _extends$1({}, item.data, {
303
307
  onLoad: resolve,
304
308
  onError: reject
305
309
  })));
306
- // Run inline script synchronously
307
- if (!((_item$data = item.data) != null && _item$data.src)) resolve(undefined);
310
+ if (!src) {
311
+ // Run inline script synchronously
312
+ resolve(undefined);
313
+ }
308
314
  }).then(() => {
309
315
  item.loaded = true;
310
316
  });
317
+ if (src) jsCache[src] = item.loaded;
311
318
  }
312
319
  if (item.type === 'iife') {
313
320
  const {
@@ -321,8 +328,11 @@ async function loadJSItem(item, context) {
321
328
  await item.loaded;
322
329
  }
323
330
  function loadCSSItem(item) {
331
+ const url = item.type === 'stylesheet' && item.data.href || '';
332
+ item.loaded || (item.loaded = cssCache[url]);
324
333
  if (item.loaded) return;
325
334
  item.loaded = true;
335
+ if (url) cssCache[url] = true;
326
336
  if (item.type === 'style') {
327
337
  document.head.append(hm('style', {
328
338
  textContent: item.data
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! markmap-view v0.14.5-alpha.22+04afb38 | MIT License */
1
+ /*! markmap-view v0.14.5-alpha.24+08dd40c | MIT License */
2
2
  import { Hook, getId, addClass, walkTree, childSelector, noop } from 'markmap-common';
3
3
  export { loadCSS, loadJS } from 'markmap-common';
4
4
  import { scaleOrdinal, schemeCategory10, zoomTransform, select, zoom, linkHorizontal, min, max, zoomIdentity, minIndex } from 'd3';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markmap-view",
3
- "version": "0.14.5-alpha.22+04afb38",
3
+ "version": "0.14.5-alpha.24+08dd40c",
4
4
  "description": "View markmaps in browser",
5
5
  "author": "Gerald <gera2ld@live.com>",
6
6
  "license": "MIT",
@@ -46,10 +46,10 @@
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/d3-flextree": "^2.1.1",
49
- "markmap-common": "0.14.5-alpha.22+04afb38"
49
+ "markmap-common": "0.14.5-alpha.24+08dd40c"
50
50
  },
51
51
  "peerDependencies": {
52
52
  "markmap-common": "*"
53
53
  },
54
- "gitHead": "04afb38dd0a6f3b5e8eaffde3c29e9e38b215c35"
54
+ "gitHead": "08dd40c9353058928a148f6b97d11e98ec1d328b"
55
55
  }