Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

this code very faster #539

Draft
wants to merge 55 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
8b312ac
rusty breadcrumbs
mProjectsCode Apr 26, 2024
8d01fe0
working graph building; mermaid
mProjectsCode Apr 27, 2024
f822607
minor changes
mProjectsCode Apr 27, 2024
de02fb4
progress on tree view
mProjectsCode Apr 28, 2024
563bde6
edge sorting
mProjectsCode Apr 29, 2024
f18ee4f
fix list index
mProjectsCode Apr 29, 2024
583ff36
fix edge link class
mProjectsCode Apr 29, 2024
e12f0e1
Builders accumulate GraphConstructionData immediately, instead of int…
SkepticMystic Apr 29, 2024
f77c813
Merge branch 'master' into mProjectsCode/master
SkepticMystic Apr 29, 2024
4002de3
Merge pull request #1 from SkepticMystic/mProjectsCode/master
mProjectsCode Apr 29, 2024
6eb258e
first half of mermaid options
mProjectsCode Apr 29, 2024
c127789
Merge branch 'master' of https://github.com/mProjectsCode/breadcrumbs
mProjectsCode Apr 29, 2024
2233557
mermaid code block collapse edge option
mProjectsCode Apr 29, 2024
ad0aca8
split up rust code
mProjectsCode May 1, 2024
dac9130
traversal options
mProjectsCode May 1, 2024
e67b4ba
fix more views
mProjectsCode May 1, 2024
fcd533b
it kind of works
mProjectsCode May 2, 2024
dd6029a
fix traversal bug with trail view
mProjectsCode May 2, 2024
7d62722
fix more trail view things
mProjectsCode May 2, 2024
c47575f
fix more bugs
mProjectsCode May 2, 2024
f895f71
rust performance improvements due to vector based set
mProjectsCode May 2, 2024
062194d
fix lot's of clippy lint issues
mProjectsCode May 2, 2024
5ba7883
fixes; rust sorting; settings rule previews
mProjectsCode May 3, 2024
ea2e5f5
better sorting
mProjectsCode May 4, 2024
8452bf8
fix(command:threading): Reimplement
SkepticMystic May 7, 2024
6e764b1
Merge pull request #2 from mProjectsCode/mProjectsCode/master
SkepticMystic May 7, 2024
8a89247
fix(builders): Swap source and target when creating GraphConstruction…
SkepticMystic May 7, 2024
0262bcd
fix(builders): Rather push an error than show a notice if Dataview is…
SkepticMystic May 7, 2024
8dfd92c
test: Delete irrelevant TS tests
SkepticMystic May 7, 2024
7fbfb31
fix: Edge sort field is neighbour-field, not neighbour
SkepticMystic May 7, 2024
aa91e86
Reimplement trim_lone_param in get_attribute_label
SkepticMystic May 7, 2024
bbe3913
Merge pull request #3 from mProjectsCode/mProjectsCode/master
SkepticMystic May 7, 2024
ea00553
Merge branch 'master' into master
SkepticMystic May 7, 2024
a7f662f
Remove some old TODOs + Add (RUST) label to existing ones
SkepticMystic May 7, 2024
5568e84
fix: Resolve merge-conflict conflicts
SkepticMystic May 7, 2024
2f2179f
wasm logging; rust script in package json
mProjectsCode May 7, 2024
1e9ce56
Merge branch 'master' of https://github.com/mProjectsCode/breadcrumbs
mProjectsCode May 7, 2024
0596d96
adress some todos
mProjectsCode May 7, 2024
523793b
more minor fixes
mProjectsCode May 7, 2024
73eb309
refactor: TraversalOptions.fields being undefined is the same as allo…
SkepticMystic May 8, 2024
b1dc8bc
fix review comments
mProjectsCode May 8, 2024
33199aa
feat: Implement basic flatten rec_traversal_data func + switch to bre…
SkepticMystic May 9, 2024
b2b8526
Merge branch 'master' of https://github.com/mProjectsCode/breadcrumbs
SkepticMystic May 9, 2024
62678a7
Reimplement `flat` option on CodeblockTree
SkepticMystic May 9, 2024
25e118b
make clippy happy; work on todos
mProjectsCode May 10, 2024
134eda2
mermaid edge sorting
mProjectsCode May 10, 2024
8f3ec65
Update src/components/side_views/MatrixEdgeField.svelte
mProjectsCode May 13, 2024
1909ecb
Update wasm/src/graph_mermaid.rs
mProjectsCode May 13, 2024
52f6b2f
performance improvements to views
mProjectsCode May 15, 2024
aecbf93
some small improvements
mProjectsCode May 25, 2024
d668311
do node stringification in rust
mProjectsCode May 27, 2024
1932175
fix error, add debounce
mProjectsCode May 27, 2024
6ba43c5
update graph on vault events and code cleanup
mProjectsCode Dec 15, 2024
bcdcd55
change update flow
mProjectsCode Dec 20, 2024
62c2653
more cleanup; improve EdgeStruct perf
mProjectsCode Dec 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/graph/builders/explicit/dataview_note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
import { log } from "src/logger";
import type BreadcrumbsPlugin from "src/main";
import { fail, graph_build_fail, succ } from "src/utils/result";
import { GraphConstructionEdgeData } from "wasm/pkg/breadcrumbs_graph_wasm";

