From 44026e7ea67bd72ec5ee768e2b249422cf763378 Mon Sep 17 00:00:00 2001 From: Ross Keenan Date: Tue, 30 Nov 2021 08:48:42 +0200 Subject: [PATCH] fix(DucksView): :bug: Return correct ViewType --- main.js | 1066 +++++++++++++++++++++++++++++++++++++--------- src/DucksView.ts | 6 +- 2 files changed, 864 insertions(+), 208 deletions(-) diff --git a/main.js b/main.js index 4894891a..d5f42b6e 100644 --- a/main.js +++ b/main.js @@ -20354,6 +20354,19 @@ function update($$) { } const outroing = new Set(); let outros; +function group_outros() { + outros = { + r: 0, + c: [], + p: outros // parent group + }; +} +function check_outros() { + if (!outros.r) { + run_all(outros.c); + } + outros = outros.p; +} function transition_in(block, local) { if (block && block.i) { outroing.delete(block); @@ -20542,7 +20555,7 @@ class SvelteComponent { /* src\Components\KoFi.svelte generated by Svelte v3.35.0 */ -function create_fragment$e(ctx) { +function create_fragment$h(ctx) { let script; let script_src_value; let t; @@ -20583,7 +20596,7 @@ function create_fragment$e(ctx) { }; } -function instance$e($$self, $$props, $$invalidate) { +function instance$h($$self, $$props, $$invalidate) { let button; var initializeKofi = () => { @@ -20604,13 +20617,13 @@ function instance$e($$self, $$props, $$invalidate) { class KoFi extends SvelteComponent { constructor(options) { super(); - init(this, options, instance$e, create_fragment$e, safe_not_equal, {}); + init(this, options, instance$h, create_fragment$h, safe_not_equal, {}); } } /* node_modules\svelte-icons\components\IconBase.svelte generated by Svelte v3.35.0 */ -function add_css$8() { +function add_css$9() { var style = element("style"); style.id = "svelte-c8tyih-style"; style.textContent = "svg.svelte-c8tyih{stroke:currentColor;fill:currentColor;stroke-width:0;width:100%;height:auto;max-height:100%}"; @@ -20618,7 +20631,7 @@ function add_css$8() { } // (18:2) {#if title} -function create_if_block$4(ctx) { +function create_if_block$5(ctx) { let title_1; let t; @@ -20640,11 +20653,11 @@ function create_if_block$4(ctx) { }; } -function create_fragment$d(ctx) { +function create_fragment$g(ctx) { let svg; let if_block_anchor; let current; - let if_block = /*title*/ ctx[0] && create_if_block$4(ctx); + let if_block = /*title*/ ctx[0] && create_if_block$5(ctx); const default_slot_template = /*#slots*/ ctx[3].default; const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[2], null); @@ -20674,7 +20687,7 @@ function create_fragment$d(ctx) { if (if_block) { if_block.p(ctx, dirty); } else { - if_block = create_if_block$4(ctx); + if_block = create_if_block$5(ctx); if_block.c(); if_block.m(svg, if_block_anchor); } @@ -20687,51 +20700,822 @@ function create_fragment$d(ctx) { if (default_slot.p && dirty & /*$$scope*/ 4) { update_slot(default_slot, default_slot_template, ctx, /*$$scope*/ ctx[2], dirty, null, null); } - } + } + + if (!current || dirty & /*viewBox*/ 2) { + attr(svg, "viewBox", /*viewBox*/ ctx[1]); + } + }, + i(local) { + if (current) return; + transition_in(default_slot, local); + current = true; + }, + o(local) { + transition_out(default_slot, local); + current = false; + }, + d(detaching) { + if (detaching) detach(svg); + if (if_block) if_block.d(); + if (default_slot) default_slot.d(detaching); + } + }; +} + +function instance$g($$self, $$props, $$invalidate) { + let { $$slots: slots = {}, $$scope } = $$props; + let { title = null } = $$props; + let { viewBox } = $$props; + + $$self.$$set = $$props => { + if ("title" in $$props) $$invalidate(0, title = $$props.title); + if ("viewBox" in $$props) $$invalidate(1, viewBox = $$props.viewBox); + if ("$$scope" in $$props) $$invalidate(2, $$scope = $$props.$$scope); + }; + + return [title, viewBox, $$scope, slots]; +} + +class IconBase extends SvelteComponent { + constructor(options) { + super(); + if (!document.getElementById("svelte-c8tyih-style")) add_css$9(); + init(this, options, instance$g, create_fragment$g, safe_not_equal, { title: 0, viewBox: 1 }); + } +} + +/* node_modules\svelte-icons\fa\FaFire.svelte generated by Svelte v3.35.0 */ + +function create_default_slot$5(ctx) { + let path; + + return { + c() { + path = svg_element("path"); + attr(path, "d", "M216 23.86c0-23.8-30.65-32.77-44.15-13.04C48 191.85 224 200 224 288c0 35.63-29.11 64.46-64.85 63.99-35.17-.45-63.15-29.77-63.15-64.94v-85.51c0-21.7-26.47-32.23-41.43-16.5C27.8 213.16 0 261.33 0 320c0 105.87 86.13 192 192 192s192-86.13 192-192c0-170.29-168-193-168-296.14z"); + }, + m(target, anchor) { + insert(target, path, anchor); + }, + d(detaching) { + if (detaching) detach(path); + } + }; +} + +function create_fragment$f(ctx) { + let iconbase; + let current; + const iconbase_spread_levels = [{ viewBox: "0 0 384 512" }, /*$$props*/ ctx[0]]; + + let iconbase_props = { + $$slots: { default: [create_default_slot$5] }, + $$scope: { ctx } + }; + + for (let i = 0; i < iconbase_spread_levels.length; i += 1) { + iconbase_props = assign(iconbase_props, iconbase_spread_levels[i]); + } + + iconbase = new IconBase({ props: iconbase_props }); + + return { + c() { + create_component(iconbase.$$.fragment); + }, + m(target, anchor) { + mount_component(iconbase, target, anchor); + current = true; + }, + p(ctx, [dirty]) { + const iconbase_changes = (dirty & /*$$props*/ 1) + ? get_spread_update(iconbase_spread_levels, [iconbase_spread_levels[0], get_spread_object(/*$$props*/ ctx[0])]) + : {}; + + if (dirty & /*$$scope*/ 2) { + iconbase_changes.$$scope = { dirty, ctx }; + } + + iconbase.$set(iconbase_changes); + }, + i(local) { + if (current) return; + transition_in(iconbase.$$.fragment, local); + current = true; + }, + o(local) { + transition_out(iconbase.$$.fragment, local); + current = false; + }, + d(detaching) { + destroy_component(iconbase, detaching); + } + }; +} + +function instance$f($$self, $$props, $$invalidate) { + $$self.$$set = $$new_props => { + $$invalidate(0, $$props = assign(assign({}, $$props), exclude_internal_props($$new_props))); + }; + + $$props = exclude_internal_props($$props); + return [$$props]; +} + +class FaFire extends SvelteComponent { + constructor(options) { + super(); + init(this, options, instance$f, create_fragment$f, safe_not_equal, {}); + } +} + +/* node_modules\svelte-icons\fa\FaRegSnowflake.svelte generated by Svelte v3.35.0 */ + +function create_default_slot$4(ctx) { + let path; + + return { + c() { + path = svg_element("path"); + attr(path, "d", "M440.1 355.2l-39.2-23 34.1-9.3c8.4-2.3 13.4-11.1 11.1-19.6l-4.1-15.5c-2.2-8.5-10.9-13.6-19.3-11.3L343 298.2 271.2 256l71.9-42.2 79.7 21.7c8.4 2.3 17-2.8 19.3-11.3l4.1-15.5c2.2-8.5-2.7-17.3-11.1-19.6l-34.1-9.3 39.2-23c7.5-4.4 10.1-14.2 5.8-21.9l-7.9-13.9c-4.3-7.7-14-10.3-21.5-5.9l-39.2 23 9.1-34.7c2.2-8.5-2.7-17.3-11.1-19.6l-15.2-4.1c-8.4-2.3-17 2.8-19.3 11.3l-21.3 81-71.9 42.2v-84.5L306 70.4c6.1-6.2 6.1-16.4 0-22.6l-11.1-11.3c-6.1-6.2-16.1-6.2-22.2 0l-24.9 25.4V16c0-8.8-7-16-15.7-16h-15.7c-8.7 0-15.7 7.2-15.7 16v46.1l-24.9-25.4c-6.1-6.2-16.1-6.2-22.2 0L142.1 48c-6.1 6.2-6.1 16.4 0 22.6l58.3 59.3v84.5l-71.9-42.2-21.3-81c-2.2-8.5-10.9-13.6-19.3-11.3L72.7 84c-8.4 2.3-13.4 11.1-11.1 19.6l9.1 34.7-39.2-23c-7.5-4.4-17.1-1.8-21.5 5.9l-7.9 13.9c-4.3 7.7-1.8 17.4 5.8 21.9l39.2 23-34.1 9.1c-8.4 2.3-13.4 11.1-11.1 19.6L6 224.2c2.2 8.5 10.9 13.6 19.3 11.3l79.7-21.7 71.9 42.2-71.9 42.2-79.7-21.7c-8.4-2.3-17 2.8-19.3 11.3l-4.1 15.5c-2.2 8.5 2.7 17.3 11.1 19.6l34.1 9.3-39.2 23c-7.5 4.4-10.1 14.2-5.8 21.9L10 391c4.3 7.7 14 10.3 21.5 5.9l39.2-23-9.1 34.7c-2.2 8.5 2.7 17.3 11.1 19.6l15.2 4.1c8.4 2.3 17-2.8 19.3-11.3l21.3-81 71.9-42.2v84.5l-58.3 59.3c-6.1 6.2-6.1 16.4 0 22.6l11.1 11.3c6.1 6.2 16.1 6.2 22.2 0l24.9-25.4V496c0 8.8 7 16 15.7 16h15.7c8.7 0 15.7-7.2 15.7-16v-46.1l24.9 25.4c6.1 6.2 16.1 6.2 22.2 0l11.1-11.3c6.1-6.2 6.1-16.4 0-22.6l-58.3-59.3v-84.5l71.9 42.2 21.3 81c2.2 8.5 10.9 13.6 19.3 11.3L375 428c8.4-2.3 13.4-11.1 11.1-19.6l-9.1-34.7 39.2 23c7.5 4.4 17.1 1.8 21.5-5.9l7.9-13.9c4.6-7.5 2.1-17.3-5.5-21.7z"); + }, + m(target, anchor) { + insert(target, path, anchor); + }, + d(detaching) { + if (detaching) detach(path); + } + }; +} + +function create_fragment$e(ctx) { + let iconbase; + let current; + const iconbase_spread_levels = [{ viewBox: "0 0 448 512" }, /*$$props*/ ctx[0]]; + + let iconbase_props = { + $$slots: { default: [create_default_slot$4] }, + $$scope: { ctx } + }; + + for (let i = 0; i < iconbase_spread_levels.length; i += 1) { + iconbase_props = assign(iconbase_props, iconbase_spread_levels[i]); + } + + iconbase = new IconBase({ props: iconbase_props }); + + return { + c() { + create_component(iconbase.$$.fragment); + }, + m(target, anchor) { + mount_component(iconbase, target, anchor); + current = true; + }, + p(ctx, [dirty]) { + const iconbase_changes = (dirty & /*$$props*/ 1) + ? get_spread_update(iconbase_spread_levels, [iconbase_spread_levels[0], get_spread_object(/*$$props*/ ctx[0])]) + : {}; + + if (dirty & /*$$scope*/ 2) { + iconbase_changes.$$scope = { dirty, ctx }; + } + + iconbase.$set(iconbase_changes); + }, + i(local) { + if (current) return; + transition_in(iconbase.$$.fragment, local); + current = true; + }, + o(local) { + transition_out(iconbase.$$.fragment, local); + current = false; + }, + d(detaching) { + destroy_component(iconbase, detaching); + } + }; +} + +function instance$e($$self, $$props, $$invalidate) { + $$self.$$set = $$new_props => { + $$invalidate(0, $$props = assign(assign({}, $$props), exclude_internal_props($$new_props))); + }; + + $$props = exclude_internal_props($$props); + return [$$props]; +} + +class FaRegSnowflake extends SvelteComponent { + constructor(options) { + super(); + init(this, options, instance$e, create_fragment$e, safe_not_equal, {}); + } +} + +// TODO - this is a hack to get the graph to work with the approvals +// I shouldn't need +const DIRECTIONS$1 = ["up", "same", "down", "next", "prev"]; +// This function takes the real & implied graphs for a given relation, and returns a new graphs with both. +// It makes implied relations real +// TODO use reflexiveClosure instead +function closeImpliedLinks(real, implied) { + const closedG = real.copy(); + implied.forEachEdge((key, a, s, t) => { + closedG.mergeEdge(t, s, a); + }); + return closedG; +} +function removeUnlinkedNodes(g) { + const copy = g.copy(); + copy.forEachNode((node) => { + if (!copy.degree(node)) + copy.dropNode(node); + }); + return copy; +} +/** + * Return a subgraph of all nodes & edges with `dirs.includes(a.dir)` + * @param {MultiGraph} main + * @param {Directions} dir + */ +function getSubInDirs(main, ...dirs) { + const sub = new graphology_umd_min.MultiGraph(); + main.forEachEdge((k, a, s, t) => { + if (dirs.includes(a.dir)) { + //@ts-ignore + addNodesIfNot(sub, [s, t], a); + sub.addEdge(s, t, a); + } + }); + return sub; +} +/** + * Return a subgraph of all nodes & edges with `files.includes(a.field)` + * @param {MultiGraph} main + * @param {string[]} fields + */ +function getSubForFields(main, fields) { + const sub = new graphology_umd_min.MultiGraph(); + main.forEachEdge((k, a, s, t) => { + if (fields.includes(a.field)) { + //@ts-ignore + addNodesIfNot(sub, [s, t], a); + sub.addEdge(s, t, a); + } + }); + return sub; +} +/** + * For every edge in `g`, add the reverse of the edge to a copy of `g`. + * + * It also sets the attrs of the reverse edges to `oppDir` and `oppFields[0]` + * @param {MultiGraph} g + * @param {UserHier[]} userHiers + * @param {boolean} closeAsOpposite + */ +function getReflexiveClosure(g, userHiers, closeAsOpposite = true) { + const copy = g.copy(); + copy.forEachEdge((k, a, s, t) => { + const { dir, field } = a; + if (field === undefined) + return; + const oppDir = getOppDir(dir); + const oppField = getOppFields(userHiers, field)[0]; + addNodesIfNot(copy, [s, t], { + //@ts-ignore + dir: closeAsOpposite ? oppDir : dir, + field: closeAsOpposite ? oppField : field, + }); + addEdgeIfNot(copy, t, s, { + //@ts-ignore + dir: closeAsOpposite ? oppDir : dir, + field: closeAsOpposite ? oppField : field, + }); + }); + return copy; +} +function addNodesIfNot(g, nodes, attr) { + nodes.forEach((node) => { + if (!g.hasNode(node)) + g.addNode(node, attr); + }); +} +function addEdgeIfNot(g, source, target, attr) { + if (!g.hasEdge(source, target)) + g.addEdge(source, target, attr); +} +const getSinks = (g) => g.filterNodes((node) => g.hasNode(node) && !g.outDegree(node)); +const getOutNeighbours = (g, node) => g.hasNode(node) ? g.outNeighbors(node) : []; +const getInNeighbours = (g, node) => g.hasNode(node) ? g.inNeighbors(node) : []; +const getOppDir = (dir) => { + switch (dir) { + case "up": + return "down"; + case "down": + return "up"; + case "same": + return "same"; + case "next": + return "prev"; + case "prev": + return "next"; + } +}; +/** + * Get the hierarchy and direction that `field` is in + * */ +function getFieldInfo(userHiers, field) { + let fieldDir; + let fieldHier; + DIRECTIONS$1.forEach((dir) => { + userHiers.forEach((hier) => { + if (hier[dir].includes(field)) { + fieldDir = dir; + fieldHier = hier; + return; + } + }); + }); + return { fieldHier, fieldDir }; +} +function getOppFields(userHiers, field) { + const { fieldHier, fieldDir } = getFieldInfo(userHiers, field); + const oppDir = getOppDir(fieldDir); + return fieldHier[oppDir]; +} +function dfsAllPaths(g, startNode) { + const queue = [ + { node: startNode, path: [] }, + ]; + const visited = []; + const allPaths = []; + let i = 0; + while (queue.length > 0 && i < 1000) { + i++; + const { node, path } = queue.shift(); + const extPath = [node, ...path]; + const succsNotVisited = g.hasNode(node) + ? g.filterOutNeighbors(node, (n, a) => !visited.includes(n)) + : []; + const newItems = succsNotVisited.map((n) => { + return { node: n, path: extPath }; + }); + visited.push(...succsNotVisited); + queue.unshift(...newItems); + if (!g.hasNode(node) || !g.outDegree(node)) + allPaths.push(extPath); + } + return allPaths; +} + +/* src\Components\Down.svelte generated by Svelte v3.35.0 */ + +function add_css$8() { + var style = element("style"); + style.id = "svelte-1rg5cw9-style"; + style.textContent = "pre.svelte-1rg5cw9{display:inline}.is-unresolved.svelte-1rg5cw9{color:var(--text-muted)}"; + append(document.head, style); +} + +function get_each_context$9(ctx, list, i) { + const child_ctx = ctx.slice(); + child_ctx[11] = list[i]; + return child_ctx; +} + +// (43:4) {:else} +function create_else_block$1(ctx) { + let fafire; + let current; + fafire = new FaFire({}); + + return { + c() { + create_component(fafire.$$.fragment); + }, + m(target, anchor) { + mount_component(fafire, target, anchor); + current = true; + }, + i(local) { + if (current) return; + transition_in(fafire.$$.fragment, local); + current = true; + }, + o(local) { + transition_out(fafire.$$.fragment, local); + current = false; + }, + d(detaching) { + destroy_component(fafire, detaching); + } + }; +} + +// (41:4) {#if frozen} +function create_if_block_1$3(ctx) { + let faregsnowflake; + let current; + faregsnowflake = new FaRegSnowflake({}); + + return { + c() { + create_component(faregsnowflake.$$.fragment); + }, + m(target, anchor) { + mount_component(faregsnowflake, target, anchor); + current = true; + }, + i(local) { + if (current) return; + transition_in(faregsnowflake.$$.fragment, local); + current = true; + }, + o(local) { + transition_out(faregsnowflake.$$.fragment, local); + current = false; + }, + d(detaching) { + destroy_component(faregsnowflake, detaching); + } + }; +} + +// (60:2) {#if line.length > 1} +function create_if_block$4(ctx) { + let div; + let pre; + let t0_value = /*line*/ ctx[11][0] + "- " + ""; + let t0; + let t1; + let span; + let a; + let t2_value = /*line*/ ctx[11][1] + ""; + let t2; + let a_class_value; + let t3; + let mounted; + let dispose; + + function click_handler_2(...args) { + return /*click_handler_2*/ ctx[7](/*line*/ ctx[11], ...args); + } + + function mouseover_handler(...args) { + return /*mouseover_handler*/ ctx[8](/*line*/ ctx[11], ...args); + } + + return { + c() { + div = element("div"); + pre = element("pre"); + t0 = text(t0_value); + t1 = space(); + span = element("span"); + a = element("a"); + t2 = text(t2_value); + t3 = space(); + attr(pre, "class", "svelte-1rg5cw9"); + + attr(a, "class", a_class_value = "internal-link " + (isInVault(/*plugin*/ ctx[0].app, /*line*/ ctx[11][1]) + ? "" + : "is-unresolved") + " svelte-1rg5cw9"); + + attr(span, "class", "internal-link"); + }, + m(target, anchor) { + insert(target, div, anchor); + append(div, pre); + append(pre, t0); + append(div, t1); + append(div, span); + append(span, a); + append(a, t2); + append(div, t3); + + if (!mounted) { + dispose = [ + listen(span, "click", click_handler_2), + listen(span, "mouseover", mouseover_handler) + ]; + + mounted = true; + } + }, + p(new_ctx, dirty) { + ctx = new_ctx; + if (dirty & /*lines*/ 16 && t0_value !== (t0_value = /*line*/ ctx[11][0] + "- " + "")) set_data(t0, t0_value); + if (dirty & /*lines*/ 16 && t2_value !== (t2_value = /*line*/ ctx[11][1] + "")) set_data(t2, t2_value); + + if (dirty & /*plugin, lines*/ 17 && a_class_value !== (a_class_value = "internal-link " + (isInVault(/*plugin*/ ctx[0].app, /*line*/ ctx[11][1]) + ? "" + : "is-unresolved") + " svelte-1rg5cw9")) { + attr(a, "class", a_class_value); + } + }, + d(detaching) { + if (detaching) detach(div); + mounted = false; + run_all(dispose); + } + }; +} + +// (59:0) {#each lines as line} +function create_each_block$9(ctx) { + let if_block_anchor; + let if_block = /*line*/ ctx[11].length > 1 && create_if_block$4(ctx); + + return { + c() { + if (if_block) if_block.c(); + if_block_anchor = empty(); + }, + m(target, anchor) { + if (if_block) if_block.m(target, anchor); + insert(target, if_block_anchor, anchor); + }, + p(ctx, dirty) { + if (/*line*/ ctx[11].length > 1) { + if (if_block) { + if_block.p(ctx, dirty); + } else { + if_block = create_if_block$4(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 (if_block) if_block.d(detaching); + if (detaching) detach(if_block_anchor); + } + }; +} + +function create_fragment$d(ctx) { + let div; + let span; + let current_block_type_index; + let if_block; + let span_aria_label_value; + let t0; + let button; + let t2; + let each_1_anchor; + let current; + let mounted; + let dispose; + const if_block_creators = [create_if_block_1$3, create_else_block$1]; + const if_blocks = []; + + function select_block_type(ctx, dirty) { + if (/*frozen*/ ctx[3]) return 0; + return 1; + } + + current_block_type_index = select_block_type(ctx); + if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); + let each_value = /*lines*/ ctx[4]; + let each_blocks = []; + + for (let i = 0; i < each_value.length; i += 1) { + each_blocks[i] = create_each_block$9(get_each_context$9(ctx, each_value, i)); + } + + return { + c() { + div = element("div"); + span = element("span"); + if_block.c(); + t0 = space(); + button = element("button"); + button.textContent = "↻"; + t2 = space(); + + for (let i = 0; i < each_blocks.length; i += 1) { + each_blocks[i].c(); + } + + each_1_anchor = empty(); + attr(span, "class", "icon nav-action-button"); + + attr(span, "aria-label", span_aria_label_value = /*frozen*/ ctx[3] + ? `Frozen on: ${/*basename*/ ctx[2]}` + : "Unfrozen"); + + attr(span, "aria-label-position", "left"); + attr(button, "class", "icon"); + attr(button, "aria-label", "Refresh Stats View (also refreshes Breadcrumbs Index)"); + }, + m(target, anchor) { + insert(target, div, anchor); + append(div, span); + if_blocks[current_block_type_index].m(span, null); + append(div, t0); + append(div, button); + insert(target, t2, anchor); + + for (let i = 0; i < each_blocks.length; i += 1) { + each_blocks[i].m(target, anchor); + } + + insert(target, each_1_anchor, anchor); + current = true; + + if (!mounted) { + dispose = [ + listen(span, "click", /*click_handler*/ ctx[5]), + listen(button, "click", /*click_handler_1*/ ctx[6]) + ]; + + mounted = true; + } + }, + p(ctx, [dirty]) { + let previous_block_index = current_block_type_index; + current_block_type_index = select_block_type(ctx); + + if (current_block_type_index !== previous_block_index) { + group_outros(); + + transition_out(if_blocks[previous_block_index], 1, 1, () => { + if_blocks[previous_block_index] = null; + }); + + check_outros(); + if_block = if_blocks[current_block_type_index]; + + if (!if_block) { + if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); + if_block.c(); + } + + transition_in(if_block, 1); + if_block.m(span, null); + } + + if (!current || dirty & /*frozen, basename*/ 12 && span_aria_label_value !== (span_aria_label_value = /*frozen*/ ctx[3] + ? `Frozen on: ${/*basename*/ ctx[2]}` + : "Unfrozen")) { + attr(span, "aria-label", span_aria_label_value); + } + + if (dirty & /*openOrSwitch, plugin, lines, hoverPreview, view, isInVault*/ 19) { + each_value = /*lines*/ ctx[4]; + let i; + + for (i = 0; i < each_value.length; i += 1) { + const child_ctx = get_each_context$9(ctx, each_value, i); + + if (each_blocks[i]) { + each_blocks[i].p(child_ctx, dirty); + } else { + each_blocks[i] = create_each_block$9(child_ctx); + each_blocks[i].c(); + each_blocks[i].m(each_1_anchor.parentNode, each_1_anchor); + } + } - if (!current || dirty & /*viewBox*/ 2) { - attr(svg, "viewBox", /*viewBox*/ ctx[1]); + for (; i < each_blocks.length; i += 1) { + each_blocks[i].d(1); + } + + each_blocks.length = each_value.length; } }, i(local) { if (current) return; - transition_in(default_slot, local); + transition_in(if_block); current = true; }, o(local) { - transition_out(default_slot, local); + transition_out(if_block); current = false; }, d(detaching) { - if (detaching) detach(svg); - if (if_block) if_block.d(); - if (default_slot) default_slot.d(detaching); + if (detaching) detach(div); + if_blocks[current_block_type_index].d(); + if (detaching) detach(t2); + destroy_each(each_blocks, detaching); + if (detaching) detach(each_1_anchor); + mounted = false; + run_all(dispose); } }; } function instance$d($$self, $$props, $$invalidate) { - let { $$slots: slots = {}, $$scope } = $$props; - let { title = null } = $$props; - let { viewBox } = $$props; + + + let { plugin } = $$props; + let { view } = $$props; + const { settings } = plugin; + const { userHiers } = settings; + let frozen = false; + let { basename } = plugin.app.workspace.getActiveFile(); + + plugin.app.workspace.on("active-leaf-change", () => { + if (frozen) return; + $$invalidate(2, basename = plugin.app.workspace.getActiveFile().basename); + }); + + let lines; + + const click_handler = () => { + $$invalidate(3, frozen = !frozen); + if (!frozen) $$invalidate(2, basename = plugin.app.workspace.getActiveFile().basename); + }; + + const click_handler_1 = async () => { + await plugin.refreshIndex(); + await view.draw(); + }; + + const click_handler_2 = async (line, e) => await openOrSwitch(plugin.app, line[1], e); + const mouseover_handler = (line, e) => hoverPreview(e, view, line[1]); $$self.$$set = $$props => { - if ("title" in $$props) $$invalidate(0, title = $$props.title); - if ("viewBox" in $$props) $$invalidate(1, viewBox = $$props.viewBox); - if ("$$scope" in $$props) $$invalidate(2, $$scope = $$props.$$scope); + if ("plugin" in $$props) $$invalidate(0, plugin = $$props.plugin); + if ("view" in $$props) $$invalidate(1, view = $$props.view); }; - return [title, viewBox, $$scope, slots]; + $$self.$$.update = () => { + if ($$self.$$.dirty & /*plugin, basename*/ 5) { + { + const { mainG } = plugin; + const upnDown = getSubInDirs(mainG, "up", "down"); + const closed = getReflexiveClosure(upnDown, userHiers); + const down = getSubInDirs(closed, "down"); + const allPaths = dfsAllPaths(down, basename); + const index = plugin.createIndex(allPaths); + console.log({ allPaths, index, down: down.inspect() }); + $$invalidate(4, lines = index.split("\n").map(line => line.split("- "))); + } + } + }; + + return [ + plugin, + view, + basename, + frozen, + lines, + click_handler, + click_handler_1, + click_handler_2, + mouseover_handler + ]; } -class IconBase extends SvelteComponent { +class Down extends SvelteComponent { constructor(options) { super(); - if (!document.getElementById("svelte-c8tyih-style")) add_css$8(); - init(this, options, instance$d, create_fragment$d, safe_not_equal, { title: 0, viewBox: 1 }); + if (!document.getElementById("svelte-1rg5cw9-style")) add_css$8(); + init(this, options, instance$d, create_fragment$d, safe_not_equal, { plugin: 0, view: 1 }); } } +class DownView extends require$$0.ItemView { + constructor(leaf, plugin) { + super(leaf); + this.icon = addFeatherIcon("corner-right-down"); + this.plugin = plugin; + } + async onload() { + super.onload(); + this.app.workspace.onLayoutReady(async () => { + await this.draw(); + }); + } + getViewType() { + return DOWN_VIEW; + } + getDisplayText() { + return "Breadcrumbs Down"; + } + async onOpen() { } + onClose() { + if (this.view) { + this.view.$destroy(); + } + return Promise.resolve(); + } + async draw() { + this.contentEl.empty(); + this.view = new Down({ + target: this.contentEl, + props: { plugin: this.plugin, view: this }, + }); + } +} + /* node_modules\svelte-icons\fa\FaInfo.svelte generated by Svelte v3.35.0 */ function create_default_slot$3(ctx) { @@ -21100,7 +21884,7 @@ class DucksView extends require$$0.ItemView { }); } getViewType() { - return STATS_VIEW; + return DUCK_VIEW; } getDisplayText() { return "Breadcrumbs Ducks"; @@ -22474,162 +23258,6 @@ class Matrix extends SvelteComponent { } } -// TODO - this is a hack to get the graph to work with the approvals -// I shouldn't need -const DIRECTIONS$1 = ["up", "same", "down", "next", "prev"]; -// This function takes the real & implied graphs for a given relation, and returns a new graphs with both. -// It makes implied relations real -// TODO use reflexiveClosure instead -function closeImpliedLinks(real, implied) { - const closedG = real.copy(); - implied.forEachEdge((key, a, s, t) => { - closedG.mergeEdge(t, s, a); - }); - return closedG; -} -function removeUnlinkedNodes(g) { - const copy = g.copy(); - copy.forEachNode((node) => { - if (!copy.degree(node)) - copy.dropNode(node); - }); - return copy; -} -/** - * Return a subgraph of all nodes & edges with `dirs.includes(a.dir)` - * @param {MultiGraph} main - * @param {Directions} dir - */ -function getSubInDirs(main, ...dirs) { - const sub = new graphology_umd_min.MultiGraph(); - main.forEachEdge((k, a, s, t) => { - if (dirs.includes(a.dir)) { - //@ts-ignore - addNodesIfNot(sub, [s, t], a); - sub.addEdge(s, t, a); - } - }); - return sub; -} -/** - * Return a subgraph of all nodes & edges with `files.includes(a.field)` - * @param {MultiGraph} main - * @param {string[]} fields - */ -function getSubForFields(main, fields) { - const sub = new graphology_umd_min.MultiGraph(); - main.forEachEdge((k, a, s, t) => { - if (fields.includes(a.field)) { - //@ts-ignore - addNodesIfNot(sub, [s, t], a); - sub.addEdge(s, t, a); - } - }); - return sub; -} -/** - * For every edge in `g`, add the reverse of the edge to a copy of `g`. - * - * It also sets the attrs of the reverse edges to `oppDir` and `oppFields[0]` - * @param {MultiGraph} g - * @param {UserHier[]} userHiers - * @param {boolean} closeAsOpposite - */ -function getReflexiveClosure(g, userHiers, closeAsOpposite = true) { - const copy = g.copy(); - copy.forEachEdge((k, a, s, t) => { - const { dir, field } = a; - if (field === undefined) - return; - const oppDir = getOppDir(dir); - const oppField = getOppFields(userHiers, field)[0]; - addNodesIfNot(copy, [s, t], { - //@ts-ignore - dir: closeAsOpposite ? oppDir : dir, - field: closeAsOpposite ? oppField : field, - }); - addEdgeIfNot(copy, t, s, { - //@ts-ignore - dir: closeAsOpposite ? oppDir : dir, - field: closeAsOpposite ? oppField : field, - }); - }); - return copy; -} -function addNodesIfNot(g, nodes, attr) { - nodes.forEach((node) => { - if (!g.hasNode(node)) - g.addNode(node, attr); - }); -} -function addEdgeIfNot(g, source, target, attr) { - if (!g.hasEdge(source, target)) - g.addEdge(source, target, attr); -} -const getSinks = (g) => g.filterNodes((node) => g.hasNode(node) && !g.outDegree(node)); -const getOutNeighbours = (g, node) => g.hasNode(node) ? g.outNeighbors(node) : []; -const getInNeighbours = (g, node) => g.hasNode(node) ? g.inNeighbors(node) : []; -const getOppDir = (dir) => { - switch (dir) { - case "up": - return "down"; - case "down": - return "up"; - case "same": - return "same"; - case "next": - return "prev"; - case "prev": - return "next"; - } -}; -/** - * Get the hierarchy and direction that `field` is in - * */ -function getFieldInfo(userHiers, field) { - let fieldDir; - let fieldHier; - DIRECTIONS$1.forEach((dir) => { - userHiers.forEach((hier) => { - if (hier[dir].includes(field)) { - fieldDir = dir; - fieldHier = hier; - return; - } - }); - }); - return { fieldHier, fieldDir }; -} -function getOppFields(userHiers, field) { - const { fieldHier, fieldDir } = getFieldInfo(userHiers, field); - const oppDir = getOppDir(fieldDir); - return fieldHier[oppDir]; -} -function dfsAllPaths(g, startNode) { - const queue = [ - { node: startNode, path: [] }, - ]; - const visited = []; - const allPaths = []; - let i = 0; - while (queue.length > 0 && i < 1000) { - i++; - const { node, path } = queue.shift(); - const extPath = [node, ...path]; - const succsNotVisited = g.hasNode(node) - ? g.filterOutNeighbors(node, (n, a) => !visited.includes(n)) - : []; - const newItems = succsNotVisited.map((n) => { - return { node: n, path: extPath }; - }); - visited.push(...succsNotVisited); - queue.unshift(...newItems); - // if (!g.hasNode(node) || !g.outDegree(node)) - allPaths.push(extPath); - } - return allPaths; -} - function normalise(arr) { const max = Math.max(...arr); return arr.map((item) => item / max); @@ -24184,6 +24812,7 @@ class StatsView extends require$$0.ItemView { const MATRIX_VIEW = "BC-matrix"; const STATS_VIEW = "BC-stats"; const DUCK_VIEW = "BC-ducks"; +const DOWN_VIEW = "BC-down"; const VIEWS = [ { plain: "Matrix", @@ -24198,6 +24827,7 @@ const VIEWS = [ openOnLoad: true, }, { plain: "Duck", type: DUCK_VIEW, constructor: DucksView, openOnLoad: false }, + { plain: "Down", type: DOWN_VIEW, constructor: DownView, openOnLoad: true }, ]; const TRAIL_ICON = "BC-trail-icon"; const TRAIL_ICON_SVG = ''; @@ -24315,6 +24945,7 @@ const DEFAULT_SETTINGS = { showAllPathsIfNoneToIndexNote: false, showBCs: true, showBCsInEditLPMode: false, + showRefreshNotice: true, showTrail: true, showGrid: true, showPrevNext: true, @@ -25152,6 +25783,13 @@ class BCSettingTab extends require$$0.PluginSettingTab { await plugin.saveSettings(); }; }); + new require$$0.Setting(generalDetails) + .setName("Show Refresh Index Notice") + .setDesc("When Refreshing Index, should it show a notice once the operation is complete?") + .addToggle((toggle) => toggle.setValue(settings.showRefreshNotice).onChange(async (value) => { + settings.showRefreshNotice = value; + await plugin.saveSettings(); + })); new require$$0.Setting(generalDetails) .setName("Enable Field Suggestor") .setDesc('Alot of Breadcrumbs features require a metadata (or inline Dataview) field to work. For example, `BC-folder-note`. The Field Suggestor will show an autocomplete menu with all available Breadcrumbs field options when the content you type matches the regex /^BC-.*$/. Basically, just type "BC-" at the start of a line to trigger it.') @@ -48852,7 +49490,8 @@ class BCPlugin extends require$$0.Plugin { await ((_a = this.getActiveTYPEView(view.type)) === null || _a === void 0 ? void 0 : _a.draw()); if (this.settings.showTrail) await this.drawTrail(); - new require$$0.Notice("Index refreshed"); + if (this.settings.showRefreshNotice) + new require$$0.Notice("Index refreshed"); } registerActiveLeafChangeEvent() { this.activeLeafChange = this.app.workspace.on("active-leaf-change", async () => { @@ -49003,7 +49642,7 @@ class BCPlugin extends require$$0.Plugin { const closed = getReflexiveClosure(g, settings.userHiers); const onlyDowns = getSubInDirs(closed, "down"); const allPaths = dfsAllPaths(onlyDowns, basename); - const index = this.createIndex(allPaths); + const index = this.addAliasesToIndex(this.createIndex(allPaths)); loglevel.info({ index }); await copy(index); }, @@ -49021,7 +49660,8 @@ class BCPlugin extends require$$0.Plugin { sinks.forEach((terminal) => { globalIndex += terminal + "\n"; const allPaths = dfsAllPaths(onlyDowns, terminal); - globalIndex += this.createIndex(allPaths) + "\n"; + globalIndex += + this.addAliasesToIndex(this.createIndex(allPaths)) + "\n"; }); loglevel.info({ globalIndex }); await copy(globalIndex); @@ -49262,8 +49902,10 @@ class BCPlugin extends require$$0.Plugin { const strs = splits.map((link) => getBaseFromMDPath(link.match(dropHeaderOrAlias)[1])); parsed.push(...strs); } - else - parsed.push(getBaseFromMDPath(rawAsString)); + else { + const basename = getBaseFromMDPath(rawAsString); + parsed.push(basename.split("#")[0].split("|")[0]); + } } else if (value.path !== undefined) { const basename = getBaseFromMDPath(value.path); @@ -49630,9 +50272,7 @@ class BCPlugin extends require$$0.Plugin { reversed.forEach((path) => path.shift()); const indent = " "; const visited = {}; - const { metadataCache } = this.app; reversed.forEach((path) => { - var _a, _b, _c, _d; for (let depth = 0; depth < path.length; depth++) { const currNode = path[depth]; // If that node has been visited before at the current depth @@ -49642,21 +50282,6 @@ class BCPlugin extends require$$0.Plugin { } else { index += `${indent.repeat(depth)}- ${makeWiki(wikilinkIndex, currNode)}`; - if (aliasesInIndex) { - const currFile = metadataCache.getFirstLinkpathDest(currNode, ""); - if (currFile !== null) { - const cache = metadataCache.getFileCache(currFile); - const alias = (_b = (_a = cache === null || cache === void 0 ? void 0 : cache.frontmatter) === null || _a === void 0 ? void 0 : _a.alias) !== null && _b !== void 0 ? _b : []; - const aliases = (_d = (_c = cache === null || cache === void 0 ? void 0 : cache.frontmatter) === null || _c === void 0 ? void 0 : _c.aliases) !== null && _d !== void 0 ? _d : []; - const allAliases = [ - ...[alias].flat(3), - ...[aliases].flat(3), - ]; - if (allAliases.length) { - index += ` (${allAliases.join(", ")})`; - } - } - } index += "\n"; if (!visited.hasOwnProperty(currNode)) visited[currNode] = []; @@ -49666,6 +50291,37 @@ class BCPlugin extends require$$0.Plugin { }); return index; } + /** + * Returns a copy of `index`, doesn't mutate. + * @param {string} index + */ + addAliasesToIndex(index) { + var _a, _b, _c, _d; + const { aliasesInIndex } = this.settings; + const copy = index.slice(); + const lines = copy.split("\n"); + for (let line of lines) { + if (aliasesInIndex) { + const note = line.split("- ")[1]; + if (!note) + continue; + const currFile = this.app.metadataCache.getFirstLinkpathDest(note, ""); + if (currFile !== null) { + const cache = this.app.metadataCache.getFileCache(currFile); + const alias = (_b = (_a = cache === null || cache === void 0 ? void 0 : cache.frontmatter) === null || _a === void 0 ? void 0 : _a.alias) !== null && _b !== void 0 ? _b : []; + const aliases = (_d = (_c = cache === null || cache === void 0 ? void 0 : cache.frontmatter) === null || _c === void 0 ? void 0 : _c.aliases) !== null && _d !== void 0 ? _d : []; + const allAliases = [ + ...[alias].flat(3), + ...[aliases].flat(3), + ]; + if (allAliases.length) { + line += ` (${allAliases.join(", ")})`; + } + } + } + } + return lines.join("\n"); + } // SECTION Breadcrumbs bfsAllPaths(g, startNode) { const pathsArr = []; diff --git a/src/DucksView.ts b/src/DucksView.ts index 4269983a..2db1e6c8 100644 --- a/src/DucksView.ts +++ b/src/DucksView.ts @@ -1,7 +1,7 @@ import { ItemView, WorkspaceLeaf } from "obsidian"; -import { STATS_VIEW } from "./constants"; -import type BCPlugin from "./main"; import Ducks from "./Components/Ducks.svelte"; +import { DUCK_VIEW } from "./constants"; +import type BCPlugin from "./main"; export default class DucksView extends ItemView { private plugin: BCPlugin; @@ -21,7 +21,7 @@ export default class DucksView extends ItemView { } getViewType() { - return STATS_VIEW; + return DUCK_VIEW; } getDisplayText() { return "Breadcrumbs Ducks";