diff --git a/main.js b/main.js index a5bd7136..46e00a51 100644 --- a/main.js +++ b/main.js @@ -20284,11 +20284,7 @@ function getAllFieldGs(fields, currGraphs) { }); return fieldGs; } -function hierToStr(hier) { - return `↑: ${hier.up.join(", ")} -→: ${hier.same.join(", ")} -↓: ${hier.down.join(", ")}`; -} +const hierToStr = (hier) => DIRECTIONS.map((dir) => `${ARROW_DIRECTIONS[dir]}: ${hier[dir].join(", ")}`).join("\n"); function removeDuplicates(arr) { return [...new Set(arr)]; } @@ -20359,6 +20355,28 @@ function oppFields(field, dir, userHierarchies) { const oppDir = getOppDir(dir); return ((_b = (_a = userHierarchies.find((hier) => hier[oppDir].includes(field))) === null || _a === void 0 ? void 0 : _a[oppDir]) !== null && _b !== void 0 ? _b : []); } +/** + * Get the hierarchy and direction that `field` is in + * */ +function getFieldInfo(userHierarchies, field) { + let fieldDir; + let fieldHier; + DIRECTIONS.forEach((dir) => { + userHierarchies.forEach((hier) => { + if (hier[dir].includes(field)) { + fieldDir = dir; + fieldHier = hier; + return; + } + }); + }); + return { fieldHier, fieldDir }; +} +function getOppFields(userHierarchies, field) { + const { fieldHier, fieldDir } = getFieldInfo(userHierarchies, field); + const oppDir = getOppDir(fieldDir); + return fieldHier[oppDir]; +} function addNodeIfNot(g, node, attr) { if (!g.hasNode(node)) g.addNode(node, attr); @@ -20379,7 +20397,35 @@ function swapItems(i, j, arr) { } const linkClass = (app, to, realQ = true) => `internal-link BC-Link ${isInVault(app, to) ? "" : "is-unresolved"} ${realQ ? "" : "BC-Implied"}`; const getOutNeighbours = (g, node) => g.hasNode(node) ? g.outNeighbors(node) : []; -const getInNeighbours = (g, node) => g.hasNode(node) ? g.inNeighbors(node) : []; +const getInNeighbours = (g, node) => g.hasNode(node) ? g.inNeighbors(node) : []; +function getPrevNext(plugin, currNode) { + const [rPrev, rNext, iPrev, iNext] = [[], [], [], []]; + const { userHierarchies } = plugin.settings; + plugin.currGraphs.main.forEachEdge(currNode, (k, a, s, t) => { + const { fieldName } = a; + if (a.dir === "next" && s === currNode) { + rNext.push({ to: t, real: true, fieldName }); + } + if (a.dir === "prev" && t === currNode) { + iNext.push({ + to: s, + real: false, + fieldName: getOppFields(userHierarchies, fieldName)[0], + }); + } + if (a.dir === "prev" && s === currNode) { + rPrev.push({ to: t, real: true, fieldName }); + } + if (a.dir === "next" && t === currNode) { + iPrev.push({ + to: s, + real: false, + fieldName: getOppFields(userHierarchies, fieldName)[0], + }); + } + }); + return { rPrev, rNext, iPrev, iNext }; +} function noop$1() { } function assign(tar, src) { @@ -22859,7 +22905,7 @@ function get_each_context_1$5(ctx, list, i) { return child_ctx; } -// (95:6) {#each DIRECTIONS as dir} +// (92:6) {#each DIRECTIONS as dir} function create_each_block_1$5(ctx) { let div; let label; @@ -22918,7 +22964,7 @@ function create_each_block_1$5(ctx) { }; } -// (63:2) {#each currHiers as hier, i} +// (60:2) {#each currHiers as hier, i} function create_each_block$5(ctx) { let details; let summary; @@ -23244,9 +23290,7 @@ function instance$5($$self, $$props, $$invalidate) { }); } - const click_handler = async () => { - $$invalidate(0, currHiers = [...currHiers, blankUserHier()]); - }; // await update(currHiers); + const click_handler = async () => $$invalidate(0, currHiers = [...currHiers, blankUserHier()]); const click_handler_1 = async () => { if (window.confirm("Are you sure you want to reset all hierarchies?")) { @@ -33723,278 +33767,301 @@ class VisModal extends obsidian.Modal { } } -/* src\Components\TrailGrid.svelte generated by Svelte v3.35.0 */ +/* src\Components\NextPrev.svelte generated by Svelte v3.35.0 */ function add_css$2() { var style = element("style"); - style.id = "svelte-gk73kp-style"; - style.textContent = "div.BC-trail-grid.svelte-gk73kp{border:2px solid var(--background-modifier-border);display:grid;align-items:stretch;width:auto;height:auto}div.BC-trail-grid-item.svelte-gk73kp{display:flex;flex-direction:column;border:1px solid var(--background-modifier-border);align-items:center;justify-content:center;padding:2px;font-size:smaller}div.BC-trail-grid-item.BC-filler.svelte-gk73kp{opacity:0.7}.dot.svelte-gk73kp{height:5px;width:5px;border-radius:50%;display:inline-block}"; + style.id = "svelte-1cqb0v5-style"; + style.textContent = ".BC-nexts.svelte-1cqb0v5 div.svelte-1cqb0v5{text-align:right}.BC-right-arrow.svelte-1cqb0v5.svelte-1cqb0v5{padding-left:5px;float:right}.BC-left-arrow.svelte-1cqb0v5.svelte-1cqb0v5{padding-right:5px;float:left}.BC-nexts.svelte-1cqb0v5.svelte-1cqb0v5{border-left:1px solid var(--background-modifier-border)}.BC-prevs.svelte-1cqb0v5.svelte-1cqb0v5{border-right:1px solid var(--background-modifier-border)}.BC-NextPrev-Container.svelte-1cqb0v5.svelte-1cqb0v5{display:grid;grid-template-columns:1fr 1fr}"; append(document.head, style); } function get_each_context$2(ctx, list, i) { const child_ctx = ctx.slice(); - child_ctx[20] = list[i]; - child_ctx[22] = i; + child_ctx[6] = list[i]; return child_ctx; } function get_each_context_1$2(ctx, list, i) { const child_ctx = ctx.slice(); - child_ctx[23] = list[i]; + child_ctx[9] = list[i]; return child_ctx; } -function get_each_context_2(ctx, list, i) { - const child_ctx = ctx.slice(); - child_ctx[22] = list[i]; - return child_ctx; +// (14:4) {#if prev.length} +function create_if_block_1$1(ctx) { + let span; + + return { + c() { + span = element("span"); + span.textContent = "←"; + attr(span, "class", "BC-left-arrow svelte-1cqb0v5"); + }, + m(target, anchor) { + insert(target, span, anchor); + }, + d(detaching) { + if (detaching) detach(span); + } + }; } -// (80:8) {#if step.value && settings.gridDots} -function create_if_block$2(ctx) { +// (16:6) {#each prev as p} +function create_each_block_1$2(ctx) { let div; - let each_value_2 = lodash.range(Math.floor(/*wordCounts*/ ctx[2][/*step*/ ctx[23].value] / 1000)); - let each_blocks = []; + let strong; + let t0_value = /*p*/ ctx[9].fieldName + ""; + let t0; + let t1; + let t2_value = /*p*/ ctx[9].to + ""; + let t2; + let t3; + let div_class_value; + let mounted; + let dispose; - for (let i = 0; i < each_value_2.length; i += 1) { - each_blocks[i] = create_each_block_2(get_each_context_2(ctx, each_value_2, i)); + function click_handler(...args) { + return /*click_handler*/ ctx[4](/*p*/ ctx[9], ...args); } return { c() { div = element("div"); - - for (let i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].c(); - } - - attr(div, "class", "dots"); + strong = element("strong"); + t0 = text(t0_value); + t1 = space(); + t2 = text(t2_value); + t3 = space(); + attr(div, "class", div_class_value = "" + (null_to_empty(linkClass(/*app*/ ctx[0], /*p*/ ctx[9].to, /*p*/ ctx[9].real)) + " svelte-1cqb0v5")); }, m(target, anchor) { insert(target, div, anchor); + append(div, strong); + append(strong, t0); + append(div, t1); + append(div, t2); + append(div, t3); - for (let i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].m(div, null); + if (!mounted) { + dispose = listen(div, "click", click_handler); + mounted = true; } }, - p(ctx, dirty) { - if (dirty & /*settings, wordCounts*/ 20) { - each_value_2 = lodash.range(Math.floor(/*wordCounts*/ ctx[2][/*step*/ ctx[23].value] / 1000)); - let i; - - for (i = 0; i < each_value_2.length; i += 1) { - const child_ctx = get_each_context_2(ctx, each_value_2, i); - - if (each_blocks[i]) { - each_blocks[i].p(child_ctx, dirty); - } else { - each_blocks[i] = create_each_block_2(child_ctx); - each_blocks[i].c(); - each_blocks[i].m(div, null); - } - } - - for (; i < each_blocks.length; i += 1) { - each_blocks[i].d(1); - } + p(new_ctx, dirty) { + ctx = new_ctx; + if (dirty & /*prev*/ 4 && t0_value !== (t0_value = /*p*/ ctx[9].fieldName + "")) set_data(t0, t0_value); + if (dirty & /*prev*/ 4 && t2_value !== (t2_value = /*p*/ ctx[9].to + "")) set_data(t2, t2_value); - each_blocks.length = each_value_2.length; + if (dirty & /*app, prev*/ 5 && div_class_value !== (div_class_value = "" + (null_to_empty(linkClass(/*app*/ ctx[0], /*p*/ ctx[9].to, /*p*/ ctx[9].real)) + " svelte-1cqb0v5"))) { + attr(div, "class", div_class_value); } }, d(detaching) { if (detaching) detach(div); - destroy_each(each_blocks, detaching); + mounted = false; + dispose(); } }; } -// (82:12) {#each range(Math.floor(wordCounts[step.value] / 1000)) as i} -function create_each_block_2(ctx) { +// (29:6) {#if next.length} +function create_if_block$2(ctx) { let span; return { c() { span = element("span"); - attr(span, "class", "dot svelte-gk73kp"); - set_style(span, "background-color", /*settings*/ ctx[4].dotsColour); + span.textContent = "→"; + attr(span, "class", "BC-right-arrow svelte-1cqb0v5"); }, m(target, anchor) { insert(target, span, anchor); }, - p: noop$1, d(detaching) { if (detaching) detach(span); } }; } -// (63:4) {#each allRuns[i] as step} -function create_each_block_1$2(ctx) { - let div1; - let div0; - let t0_value = /*step*/ ctx[23].value + ""; +// (30:6) {#each next as n} +function create_each_block$2(ctx) { + let div; + let t0_value = /*n*/ ctx[6].to + ""; let t0; - let div0_class_value; let t1; + let strong; + let t2_value = /*n*/ ctx[6].fieldName + ""; let t2; - let div1_class_value; - let div1_style_value; + let t3; + let div_class_value; let mounted; let dispose; - let if_block = /*step*/ ctx[23].value && /*settings*/ ctx[4].gridDots && create_if_block$2(ctx); - - function click_handler(...args) { - return /*click_handler*/ ctx[10](/*step*/ ctx[23], ...args); - } - function mouseover_handler(...args) { - return /*mouseover_handler*/ ctx[11](/*step*/ ctx[23], ...args); + function click_handler_1(...args) { + return /*click_handler_1*/ ctx[5](/*n*/ ctx[6], ...args); } return { c() { - div1 = element("div"); - div0 = element("div"); + div = element("div"); t0 = text(t0_value); t1 = space(); - if (if_block) if_block.c(); - t2 = space(); - attr(div0, "class", div0_class_value = "" + (null_to_empty(linkClass(/*app*/ ctx[1], /*step*/ ctx[23].value)) + " svelte-gk73kp")); - attr(div1, "class", div1_class_value = "BC-trail-grid-item " + (/*step*/ ctx[23].value === "" ? "BC-filler" : "") + " svelte-gk73kp"); - - attr(div1, "style", div1_style_value = "\r\n grid-area: " + (/*step*/ ctx[23].first + 1) + " / " + (/*i*/ ctx[22] + 1) + " / \r\n " + (/*step*/ ctx[23].last + 2) + " / " + (/*i*/ ctx[22] + 2) + ";\r\n " + (/*settings*/ ctx[4].gridHeatmap - ? `background-color: ${/*settings*/ ctx[4].heatmapColour}${Math.round(/*children*/ ctx[3][/*step*/ ctx[23].value] * 200 + 55).toString(16)}` - : "")); + strong = element("strong"); + t2 = text(t2_value); + t3 = space(); + attr(div, "class", div_class_value = "" + (linkClass(/*app*/ ctx[0], /*n*/ ctx[6].to, /*n*/ ctx[6].real) + " BC-next" + " svelte-1cqb0v5")); }, m(target, anchor) { - insert(target, div1, anchor); - append(div1, div0); - append(div0, t0); - append(div1, t1); - if (if_block) if_block.m(div1, null); - append(div1, t2); + insert(target, div, anchor); + append(div, t0); + append(div, t1); + append(div, strong); + append(strong, t2); + append(div, t3); if (!mounted) { - dispose = [ - listen(div1, "click", click_handler), - listen(div1, "mouseover", mouseover_handler) - ]; - + dispose = listen(div, "click", click_handler_1); mounted = true; } }, p(new_ctx, dirty) { ctx = new_ctx; + if (dirty & /*next*/ 2 && t0_value !== (t0_value = /*n*/ ctx[6].to + "")) set_data(t0, t0_value); + if (dirty & /*next*/ 2 && t2_value !== (t2_value = /*n*/ ctx[6].fieldName + "")) set_data(t2, t2_value); - if (dirty & /*app*/ 2 && div0_class_value !== (div0_class_value = "" + (null_to_empty(linkClass(/*app*/ ctx[1], /*step*/ ctx[23].value)) + " svelte-gk73kp"))) { - attr(div0, "class", div0_class_value); - } - - if (/*step*/ ctx[23].value && /*settings*/ ctx[4].gridDots) if_block.p(ctx, dirty); - - if (dirty & /*children*/ 8 && div1_style_value !== (div1_style_value = "\r\n grid-area: " + (/*step*/ ctx[23].first + 1) + " / " + (/*i*/ ctx[22] + 1) + " / \r\n " + (/*step*/ ctx[23].last + 2) + " / " + (/*i*/ ctx[22] + 2) + ";\r\n " + (/*settings*/ ctx[4].gridHeatmap - ? `background-color: ${/*settings*/ ctx[4].heatmapColour}${Math.round(/*children*/ ctx[3][/*step*/ ctx[23].value] * 200 + 55).toString(16)}` - : ""))) { - attr(div1, "style", div1_style_value); + if (dirty & /*app, next*/ 3 && div_class_value !== (div_class_value = "" + (linkClass(/*app*/ ctx[0], /*n*/ ctx[6].to, /*n*/ ctx[6].real) + " BC-next" + " svelte-1cqb0v5"))) { + attr(div, "class", div_class_value); } }, d(detaching) { - if (detaching) detach(div1); - if (if_block) if_block.d(); + if (detaching) detach(div); mounted = false; - run_all(dispose); + dispose(); } }; } -// (62:2) {#each transposedTrails as col, i} -function create_each_block$2(ctx) { - let each_1_anchor; - let each_value_1 = /*allRuns*/ ctx[8][/*i*/ ctx[22]]; - let each_blocks = []; +function create_fragment$2(ctx) { + let div2; + let div0; + let t0; + let span0; + let t1; + let div1; + let span1; + let t2; + let if_block0 = /*prev*/ ctx[2].length && create_if_block_1$1(); + let each_value_1 = /*prev*/ ctx[2]; + let each_blocks_1 = []; for (let i = 0; i < each_value_1.length; i += 1) { - each_blocks[i] = create_each_block_1$2(get_each_context_1$2(ctx, each_value_1, i)); + each_blocks_1[i] = create_each_block_1$2(get_each_context_1$2(ctx, each_value_1, i)); + } + + let if_block1 = /*next*/ ctx[1].length && create_if_block$2(); + let each_value = /*next*/ ctx[1]; + let each_blocks = []; + + for (let i = 0; i < each_value.length; i += 1) { + each_blocks[i] = create_each_block$2(get_each_context$2(ctx, each_value, i)); } return { c() { + div2 = element("div"); + div0 = element("div"); + if (if_block0) if_block0.c(); + t0 = space(); + span0 = element("span"); + + for (let i = 0; i < each_blocks_1.length; i += 1) { + each_blocks_1[i].c(); + } + + t1 = space(); + div1 = element("div"); + span1 = element("span"); + if (if_block1) if_block1.c(); + t2 = space(); + for (let i = 0; i < each_blocks.length; i += 1) { each_blocks[i].c(); } - each_1_anchor = empty$1(); + attr(div0, "class", "BC-prevs svelte-1cqb0v5"); + attr(div1, "class", "BC-nexts svelte-1cqb0v5"); + attr(div2, "class", "BC-NextPrev-Container svelte-1cqb0v5"); }, m(target, anchor) { - for (let i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].m(target, anchor); - } + insert(target, div2, anchor); + append(div2, div0); + if (if_block0) if_block0.m(div0, null); + append(div0, t0); + append(div0, span0); - insert(target, each_1_anchor, anchor); - }, - p(ctx, dirty) { - if (dirty & /*allRuns, settings, Math, children, openOrSwitch, app, currFile, hoverPreview, activeLeafView, range, wordCounts, linkClass*/ 382) { - each_value_1 = /*allRuns*/ ctx[8][/*i*/ ctx[22]]; - let i; + for (let i = 0; i < each_blocks_1.length; i += 1) { + each_blocks_1[i].m(span0, null); + } - for (i = 0; i < each_value_1.length; i += 1) { - const child_ctx = get_each_context_1$2(ctx, each_value_1, i); + append(div2, t1); + append(div2, div1); + append(div1, span1); + if (if_block1) if_block1.m(span1, null); + append(span1, t2); - if (each_blocks[i]) { - each_blocks[i].p(child_ctx, dirty); - } else { - each_blocks[i] = create_each_block_1$2(child_ctx); - each_blocks[i].c(); - each_blocks[i].m(each_1_anchor.parentNode, each_1_anchor); - } - } - - for (; i < each_blocks.length; i += 1) { - each_blocks[i].d(1); - } - - each_blocks.length = each_value_1.length; + for (let i = 0; i < each_blocks.length; i += 1) { + each_blocks[i].m(span1, null); } }, - d(detaching) { - destroy_each(each_blocks, detaching); - if (detaching) detach(each_1_anchor); - } - }; -} + p(ctx, [dirty]) { + if (/*prev*/ ctx[2].length) { + if (if_block0) ; else { + if_block0 = create_if_block_1$1(); + if_block0.c(); + if_block0.m(div0, t0); + } + } else if (if_block0) { + if_block0.d(1); + if_block0 = null; + } -function create_fragment$2(ctx) { - let div; - let each_value = /*transposedTrails*/ ctx[7]; - let each_blocks = []; + if (dirty & /*linkClass, app, prev, openOrSwitch*/ 5) { + each_value_1 = /*prev*/ ctx[2]; + let i; - for (let i = 0; i < each_value.length; i += 1) { - each_blocks[i] = create_each_block$2(get_each_context$2(ctx, each_value, i)); - } + for (i = 0; i < each_value_1.length; i += 1) { + const child_ctx = get_each_context_1$2(ctx, each_value_1, i); - return { - c() { - div = element("div"); + if (each_blocks_1[i]) { + each_blocks_1[i].p(child_ctx, dirty); + } else { + each_blocks_1[i] = create_each_block_1$2(child_ctx); + each_blocks_1[i].c(); + each_blocks_1[i].m(span0, null); + } + } - for (let i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].c(); - } + for (; i < each_blocks_1.length; i += 1) { + each_blocks_1[i].d(1); + } - attr(div, "class", "BC-trail-grid svelte-gk73kp"); - set_style(div, "grid-template-columns", ("1fr ").repeat(/*transposedTrails*/ ctx[7].length)); - set_style(div, "grid-template-rows", ("1fr ").repeat(/*sortedTrails*/ ctx[0].length)); - }, - m(target, anchor) { - insert(target, div, anchor); + each_blocks_1.length = each_value_1.length; + } - for (let i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].m(div, null); + if (/*next*/ ctx[1].length) { + if (if_block1) ; else { + if_block1 = create_if_block$2(); + if_block1.c(); + if_block1.m(span1, t2); + } + } else if (if_block1) { + if_block1.d(1); + if_block1 = null; } - }, - p(ctx, [dirty]) { - if (dirty & /*allRuns, settings, Math, children, openOrSwitch, app, currFile, hoverPreview, activeLeafView, range, wordCounts, linkClass*/ 382) { - each_value = /*transposedTrails*/ ctx[7]; + + if (dirty & /*linkClass, app, next, openOrSwitch*/ 3) { + each_value = /*next*/ ctx[1]; let i; for (i = 0; i < each_value.length; i += 1) { @@ -34005,7 +34072,7 @@ function create_fragment$2(ctx) { } else { each_blocks[i] = create_each_block$2(child_ctx); each_blocks[i].c(); - each_blocks[i].m(div, null); + each_blocks[i].m(span1, null); } } @@ -34015,15 +34082,14 @@ function create_fragment$2(ctx) { each_blocks.length = each_value.length; } - - if (dirty & /*sortedTrails*/ 1) { - set_style(div, "grid-template-rows", ("1fr ").repeat(/*sortedTrails*/ ctx[0].length)); - } }, i: noop$1, o: noop$1, d(detaching) { - if (detaching) detach(div); + if (detaching) detach(div2); + if (if_block0) if_block0.d(); + destroy_each(each_blocks_1, detaching); + if (if_block1) if_block1.d(); destroy_each(each_blocks, detaching); } }; @@ -34032,159 +34098,101 @@ function create_fragment$2(ctx) { function instance$2($$self, $$props, $$invalidate) { - let { sortedTrails } = $$props; + let { app } = $$props; let { plugin } = $$props; - const settings = plugin.settings; - const currFile = app.workspace.getActiveFile(); - const activeLeafView = app.workspace.activeLeaf.view; - const allCells = [...new Set(sortedTrails.reduce((a, b) => [...a, ...b]))]; - const wordCounts = {}; - - allCells.forEach(cell => { - var _a; - - try { - $$invalidate( - 2, - wordCounts[cell] = (_a = app.metadataCache.getFirstLinkpathDest(cell, "")) === null || _a === void 0 - ? void 0 - : _a.stat.size, - wordCounts - ); - } catch(error) { - console.log(error); - console.log({ currFile }); - $$invalidate(2, wordCounts[cell] = 0, wordCounts); - } - }); - - // const data: {[cell: string]: number} = {} - // allCells.forEach(cell => data[cell] = app.metadataCache.getFileCache(app.metadataCache.getFirstLinkpathDest(cell, currFile.path))?.links.length ?? 0); - const { up, down } = plugin.currGraphs.mergedGs; - - const closedParents = closeImpliedLinks(up, down); - const children = {}; - allCells.forEach(cell => $$invalidate(3, children[cell] = getOutNeighbours(closedParents, cell).length, children)); - const normalisedData = normalise(Object.values(children)); - - allCells.forEach((cell, i) => { - $$invalidate(3, children[cell] = normalisedData[i], children); - }); - - // const normalisedData = allCells.forEach(cell => { - // }) - // const links: {[cell: string]: number}[] = [] - // data.forEach(cell => links[Object.keys(cell)[0]] = (Object.values(cell)[0]?.links.length ?? 0)) - // console.log(data) - const maxLength = Math.max(...sortedTrails.map(trail => trail.length)); - - const paddedTrails = sortedTrails.map(trail => padArray(trail, maxLength)); - - // const permutations: string[][][] = permute(paddedTrails.map(trail => [trail[0]])) - // // permutations.map(trails => sum(transpose(trails).map(runs).map(runs => runs.length))) - // const ALLRuns = permutations.map(permutation => transpose(permutation).map(runs)) - // const runsPerRun = ALLRuns.map(runs => runs[0].length) - // const minRunLength = Math.min(...runsPerRun); - // const indexOfMinRun = runsPerRun.indexOf(minRunLength); - // const minRun = ALLRuns[indexOfMinRun] - const transposedTrails = transpose(paddedTrails); - - const allRuns = transposedTrails.map(runs); - const click_handler = (step, e) => openOrSwitch(app, step.value, currFile, e); - const mouseover_handler = (step, e) => hoverPreview$1(e, activeLeafView, step.value); + let { next } = $$props; + let { prev } = $$props; + const click_handler = async (p, e) => openOrSwitch$1(app, p.to, e); + const click_handler_1 = async (n, e) => openOrSwitch$1(app, n.to, e); $$self.$$set = $$props => { - if ("sortedTrails" in $$props) $$invalidate(0, sortedTrails = $$props.sortedTrails); - if ("app" in $$props) $$invalidate(1, app = $$props.app); - if ("plugin" in $$props) $$invalidate(9, plugin = $$props.plugin); + if ("app" in $$props) $$invalidate(0, app = $$props.app); + if ("plugin" in $$props) $$invalidate(3, plugin = $$props.plugin); + if ("next" in $$props) $$invalidate(1, next = $$props.next); + if ("prev" in $$props) $$invalidate(2, prev = $$props.prev); }; - return [ - sortedTrails, - app, - wordCounts, - children, - settings, - currFile, - activeLeafView, - transposedTrails, - allRuns, - plugin, - click_handler, - mouseover_handler - ]; + return [app, next, prev, plugin, click_handler, click_handler_1]; } -class TrailGrid extends SvelteComponent { +class NextPrev extends SvelteComponent { constructor(options) { super(); - if (!document.getElementById("svelte-gk73kp-style")) add_css$2(); - init$1(this, options, instance$2, create_fragment$2, safe_not_equal, { sortedTrails: 0, app: 1, plugin: 9 }); + if (!document.getElementById("svelte-1cqb0v5-style")) add_css$2(); + init$1(this, options, instance$2, create_fragment$2, safe_not_equal, { app: 0, plugin: 3, next: 1, prev: 2 }); } } -/* src\Components\TrailPath.svelte generated by Svelte v3.35.0 */ +/* src\Components\TrailGrid.svelte generated by Svelte v3.35.0 */ function add_css$1() { var style = element("style"); - style.id = "svelte-3c1frp-style"; - style.textContent = "span.BC-trail-path-container.svelte-3c1frp{display:flex;justify-content:space-between}"; + style.id = "svelte-gk73kp-style"; + style.textContent = "div.BC-trail-grid.svelte-gk73kp{border:2px solid var(--background-modifier-border);display:grid;align-items:stretch;width:auto;height:auto}div.BC-trail-grid-item.svelte-gk73kp{display:flex;flex-direction:column;border:1px solid var(--background-modifier-border);align-items:center;justify-content:center;padding:2px;font-size:smaller}div.BC-trail-grid-item.BC-filler.svelte-gk73kp{opacity:0.7}.dot.svelte-gk73kp{height:5px;width:5px;border-radius:50%;display:inline-block}"; append(document.head, style); } function get_each_context$1(ctx, list, i) { const child_ctx = ctx.slice(); - child_ctx[10] = list[i]; + child_ctx[20] = list[i]; + child_ctx[22] = i; return child_ctx; } function get_each_context_1$1(ctx, list, i) { const child_ctx = ctx.slice(); - child_ctx[13] = list[i]; - child_ctx[15] = i; + child_ctx[23] = list[i]; return child_ctx; } -// (20:8) {:else} -function create_else_block(ctx) { - let each_1_anchor; - let each_value_1 = /*trail*/ ctx[10]; +function get_each_context_2(ctx, list, i) { + const child_ctx = ctx.slice(); + child_ctx[22] = list[i]; + return child_ctx; +} + +// (80:8) {#if step.value && settings.gridDots} +function create_if_block$1(ctx) { + let div; + let each_value_2 = lodash.range(Math.floor(/*wordCounts*/ ctx[2][/*step*/ ctx[23].value] / 1000)); let each_blocks = []; - for (let i = 0; i < each_value_1.length; i += 1) { - each_blocks[i] = create_each_block_1$1(get_each_context_1$1(ctx, each_value_1, i)); + for (let i = 0; i < each_value_2.length; i += 1) { + each_blocks[i] = create_each_block_2(get_each_context_2(ctx, each_value_2, i)); } return { c() { + div = element("div"); + for (let i = 0; i < each_blocks.length; i += 1) { each_blocks[i].c(); } - each_1_anchor = empty$1(); + attr(div, "class", "dots"); }, m(target, anchor) { + insert(target, div, anchor); + for (let i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].m(target, anchor); + each_blocks[i].m(div, null); } - - insert(target, each_1_anchor, anchor); }, p(ctx, dirty) { - if (dirty & /*settings, trailsToShow, openOrSwitch, app, currFile, hoverPreview, activeLeafView*/ 110) { - each_value_1 = /*trail*/ ctx[10]; + if (dirty & /*settings, wordCounts*/ 20) { + each_value_2 = lodash.range(Math.floor(/*wordCounts*/ ctx[2][/*step*/ ctx[23].value] / 1000)); let i; - for (i = 0; i < each_value_1.length; i += 1) { - const child_ctx = get_each_context_1$1(ctx, each_value_1, i); + for (i = 0; i < each_value_2.length; i += 1) { + const child_ctx = get_each_context_2(ctx, each_value_2, i); if (each_blocks[i]) { each_blocks[i].p(child_ctx, dirty); } else { - each_blocks[i] = create_each_block_1$1(child_ctx); + each_blocks[i] = create_each_block_2(child_ctx); each_blocks[i].c(); - each_blocks[i].m(each_1_anchor.parentNode, each_1_anchor); + each_blocks[i].m(div, null); } } @@ -34192,104 +34200,86 @@ function create_else_block(ctx) { each_blocks[i].d(1); } - each_blocks.length = each_value_1.length; + each_blocks.length = each_value_2.length; } }, d(detaching) { + if (detaching) detach(div); destroy_each(each_blocks, detaching); - if (detaching) detach(each_1_anchor); } }; } -// (18:8) {#if trail.length === 0} -function create_if_block_1$1(ctx) { +// (82:12) {#each range(Math.floor(wordCounts[step.value] / 1000)) as i} +function create_each_block_2(ctx) { let span; - let t_value = /*settings*/ ctx[2].noPathMessage + ""; - let t; return { c() { span = element("span"); - t = text(t_value); + attr(span, "class", "dot svelte-gk73kp"); + set_style(span, "background-color", /*settings*/ ctx[4].dotsColour); }, m(target, anchor) { insert(target, span, anchor); - append(span, t); - }, - p(ctx, dirty) { - if (dirty & /*settings*/ 4 && t_value !== (t_value = /*settings*/ ctx[2].noPathMessage + "")) set_data(t, t_value); }, + p: noop$1, d(detaching) { if (detaching) detach(span); } }; } -// (30:12) {#if i < trail.length - 1} -function create_if_block_2(ctx) { - let span; - let t_value = " " + /*settings*/ ctx[2].trailSeperator + " " + ""; - let t; - - return { - c() { - span = element("span"); - t = text(t_value); - }, - m(target, anchor) { - insert(target, span, anchor); - append(span, t); - }, - p(ctx, dirty) { - if (dirty & /*settings*/ 4 && t_value !== (t_value = " " + /*settings*/ ctx[2].trailSeperator + " " + "")) set_data(t, t_value); - }, - d(detaching) { - if (detaching) detach(span); - } - }; -} - -// (21:10) {#each trail as crumb, i} +// (63:4) {#each allRuns[i] as step} function create_each_block_1$1(ctx) { - let span; - let t0_value = /*crumb*/ ctx[13] + ""; + let div1; + let div0; + let t0_value = /*step*/ ctx[23].value + ""; let t0; + let div0_class_value; let t1; - let if_block_anchor; + let t2; + let div1_class_value; + let div1_style_value; let mounted; let dispose; + let if_block = /*step*/ ctx[23].value && /*settings*/ ctx[4].gridDots && create_if_block$1(ctx); function click_handler(...args) { - return /*click_handler*/ ctx[7](/*crumb*/ ctx[13], ...args); + return /*click_handler*/ ctx[10](/*step*/ ctx[23], ...args); } function mouseover_handler(...args) { - return /*mouseover_handler*/ ctx[8](/*crumb*/ ctx[13], ...args); + return /*mouseover_handler*/ ctx[11](/*step*/ ctx[23], ...args); } - let if_block = /*i*/ ctx[15] < /*trail*/ ctx[10].length - 1 && create_if_block_2(ctx); - return { c() { - span = element("span"); + div1 = element("div"); + div0 = element("div"); t0 = text(t0_value); t1 = space(); if (if_block) if_block.c(); - if_block_anchor = empty$1(); - attr(span, "class", "internal-link BC-Link"); + t2 = space(); + attr(div0, "class", div0_class_value = "" + (null_to_empty(linkClass(/*app*/ ctx[1], /*step*/ ctx[23].value)) + " svelte-gk73kp")); + attr(div1, "class", div1_class_value = "BC-trail-grid-item " + (/*step*/ ctx[23].value === "" ? "BC-filler" : "") + " svelte-gk73kp"); + + attr(div1, "style", div1_style_value = "\r\n grid-area: " + (/*step*/ ctx[23].first + 1) + " / " + (/*i*/ ctx[22] + 1) + " / \r\n " + (/*step*/ ctx[23].last + 2) + " / " + (/*i*/ ctx[22] + 2) + ";\r\n " + (/*settings*/ ctx[4].gridHeatmap + ? `background-color: ${/*settings*/ ctx[4].heatmapColour}${Math.round(/*children*/ ctx[3][/*step*/ ctx[23].value] * 200 + 55).toString(16)}` + : "")); }, m(target, anchor) { - insert(target, span, anchor); - append(span, t0); - insert(target, t1, anchor); - if (if_block) if_block.m(target, anchor); - insert(target, if_block_anchor, anchor); + insert(target, div1, anchor); + append(div1, div0); + append(div0, t0); + append(div1, t1); + if (if_block) if_block.m(div1, null); + append(div1, t2); if (!mounted) { dispose = [ - listen(span, "click", click_handler), - listen(span, "mouseover", mouseover_handler) + listen(div1, "click", click_handler), + listen(div1, "mouseover", mouseover_handler) ]; mounted = true; @@ -34297,154 +34287,115 @@ function create_each_block_1$1(ctx) { }, p(new_ctx, dirty) { ctx = new_ctx; - if (dirty & /*trailsToShow*/ 32 && t0_value !== (t0_value = /*crumb*/ ctx[13] + "")) set_data(t0, t0_value); - if (/*i*/ ctx[15] < /*trail*/ ctx[10].length - 1) { - if (if_block) { - if_block.p(ctx, dirty); - } else { - if_block = create_if_block_2(ctx); - if_block.c(); - if_block.m(if_block_anchor.parentNode, if_block_anchor); - } - } else if (if_block) { - if_block.d(1); - if_block = null; + if (dirty & /*app*/ 2 && div0_class_value !== (div0_class_value = "" + (null_to_empty(linkClass(/*app*/ ctx[1], /*step*/ ctx[23].value)) + " svelte-gk73kp"))) { + attr(div0, "class", div0_class_value); + } + + if (/*step*/ ctx[23].value && /*settings*/ ctx[4].gridDots) if_block.p(ctx, dirty); + + if (dirty & /*children*/ 8 && div1_style_value !== (div1_style_value = "\r\n grid-area: " + (/*step*/ ctx[23].first + 1) + " / " + (/*i*/ ctx[22] + 1) + " / \r\n " + (/*step*/ ctx[23].last + 2) + " / " + (/*i*/ ctx[22] + 2) + ";\r\n " + (/*settings*/ ctx[4].gridHeatmap + ? `background-color: ${/*settings*/ ctx[4].heatmapColour}${Math.round(/*children*/ ctx[3][/*step*/ ctx[23].value] * 200 + 55).toString(16)}` + : ""))) { + attr(div1, "style", div1_style_value); } }, d(detaching) { - if (detaching) detach(span); - if (detaching) detach(t1); - if (if_block) if_block.d(detaching); - if (detaching) detach(if_block_anchor); + if (detaching) detach(div1); + if (if_block) if_block.d(); mounted = false; run_all(dispose); } }; } -// (16:4) {#each trailsToShow as trail} +// (62:2) {#each transposedTrails as col, i} function create_each_block$1(ctx) { - let div; - let t; + let each_1_anchor; + let each_value_1 = /*allRuns*/ ctx[8][/*i*/ ctx[22]]; + let each_blocks = []; - function select_block_type(ctx, dirty) { - if (/*trail*/ ctx[10].length === 0) return create_if_block_1$1; - return create_else_block; + for (let i = 0; i < each_value_1.length; i += 1) { + each_blocks[i] = create_each_block_1$1(get_each_context_1$1(ctx, each_value_1, i)); } - let current_block_type = select_block_type(ctx); - let if_block = current_block_type(ctx); - return { c() { - div = element("div"); - if_block.c(); - t = space(); + for (let i = 0; i < each_blocks.length; i += 1) { + each_blocks[i].c(); + } + + each_1_anchor = empty$1(); }, m(target, anchor) { - insert(target, div, anchor); - if_block.m(div, null); - append(div, t); + for (let i = 0; i < each_blocks.length; i += 1) { + each_blocks[i].m(target, anchor); + } + + insert(target, each_1_anchor, anchor); }, p(ctx, dirty) { - if (current_block_type === (current_block_type = select_block_type(ctx)) && if_block) { - if_block.p(ctx, dirty); - } else { - if_block.d(1); - if_block = current_block_type(ctx); + if (dirty & /*allRuns, settings, Math, children, openOrSwitch, app, currFile, hoverPreview, activeLeafView, range, wordCounts, linkClass*/ 382) { + each_value_1 = /*allRuns*/ ctx[8][/*i*/ ctx[22]]; + let i; - if (if_block) { - if_block.c(); - if_block.m(div, t); - } - } - }, - d(detaching) { - if (detaching) detach(div); - if_block.d(); - } - }; -} + for (i = 0; i < each_value_1.length; i += 1) { + const child_ctx = get_each_context_1$1(ctx, each_value_1, i); -// (39:2) {#if sortedTrails.length > 1} -function create_if_block$1(ctx) { - let div; - let button; - let t_value = (/*showAll*/ ctx[4] ? "Shortest" : "All") + ""; - let t; - let mounted; - let dispose; + if (each_blocks[i]) { + each_blocks[i].p(child_ctx, dirty); + } else { + each_blocks[i] = create_each_block_1$1(child_ctx); + each_blocks[i].c(); + each_blocks[i].m(each_1_anchor.parentNode, each_1_anchor); + } + } - return { - c() { - div = element("div"); - button = element("button"); - t = text(t_value); - attr(button, "class", "button-div"); - }, - m(target, anchor) { - insert(target, div, anchor); - append(div, button); - append(button, t); + for (; i < each_blocks.length; i += 1) { + each_blocks[i].d(1); + } - if (!mounted) { - dispose = listen(button, "click", /*click_handler_1*/ ctx[9]); - mounted = true; + each_blocks.length = each_value_1.length; } }, - p(ctx, dirty) { - if (dirty & /*showAll*/ 16 && t_value !== (t_value = (/*showAll*/ ctx[4] ? "Shortest" : "All") + "")) set_data(t, t_value); - }, d(detaching) { - if (detaching) detach(div); - mounted = false; - dispose(); + destroy_each(each_blocks, detaching); + if (detaching) detach(each_1_anchor); } }; } function create_fragment$1(ctx) { - let span; let div; - let t; - let each_value = /*trailsToShow*/ ctx[5]; + let each_value = /*transposedTrails*/ ctx[7]; let each_blocks = []; for (let i = 0; i < each_value.length; i += 1) { each_blocks[i] = create_each_block$1(get_each_context$1(ctx, each_value, i)); } - let if_block = /*sortedTrails*/ ctx[0].length > 1 && create_if_block$1(ctx); - return { c() { - span = element("span"); div = element("div"); for (let i = 0; i < each_blocks.length; i += 1) { each_blocks[i].c(); } - t = space(); - if (if_block) if_block.c(); - attr(div, "class", "trails-div"); - attr(span, "class", "BC-trail-path-container svelte-3c1frp"); + attr(div, "class", "BC-trail-grid svelte-gk73kp"); + set_style(div, "grid-template-columns", ("1fr ").repeat(/*transposedTrails*/ ctx[7].length)); + set_style(div, "grid-template-rows", ("1fr ").repeat(/*sortedTrails*/ ctx[0].length)); }, m(target, anchor) { - insert(target, span, anchor); - append(span, div); + insert(target, div, anchor); for (let i = 0; i < each_blocks.length; i += 1) { each_blocks[i].m(div, null); } - - append(span, t); - if (if_block) if_block.m(span, null); }, p(ctx, [dirty]) { - if (dirty & /*settings, trailsToShow, openOrSwitch, app, currFile, hoverPreview, activeLeafView*/ 110) { - each_value = /*trailsToShow*/ ctx[5]; + if (dirty & /*allRuns, settings, Math, children, openOrSwitch, app, currFile, hoverPreview, activeLeafView, range, wordCounts, linkClass*/ 382) { + each_value = /*transposedTrails*/ ctx[7]; let i; for (i = 0; i < each_value.length; i += 1) { @@ -34466,117 +34417,209 @@ function create_fragment$1(ctx) { each_blocks.length = each_value.length; } - if (/*sortedTrails*/ ctx[0].length > 1) { - if (if_block) { - if_block.p(ctx, dirty); - } else { - if_block = create_if_block$1(ctx); - if_block.c(); - if_block.m(span, null); - } - } else if (if_block) { - if_block.d(1); - if_block = null; + if (dirty & /*sortedTrails*/ 1) { + set_style(div, "grid-template-rows", ("1fr ").repeat(/*sortedTrails*/ ctx[0].length)); } }, i: noop$1, o: noop$1, d(detaching) { - if (detaching) detach(span); + if (detaching) detach(div); destroy_each(each_blocks, detaching); - if (if_block) if_block.d(); } }; } function instance$1($$self, $$props, $$invalidate) { - let trailsToShow; let { sortedTrails } = $$props; let { app } = $$props; - let { settings } = $$props; - let { currFile } = $$props; + let { plugin } = $$props; + const settings = plugin.settings; + const currFile = app.workspace.getActiveFile(); const activeLeafView = app.workspace.activeLeaf.view; - let showAll = settings.showAll; - const click_handler = async (crumb, e) => await openOrSwitch(app, crumb, currFile, e); - const mouseover_handler = (crumb, e) => hoverPreview$1(e, activeLeafView, crumb); - const click_handler_1 = () => $$invalidate(4, showAll = !showAll); + const allCells = [...new Set(sortedTrails.reduce((a, b) => [...a, ...b]))]; + const wordCounts = {}; + + allCells.forEach(cell => { + var _a; + + try { + $$invalidate( + 2, + wordCounts[cell] = (_a = app.metadataCache.getFirstLinkpathDest(cell, "")) === null || _a === void 0 + ? void 0 + : _a.stat.size, + wordCounts + ); + } catch(error) { + console.log(error); + console.log({ currFile }); + $$invalidate(2, wordCounts[cell] = 0, wordCounts); + } + }); + + // const data: {[cell: string]: number} = {} + // allCells.forEach(cell => data[cell] = app.metadataCache.getFileCache(app.metadataCache.getFirstLinkpathDest(cell, currFile.path))?.links.length ?? 0); + const { up, down } = plugin.currGraphs.mergedGs; + + const closedParents = closeImpliedLinks(up, down); + const children = {}; + allCells.forEach(cell => $$invalidate(3, children[cell] = getOutNeighbours(closedParents, cell).length, children)); + const normalisedData = normalise(Object.values(children)); + + allCells.forEach((cell, i) => { + $$invalidate(3, children[cell] = normalisedData[i], children); + }); + + // const normalisedData = allCells.forEach(cell => { + // }) + // const links: {[cell: string]: number}[] = [] + // data.forEach(cell => links[Object.keys(cell)[0]] = (Object.values(cell)[0]?.links.length ?? 0)) + // console.log(data) + const maxLength = Math.max(...sortedTrails.map(trail => trail.length)); + + const paddedTrails = sortedTrails.map(trail => padArray(trail, maxLength)); + + // const permutations: string[][][] = permute(paddedTrails.map(trail => [trail[0]])) + // // permutations.map(trails => sum(transpose(trails).map(runs).map(runs => runs.length))) + // const ALLRuns = permutations.map(permutation => transpose(permutation).map(runs)) + // const runsPerRun = ALLRuns.map(runs => runs[0].length) + // const minRunLength = Math.min(...runsPerRun); + // const indexOfMinRun = runsPerRun.indexOf(minRunLength); + // const minRun = ALLRuns[indexOfMinRun] + const transposedTrails = transpose(paddedTrails); + + const allRuns = transposedTrails.map(runs); + const click_handler = (step, e) => openOrSwitch(app, step.value, currFile, e); + const mouseover_handler = (step, e) => hoverPreview$1(e, activeLeafView, step.value); $$self.$$set = $$props => { if ("sortedTrails" in $$props) $$invalidate(0, sortedTrails = $$props.sortedTrails); if ("app" in $$props) $$invalidate(1, app = $$props.app); - if ("settings" in $$props) $$invalidate(2, settings = $$props.settings); - if ("currFile" in $$props) $$invalidate(3, currFile = $$props.currFile); - }; - - $$self.$$.update = () => { - if ($$self.$$.dirty & /*showAll, sortedTrails*/ 17) { - $$invalidate(5, trailsToShow = showAll ? sortedTrails : [sortedTrails[0]]); - } + if ("plugin" in $$props) $$invalidate(9, plugin = $$props.plugin); }; return [ sortedTrails, app, + wordCounts, + children, settings, currFile, - showAll, - trailsToShow, activeLeafView, + transposedTrails, + allRuns, + plugin, click_handler, - mouseover_handler, - click_handler_1 + mouseover_handler ]; } -class TrailPath extends SvelteComponent { +class TrailGrid extends SvelteComponent { constructor(options) { super(); - if (!document.getElementById("svelte-3c1frp-style")) add_css$1(); - - init$1(this, options, instance$1, create_fragment$1, safe_not_equal, { - sortedTrails: 0, - app: 1, - settings: 2, - currFile: 3 - }); + if (!document.getElementById("svelte-gk73kp-style")) add_css$1(); + init$1(this, options, instance$1, create_fragment$1, safe_not_equal, { sortedTrails: 0, app: 1, plugin: 9 }); } } -/* src\Components\NextPrev.svelte generated by Svelte v3.35.0 */ +/* src\Components\TrailPath.svelte generated by Svelte v3.35.0 */ function add_css() { var style = element("style"); - style.id = "svelte-1cqb0v5-style"; - style.textContent = ".BC-nexts.svelte-1cqb0v5 div.svelte-1cqb0v5{text-align:right}.BC-right-arrow.svelte-1cqb0v5.svelte-1cqb0v5{padding-left:5px;float:right}.BC-left-arrow.svelte-1cqb0v5.svelte-1cqb0v5{padding-right:5px;float:left}.BC-nexts.svelte-1cqb0v5.svelte-1cqb0v5{border-left:1px solid var(--background-modifier-border)}.BC-prevs.svelte-1cqb0v5.svelte-1cqb0v5{border-right:1px solid var(--background-modifier-border)}.BC-NextPrev-Container.svelte-1cqb0v5.svelte-1cqb0v5{display:grid;grid-template-columns:1fr 1fr}"; + style.id = "svelte-3c1frp-style"; + style.textContent = "span.BC-trail-path-container.svelte-3c1frp{display:flex;justify-content:space-between}"; append(document.head, style); } function get_each_context(ctx, list, i) { const child_ctx = ctx.slice(); - child_ctx[6] = list[i]; + child_ctx[10] = list[i]; return child_ctx; } function get_each_context_1(ctx, list, i) { const child_ctx = ctx.slice(); - child_ctx[9] = list[i]; + child_ctx[13] = list[i]; + child_ctx[15] = i; return child_ctx; } -// (13:4) {#if prev.length} +// (20:8) {:else} +function create_else_block(ctx) { + let each_1_anchor; + let each_value_1 = /*trail*/ ctx[10]; + let each_blocks = []; + + for (let i = 0; i < each_value_1.length; i += 1) { + each_blocks[i] = create_each_block_1(get_each_context_1(ctx, each_value_1, i)); + } + + return { + c() { + for (let i = 0; i < each_blocks.length; i += 1) { + each_blocks[i].c(); + } + + each_1_anchor = empty$1(); + }, + m(target, anchor) { + for (let i = 0; i < each_blocks.length; i += 1) { + each_blocks[i].m(target, anchor); + } + + insert(target, each_1_anchor, anchor); + }, + p(ctx, dirty) { + if (dirty & /*settings, trailsToShow, openOrSwitch, app, currFile, hoverPreview, activeLeafView*/ 110) { + each_value_1 = /*trail*/ ctx[10]; + let i; + + for (i = 0; i < each_value_1.length; i += 1) { + const child_ctx = get_each_context_1(ctx, each_value_1, i); + + if (each_blocks[i]) { + each_blocks[i].p(child_ctx, dirty); + } else { + each_blocks[i] = create_each_block_1(child_ctx); + each_blocks[i].c(); + each_blocks[i].m(each_1_anchor.parentNode, each_1_anchor); + } + } + + for (; i < each_blocks.length; i += 1) { + each_blocks[i].d(1); + } + + each_blocks.length = each_value_1.length; + } + }, + d(detaching) { + destroy_each(each_blocks, detaching); + if (detaching) detach(each_1_anchor); + } + }; +} + +// (18:8) {#if trail.length === 0} function create_if_block_1(ctx) { let span; + let t_value = /*settings*/ ctx[2].noPathMessage + ""; + let t; return { c() { span = element("span"); - span.textContent = "←"; - attr(span, "class", "BC-left-arrow svelte-1cqb0v5"); + t = text(t_value); }, m(target, anchor) { insert(target, span, anchor); + append(span, t); + }, + p(ctx, dirty) { + if (dirty & /*settings*/ 4 && t_value !== (t_value = /*settings*/ ctx[2].noPathMessage + "")) set_data(t, t_value); }, d(detaching) { if (detaching) detach(span); @@ -34584,110 +34627,175 @@ function create_if_block_1(ctx) { }; } -// (15:6) {#each prev as p} +// (30:12) {#if i < trail.length - 1} +function create_if_block_2(ctx) { + let span; + let t_value = " " + /*settings*/ ctx[2].trailSeperator + " " + ""; + let t; + + return { + c() { + span = element("span"); + t = text(t_value); + }, + m(target, anchor) { + insert(target, span, anchor); + append(span, t); + }, + p(ctx, dirty) { + if (dirty & /*settings*/ 4 && t_value !== (t_value = " " + /*settings*/ ctx[2].trailSeperator + " " + "")) set_data(t, t_value); + }, + d(detaching) { + if (detaching) detach(span); + } + }; +} + +// (21:10) {#each trail as crumb, i} function create_each_block_1(ctx) { - let div; - let t0_value = /*p*/ ctx[9].to + ""; + let span; + let t0_value = /*crumb*/ ctx[13] + ""; let t0; let t1; - let div_class_value; + let if_block_anchor; let mounted; let dispose; function click_handler(...args) { - return /*click_handler*/ ctx[4](/*p*/ ctx[9], ...args); + return /*click_handler*/ ctx[7](/*crumb*/ ctx[13], ...args); } + function mouseover_handler(...args) { + return /*mouseover_handler*/ ctx[8](/*crumb*/ ctx[13], ...args); + } + + let if_block = /*i*/ ctx[15] < /*trail*/ ctx[10].length - 1 && create_if_block_2(ctx); + return { c() { - div = element("div"); + span = element("span"); t0 = text(t0_value); t1 = space(); - attr(div, "class", div_class_value = "" + (null_to_empty(linkClass(/*app*/ ctx[0], /*p*/ ctx[9].to, /*p*/ ctx[9].real)) + " svelte-1cqb0v5")); + if (if_block) if_block.c(); + if_block_anchor = empty$1(); + attr(span, "class", "internal-link BC-Link"); }, m(target, anchor) { - insert(target, div, anchor); - append(div, t0); - append(div, t1); + insert(target, span, anchor); + append(span, t0); + insert(target, t1, anchor); + if (if_block) if_block.m(target, anchor); + insert(target, if_block_anchor, anchor); if (!mounted) { - dispose = listen(div, "click", click_handler); + dispose = [ + listen(span, "click", click_handler), + listen(span, "mouseover", mouseover_handler) + ]; + mounted = true; } }, p(new_ctx, dirty) { ctx = new_ctx; - if (dirty & /*prev*/ 4 && t0_value !== (t0_value = /*p*/ ctx[9].to + "")) set_data(t0, t0_value); + if (dirty & /*trailsToShow*/ 32 && t0_value !== (t0_value = /*crumb*/ ctx[13] + "")) set_data(t0, t0_value); - if (dirty & /*app, prev*/ 5 && div_class_value !== (div_class_value = "" + (null_to_empty(linkClass(/*app*/ ctx[0], /*p*/ ctx[9].to, /*p*/ ctx[9].real)) + " svelte-1cqb0v5"))) { - attr(div, "class", div_class_value); + if (/*i*/ ctx[15] < /*trail*/ ctx[10].length - 1) { + if (if_block) { + if_block.p(ctx, dirty); + } else { + if_block = create_if_block_2(ctx); + if_block.c(); + if_block.m(if_block_anchor.parentNode, if_block_anchor); + } + } else if (if_block) { + if_block.d(1); + if_block = null; } }, d(detaching) { - if (detaching) detach(div); + if (detaching) detach(span); + if (detaching) detach(t1); + if (if_block) if_block.d(detaching); + if (detaching) detach(if_block_anchor); mounted = false; - dispose(); + run_all(dispose); } }; } -// (27:6) {#if next.length} -function create_if_block(ctx) { - let span; +// (16:4) {#each trailsToShow as trail} +function create_each_block(ctx) { + let div; + let t; + + function select_block_type(ctx, dirty) { + if (/*trail*/ ctx[10].length === 0) return create_if_block_1; + return create_else_block; + } + + let current_block_type = select_block_type(ctx); + let if_block = current_block_type(ctx); return { c() { - span = element("span"); - span.textContent = "→"; - attr(span, "class", "BC-right-arrow svelte-1cqb0v5"); + div = element("div"); + if_block.c(); + t = space(); }, m(target, anchor) { - insert(target, span, anchor); + insert(target, div, anchor); + if_block.m(div, null); + append(div, t); + }, + p(ctx, dirty) { + if (current_block_type === (current_block_type = select_block_type(ctx)) && if_block) { + if_block.p(ctx, dirty); + } else { + if_block.d(1); + if_block = current_block_type(ctx); + + if (if_block) { + if_block.c(); + if_block.m(div, t); + } + } }, d(detaching) { - if (detaching) detach(span); + if (detaching) detach(div); + if_block.d(); } }; } -// (28:6) {#each next as n} -function create_each_block(ctx) { +// (39:2) {#if sortedTrails.length > 1} +function create_if_block(ctx) { let div; - let t0_value = /*n*/ ctx[6].to + ""; - let t0; - let t1; - let div_class_value; + let button; + let t_value = (/*showAll*/ ctx[4] ? "Shortest" : "All") + ""; + let t; let mounted; let dispose; - function click_handler_1(...args) { - return /*click_handler_1*/ ctx[5](/*n*/ ctx[6], ...args); - } - return { c() { div = element("div"); - t0 = text(t0_value); - t1 = space(); - attr(div, "class", div_class_value = "" + (linkClass(/*app*/ ctx[0], /*n*/ ctx[6].to, /*n*/ ctx[6].real) + " BC-next" + " svelte-1cqb0v5")); + button = element("button"); + t = text(t_value); + attr(button, "class", "button-div"); }, m(target, anchor) { insert(target, div, anchor); - append(div, t0); - append(div, t1); + append(div, button); + append(button, t); if (!mounted) { - dispose = listen(div, "click", click_handler_1); + dispose = listen(button, "click", /*click_handler_1*/ ctx[9]); mounted = true; } }, - p(new_ctx, dirty) { - ctx = new_ctx; - if (dirty & /*next*/ 2 && t0_value !== (t0_value = /*n*/ ctx[6].to + "")) set_data(t0, t0_value); - - if (dirty & /*app, next*/ 3 && div_class_value !== (div_class_value = "" + (linkClass(/*app*/ ctx[0], /*n*/ ctx[6].to, /*n*/ ctx[6].real) + " BC-next" + " svelte-1cqb0v5"))) { - attr(div, "class", div_class_value); - } + p(ctx, dirty) { + if (dirty & /*showAll*/ 16 && t_value !== (t_value = (/*showAll*/ ctx[4] ? "Shortest" : "All") + "")) set_data(t, t_value); }, d(detaching) { if (detaching) detach(div); @@ -34698,125 +34806,46 @@ function create_each_block(ctx) { } function create_fragment(ctx) { - let div2; - let div0; - let t0; - let span0; - let t1; - let div1; - let span1; - let t2; - let if_block0 = /*prev*/ ctx[2].length && create_if_block_1(); - let each_value_1 = /*prev*/ ctx[2]; - let each_blocks_1 = []; - - for (let i = 0; i < each_value_1.length; i += 1) { - each_blocks_1[i] = create_each_block_1(get_each_context_1(ctx, each_value_1, i)); - } - - let if_block1 = /*next*/ ctx[1].length && create_if_block(); - let each_value = /*next*/ ctx[1]; + let span; + let div; + let t; + let each_value = /*trailsToShow*/ ctx[5]; let each_blocks = []; for (let i = 0; i < each_value.length; i += 1) { each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i)); } + let if_block = /*sortedTrails*/ ctx[0].length > 1 && create_if_block(ctx); + return { c() { - div2 = element("div"); - div0 = element("div"); - if (if_block0) if_block0.c(); - t0 = space(); - span0 = element("span"); - - for (let i = 0; i < each_blocks_1.length; i += 1) { - each_blocks_1[i].c(); - } - - t1 = space(); - div1 = element("div"); - span1 = element("span"); - if (if_block1) if_block1.c(); - t2 = space(); + span = element("span"); + div = element("div"); for (let i = 0; i < each_blocks.length; i += 1) { each_blocks[i].c(); } - attr(div0, "class", "BC-prevs svelte-1cqb0v5"); - attr(div1, "class", "BC-nexts svelte-1cqb0v5"); - attr(div2, "class", "BC-NextPrev-Container svelte-1cqb0v5"); + t = space(); + if (if_block) if_block.c(); + attr(div, "class", "trails-div"); + attr(span, "class", "BC-trail-path-container svelte-3c1frp"); }, m(target, anchor) { - insert(target, div2, anchor); - append(div2, div0); - if (if_block0) if_block0.m(div0, null); - append(div0, t0); - append(div0, span0); - - for (let i = 0; i < each_blocks_1.length; i += 1) { - each_blocks_1[i].m(span0, null); - } - - append(div2, t1); - append(div2, div1); - append(div1, span1); - if (if_block1) if_block1.m(span1, null); - append(span1, t2); + insert(target, span, anchor); + append(span, div); for (let i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].m(span1, null); + each_blocks[i].m(div, null); } + + append(span, t); + if (if_block) if_block.m(span, null); }, p(ctx, [dirty]) { - if (/*prev*/ ctx[2].length) { - if (if_block0) ; else { - if_block0 = create_if_block_1(); - if_block0.c(); - if_block0.m(div0, t0); - } - } else if (if_block0) { - if_block0.d(1); - if_block0 = null; - } - - if (dirty & /*linkClass, app, prev, openOrSwitch*/ 5) { - each_value_1 = /*prev*/ ctx[2]; - let i; - - for (i = 0; i < each_value_1.length; i += 1) { - const child_ctx = get_each_context_1(ctx, each_value_1, i); - - if (each_blocks_1[i]) { - each_blocks_1[i].p(child_ctx, dirty); - } else { - each_blocks_1[i] = create_each_block_1(child_ctx); - each_blocks_1[i].c(); - each_blocks_1[i].m(span0, null); - } - } - - for (; i < each_blocks_1.length; i += 1) { - each_blocks_1[i].d(1); - } - - each_blocks_1.length = each_value_1.length; - } - - if (/*next*/ ctx[1].length) { - if (if_block1) ; else { - if_block1 = create_if_block(); - if_block1.c(); - if_block1.m(span1, t2); - } - } else if (if_block1) { - if_block1.d(1); - if_block1 = null; - } - - if (dirty & /*linkClass, app, next, openOrSwitch*/ 3) { - each_value = /*next*/ ctx[1]; + if (dirty & /*settings, trailsToShow, openOrSwitch, app, currFile, hoverPreview, activeLeafView*/ 110) { + each_value = /*trailsToShow*/ ctx[5]; let i; for (i = 0; i < each_value.length; i += 1) { @@ -34827,7 +34856,7 @@ function create_fragment(ctx) { } else { each_blocks[i] = create_each_block(child_ctx); each_blocks[i].c(); - each_blocks[i].m(span1, null); + each_blocks[i].m(div, null); } } @@ -34837,44 +34866,82 @@ function create_fragment(ctx) { each_blocks.length = each_value.length; } + + if (/*sortedTrails*/ ctx[0].length > 1) { + if (if_block) { + if_block.p(ctx, dirty); + } else { + if_block = create_if_block(ctx); + if_block.c(); + if_block.m(span, null); + } + } else if (if_block) { + if_block.d(1); + if_block = null; + } }, i: noop$1, o: noop$1, d(detaching) { - if (detaching) detach(div2); - if (if_block0) if_block0.d(); - destroy_each(each_blocks_1, detaching); - if (if_block1) if_block1.d(); + if (detaching) detach(span); destroy_each(each_blocks, detaching); + if (if_block) if_block.d(); } }; } function instance($$self, $$props, $$invalidate) { + let trailsToShow; + let { sortedTrails } = $$props; let { app } = $$props; - let { plugin } = $$props; - let { next } = $$props; - let { prev } = $$props; - const click_handler = async (p, e) => openOrSwitch$1(app, p.to, e); - const click_handler_1 = async (n, e) => openOrSwitch$1(app, n.to, e); + let { settings } = $$props; + let { currFile } = $$props; + const activeLeafView = app.workspace.activeLeaf.view; + let showAll = settings.showAll; + const click_handler = async (crumb, e) => await openOrSwitch(app, crumb, currFile, e); + const mouseover_handler = (crumb, e) => hoverPreview$1(e, activeLeafView, crumb); + const click_handler_1 = () => $$invalidate(4, showAll = !showAll); $$self.$$set = $$props => { - if ("app" in $$props) $$invalidate(0, app = $$props.app); - if ("plugin" in $$props) $$invalidate(3, plugin = $$props.plugin); - if ("next" in $$props) $$invalidate(1, next = $$props.next); - if ("prev" in $$props) $$invalidate(2, prev = $$props.prev); + if ("sortedTrails" in $$props) $$invalidate(0, sortedTrails = $$props.sortedTrails); + if ("app" in $$props) $$invalidate(1, app = $$props.app); + if ("settings" in $$props) $$invalidate(2, settings = $$props.settings); + if ("currFile" in $$props) $$invalidate(3, currFile = $$props.currFile); }; - return [app, next, prev, plugin, click_handler, click_handler_1]; + $$self.$$.update = () => { + if ($$self.$$.dirty & /*showAll, sortedTrails*/ 17) { + $$invalidate(5, trailsToShow = showAll ? sortedTrails : [sortedTrails[0]]); + } + }; + + return [ + sortedTrails, + app, + settings, + currFile, + showAll, + trailsToShow, + activeLeafView, + click_handler, + mouseover_handler, + click_handler_1 + ]; } -class NextPrev extends SvelteComponent { +class TrailPath extends SvelteComponent { constructor(options) { super(); - if (!document.getElementById("svelte-1cqb0v5-style")) add_css(); - init$1(this, options, instance, create_fragment, safe_not_equal, { app: 0, plugin: 3, next: 1, prev: 2 }); + if (!document.getElementById("svelte-3c1frp-style")) add_css(); + + init$1(this, options, instance, create_fragment, safe_not_equal, { + sortedTrails: 0, + app: 1, + settings: 2, + currFile: 3 + }); } } @@ -35369,23 +35436,9 @@ class BCPlugin extends obsidian.Plugin { const sortedTrails = this.getBreadcrumbs(closedUp, currFile); debug(settings, { sortedTrails }); const { basename } = currFile; - const { main } = this.currGraphs; - const next = []; - const prev = []; - main.forEachEdge(basename, (k, a, s, t) => { - if (a.dir === "next" && s === basename) { - next.push({ to: t, real: true }); - } - if (a.dir === "prev" && t === basename) { - next.push({ to: s, real: false }); - } - if (a.dir === "prev" && s === basename) { - prev.push({ to: t, real: true }); - } - if (a.dir === "next" && t === basename) { - prev.push({ to: s, real: false }); - } - }); + const { rPrev, rNext, iPrev, iNext } = getPrevNext(this, basename); + const next = [...rNext, ...iNext]; + const prev = [...rPrev, ...iPrev]; const noItems = sortedTrails.length === 0 && next.length === 0 && prev.length === 0; if (noItems && settings.noPathMessage === "") { debugGroupEnd(settings, "debugMode"); diff --git a/src/sharedFunctions.ts b/src/sharedFunctions.ts index 2aaddfc0..bdf1eed5 100644 --- a/src/sharedFunctions.ts +++ b/src/sharedFunctions.ts @@ -654,11 +654,10 @@ export function getAllFieldGs(fields: string[], currGraphs: HierarchyGraphs[]) { return fieldGs; } -export function hierToStr(hier: userHierarchy) { - return `↑: ${hier.up.join(", ")} -→: ${hier.same.join(", ")} -↓: ${hier.down.join(", ")}`; -} +export const hierToStr = (hier: userHierarchy) => + DIRECTIONS.map( + (dir) => `${ARROW_DIRECTIONS[dir]}: ${hier[dir].join(", ")}` + ).join("\n"); export function removeDuplicates(arr: T[]) { return [...new Set(arr)];