const get_dataview_note_info = (
plugin: BreadcrumbsPlugin,
Expand Down Expand Up @@ -58,7 +59,7 @@ export const _add_explicit_edges_dataview_note: ExplicitEdgeBuilder = (
plugin,
all_files,
) => {
const results: EdgeBuilderResults = { nodes: [], edges: [], errors: [] }
const results: EdgeBuilderResults = { nodes: [], edges: [], errors: [] };

all_files.obsidian?.forEach(
({ file: dataview_note_file, cache: dataview_note_cache }) => {
Expand Down Expand Up @@ -90,7 +91,8 @@ export const _add_explicit_edges_dataview_note: ExplicitEdgeBuilder = (
dataview_note_path,
);
if (!dataview_note_info.ok) {
if (dataview_note_info.error) results.errors.push(dataview_note_info.error);
if (dataview_note_info.error)
results.errors.push(dataview_note_info.error);
return;
}
const { field, query } = dataview_note_info.data;
Expand All @@ -114,18 +116,16 @@ export const _add_explicit_edges_dataview_note: ExplicitEdgeBuilder = (

pages.forEach((page) => {
// NOTE: I _believe_ we don't need to even safe_add_node, since dv will only return resolved notes
results.edges.push({
source_id: dataview_note_page.file.path,
target_id: page.file.path,
attr: {
results.edges.push(
new GraphConstructionEdgeData(
dataview_note_page.file.path,
page.file.path,
field,
explicit: true,
source: "dataview_note",
},
}
"dataview_note",
),
);
});
});

return results
return results;
};
42 changes: 27 additions & 15 deletions src/graph/builders/explicit/date_note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,23 @@ import type {
ExplicitEdgeBuilder,
} from "src/interfaces/graph";
import { Paths } from "src/utils/paths";
import {
GraphConstructionEdgeData,
GraphConstructionNodeData,
} from "wasm/pkg/breadcrumbs_graph_wasm";

// TODO: Option to point up to month, (and for month to point up to year?)

export const _add_explicit_edges_date_note: ExplicitEdgeBuilder = (
plugin,
all_files,
) => {
const results: EdgeBuilderResults = { nodes: [], edges: [], errors: [] }
const results: EdgeBuilderResults = { nodes: [], edges: [], errors: [] };

const date_note_settings = plugin.settings.explicit_edge_sources.date_note;
if (!date_note_settings.enabled) { return results }
else if (
if (!date_note_settings.enabled) {
return results;
} else if (
!plugin.settings.edge_fields.find(
(field) => field.label === date_note_settings.default_field,
)
Expand All @@ -26,7 +31,7 @@ export const _add_explicit_edges_date_note: ExplicitEdgeBuilder = (
message: `The default Date Note field "${date_note_settings.default_field}" is not a valid Breadcrumbs Edge field`,
});

return results
return results;
}

const date_notes: {
Expand Down Expand Up @@ -94,19 +99,26 @@ export const _add_explicit_edges_date_note: ExplicitEdgeBuilder = (
// NOTE: We have a full path, so we can go straight to the file without the given source_path
const target_file = plugin.app.vault.getFileByPath(target_id);
if (!target_file) {
results.nodes.push({ id: target_id, attr: { resolved: false } });
results.nodes.push(
new GraphConstructionNodeData(
target_id,
[],
false,
false,
false,
),
);
}

results.edges.push({
target_id,
source_id: date_note.path,
attr: {
explicit: true,
source: "date_note",
field: date_note_settings.default_field,
}
});
results.edges.push(
new GraphConstructionEdgeData(
target_id,
date_note.path,
date_note_settings.default_field,
"date_note",
),
);
});

return results
return results;
};
30 changes: 17 additions & 13 deletions src/graph/builders/explicit/dendron_note.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { META_ALIAS } from "src/const/metadata_fields";
// import type { BCGraph } from "src/graph/MyMultiGraph";
import type {
BreadcrumbsError,
EdgeBuilderResults,
ExplicitEdgeBuilder,
} from "src/interfaces/graph";
import type BreadcrumbsPlugin from "src/main";
import { Paths } from "src/utils/paths";
import { fail, graph_build_fail, succ } from "src/utils/result";
import {
GraphConstructionEdgeData,
GraphConstructionNodeData,
} from "wasm/pkg/breadcrumbs_graph_wasm";

const get_dendron_note_info = (
plugin: BreadcrumbsPlugin,
Expand Down Expand Up @@ -86,7 +89,9 @@ const handle_dendron_note = (
const target_file = plugin.app.vault.getFileByPath(target_id);

if (!target_file) {
results.nodes.push({ id: target_id, attr: { resolved: false } });
results.nodes.push(
new GraphConstructionNodeData(target_id, [], false, false, false),
);

// If !target_file, we can recursively call handle_dendron_note
// To add the unresolved edges along the way
Expand All @@ -102,25 +107,24 @@ const handle_dendron_note = (
);
}

results.edges.push({
source_id,
target_id,
attr: {
results.edges.push(
new GraphConstructionEdgeData(
source_id,
target_id,
field,
explicit: true,
source: "dendron_note",
}
});
"dendron_note",
),
);
};

export const _add_explicit_edges_dendron_note: ExplicitEdgeBuilder = (
plugin,
all_files,
) => {
const results: EdgeBuilderResults = { nodes: [], edges: [], errors: [] }
const results: EdgeBuilderResults = { nodes: [], edges: [], errors: [] };

if (!plugin.settings.explicit_edge_sources.dendron_note.enabled) {
return results
return results;
}

all_files.obsidian?.forEach(({ file, cache }) => {
Expand All @@ -131,5 +135,5 @@ export const _add_explicit_edges_dendron_note: ExplicitEdgeBuilder = (
handle_dendron_note(plugin, results, page.file.path, page);
});

return results
return results;
};
28 changes: 15 additions & 13 deletions src/graph/builders/explicit/folder_note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type {
import type { Result } from "src/interfaces/result";
import type BreadcrumbsPlugin from "src/main";
import { fail, graph_build_fail, succ } from "src/utils/result";
import { GraphConstructionEdgeData } from "wasm/pkg/breadcrumbs_graph_wasm";

type FolderNoteData = {
field: string;
Expand Down Expand Up @@ -75,7 +76,7 @@ export const _add_explicit_edges_folder_note: ExplicitEdgeBuilder = async (
plugin,
all_files,
) => {
const results: EdgeBuilderResults = { nodes: [], edges: [], errors: [] }
const results: EdgeBuilderResults = { nodes: [], edges: [], errors: [] };

const folder_notes: {
file: { path: string; folder: string };
Expand All @@ -92,7 +93,8 @@ export const _add_explicit_edges_folder_note: ExplicitEdgeBuilder = async (
folder_note_file.path,
);
if (!folder_note_info.ok) {
if (folder_note_info.error) results.errors.push(folder_note_info.error);
if (folder_note_info.error)
results.errors.push(folder_note_info.error);
return;
}

Expand All @@ -113,7 +115,8 @@ export const _add_explicit_edges_folder_note: ExplicitEdgeBuilder = async (
folder_note_page.file.path,
);
if (!folder_note_info.ok) {
if (folder_note_info.error) results.errors.push(folder_note_info.error);
if (folder_note_info.error)
results.errors.push(folder_note_info.error);
return;
}

Expand All @@ -140,20 +143,19 @@ export const _add_explicit_edges_folder_note: ExplicitEdgeBuilder = async (
}

// We know path is resolved
results.edges.push({
target_id: target_path,
source_id: folder_note.path,
attr: {
explicit: true,
field: data.field,
source: "folder_note",
},
});
results.edges.push(
new GraphConstructionEdgeData(
target_path,
folder_note.path,
data.field,
"folder_note",
),
);
},
data.recurse,
),
),
);

return results
return results;
};
42 changes: 24 additions & 18 deletions src/graph/builders/explicit/johnny_decimal_note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import type BreadcrumbsPlugin from "src/main";
import { Paths } from "src/utils/paths";
import { fail, graph_build_fail, succ } from "src/utils/result";
import { ensure_not_ends_with } from "src/utils/strings";
import {
GraphConstructionEdgeData,
GraphConstructionNodeData,
} from "wasm/pkg/breadcrumbs_graph_wasm";

const get_johnny_decimal_note_info = (
plugin: BreadcrumbsPlugin,
Expand Down Expand Up @@ -85,20 +89,27 @@ const handle_johnny_decimal_note = (

// NOTE: I don't think this can ever happen... if target_note, then target_file must exist
if (!target_file) {
results.nodes.push({ id: target_note.path, attr: { resolved: false } });
results.nodes.push(
new GraphConstructionNodeData(
target_note.path,
[],
false,
false,
false,
),
);
}

const { field } = johnny_decimal_note_info.data;

results.edges.push({
source_id: source_note.path,
target_id: target_note.path,
attr: {
results.edges.push(
new GraphConstructionEdgeData(
source_note.path,
target_note.path,
field,
explicit: true,
source: "johnny_decimal_note",
}
});
"johnny_decimal_note",
),
);
};

type JohnnyDecimalNote = {
Expand All @@ -112,10 +123,10 @@ export const _add_explicit_edges_johnny_decimal_note: ExplicitEdgeBuilder = (
plugin,
all_files,
) => {
const results: EdgeBuilderResults = { nodes: [], edges: [], errors: [] }
const results: EdgeBuilderResults = { nodes: [], edges: [], errors: [] };

if (!plugin.settings.explicit_edge_sources.johnny_decimal_note.enabled) {
return results
return results;
}

const { delimiter } =
Expand Down Expand Up @@ -156,13 +167,8 @@ export const _add_explicit_edges_johnny_decimal_note: ExplicitEdgeBuilder = (
});

johnny_decimal_notes.forEach((note) => {
handle_johnny_decimal_note(
plugin,
results,
note,
johnny_decimal_notes,
);
handle_johnny_decimal_note(plugin, results, note, johnny_decimal_notes);
});

return results
return results;
};
Loading