Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions src/api/data-array.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Groupings, Values } from "data-model/value";
import { QuerySettings } from "settings";
import { Groupings, Values } from "../data-model/value";
import { QuerySettings } from "../settings";

/** A function which maps an array element to some value. */
export type ArrayFunc<T, O> = (elem: T, index: number, arr: T[]) => O;
Expand Down
2 changes: 1 addition & 1 deletion src/api/extensions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { STask } from "data-model/serialized/markdown";
import { STask } from "../data-model/serialized/markdown";

/** A general function for deciding how to check a task given it's current state. */
export type TaskStatusSelector = (task: STask) => Promise<string>;
Expand Down
22 changes: 11 additions & 11 deletions src/api/inline-api.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/** Fancy wrappers for the JavaScript API, used both by external plugins AND by the dataview javascript view. */

import { App, Component } from "obsidian";
import { FullIndex } from "data-index";
import { renderValue, renderErrorPre } from "ui/render";
import type { DataviewApi, DataviewIOApi, QueryApiSettings, QueryResult } from "api/plugin-api";
import { DataviewSettings, ExportSettings } from "settings";
import { DataObject, Grouping, Link, Literal, Values, Widgets } from "data-model/value";
import { BoundFunctionImpl, DEFAULT_FUNCTIONS, Functions } from "expression/functions";
import { Context } from "expression/context";
import { defaultLinkHandler } from "query/engine";
import { FullIndex } from "../data-index";
import { renderValue, renderErrorPre } from "../ui/render";
import type { DataviewApi, DataviewIOApi, QueryApiSettings, QueryResult } from "../api/plugin-api";
import { DataviewSettings, ExportSettings } from "../settings";
import { DataObject, Grouping, Link, Literal, Values, Widgets } from "../data-model/value";
import { BoundFunctionImpl, DEFAULT_FUNCTIONS, Functions } from "../expression/functions";
import { Context } from "../expression/context";
import { defaultLinkHandler } from "../query/engine";
import { DateTime, Duration } from "luxon";
import * as Luxon from "luxon";
import { DataArray } from "./data-array";
import { SListItem } from "data-model/serialized/markdown";
import { EXPRESSION } from "expression/parse";
import { Result } from "api/result";
import { SListItem } from "../data-model/serialized/markdown";
import { EXPRESSION } from "../expression/parse";
import { Result } from "../api/result";

/** Asynchronous API calls related to file / system IO. */
export class DataviewInlineIOApi {
Expand Down
44 changes: 22 additions & 22 deletions src/api/plugin-api.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/** The general, externally accessible plugin API (available at `app.plugins.plugins.dataview.api` or as global `DataviewAPI`). */

import { App, Component, MarkdownPostProcessorContext, TFile } from "obsidian";
import { FullIndex } from "data-index/index";
import { matchingSourcePaths } from "data-index/resolver";
import { Sources } from "data-index/source";
import { DataObject, Grouping, Groupings, Link, Literal, Values, Widgets } from "data-model/value";
import { EXPRESSION } from "expression/parse";
import { renderCodeBlock, renderErrorPre, renderValue } from "ui/render";
import { FullIndex } from "../data-index";
import { matchingSourcePaths } from "../data-index/resolver";
import { Sources } from "../data-index/source";
import { DataObject, Grouping, Groupings, Link, Literal, Values, Widgets } from "../data-model/value";
import { EXPRESSION } from "../expression/parse";
import { renderCodeBlock, renderErrorPre, renderValue } from "../ui/render";
import { DataArray } from "./data-array";
import { BoundFunctionImpl, DEFAULT_FUNCTIONS, Functions } from "expression/functions";
import { Context } from "expression/context";
import { BoundFunctionImpl, DEFAULT_FUNCTIONS, Functions } from "../expression/functions";
import { Context } from "../expression/context";
import {
defaultLinkHandler,
executeCalendar,
Expand All @@ -18,23 +18,23 @@ import {
executeTable,
executeTask,
IdentifierMeaning,
} from "query/engine";
} from "../query/engine";
import { DateTime, Duration } from "luxon";
import * as Luxon from "luxon";
import { compare, CompareOperator, satisfies } from "compare-versions";
import { DataviewSettings, ExportSettings } from "settings";
import { parseFrontmatter } from "data-import/markdown-file";
import { SListItem, SMarkdownPage } from "data-model/serialized/markdown";
import { createFixedTaskView, createTaskView, nestGroups } from "ui/views/task-view";
import { createFixedListView, createListView } from "ui/views/list-view";
import { createFixedTableView, createTableView } from "ui/views/table-view";
import { Result } from "api/result";
import { parseQuery } from "query/parse";
import { tryOrPropagate } from "util/normalize";
import { Query } from "query/query";
import { DataviewCalendarRenderer } from "ui/views/calendar-view";
import { DataviewJSRenderer } from "ui/views/js-view";
import { markdownList, markdownTable, markdownTaskList } from "ui/export/markdown";
import { DataviewSettings, ExportSettings } from "../settings";
import { parseFrontmatter } from "../data-import/markdown-file";
import { SListItem, SMarkdownPage } from "../data-model/serialized/markdown";
import { createFixedTaskView, createTaskView, nestGroups } from "../ui/views/task-view";
import { createFixedListView, createListView } from "../ui/views/list-view";
import { createFixedTableView, createTableView } from "../ui/views/table-view";
import { Result } from "./result";
import { parseQuery } from "../query/parse";
import { tryOrPropagate } from "../util/normalize";
import { Query } from "../query/query";
import { DataviewCalendarRenderer } from "../ui/views/calendar-view";
import { DataviewJSRenderer } from "../ui/views/js-view";
import { markdownList, markdownTable, markdownTaskList } from "../ui/export/markdown";

/** Asynchronous API calls related to file / system IO. */
export class DataviewIOApi {
Expand Down
2 changes: 1 addition & 1 deletion src/data-import/common.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** Common utilities for extracting tags, links, and other business from metadata. */

import { EXPRESSION } from "expression/parse";
import { EXPRESSION } from "../expression/parse";

const POTENTIAL_TAG_MATCHER = /#[^\s,;\.:!\?'"`()\[\]\{\}]+/giu;

Expand Down
6 changes: 3 additions & 3 deletions src/data-import/csv.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { canonicalizeVarName } from "util/normalize";
import { DataObject } from "data-model/value";
import { canonicalizeVarName } from "../util/normalize";
import { DataObject } from "../data-model/value";
import * as Papa from "papaparse";
import { parseFrontmatter } from "data-import/markdown-file";
import { parseFrontmatter } from "../data-import/markdown-file";

/** Parse a CSV file into a collection of data rows. */
export function parseCsv(content: string): DataObject[] {
Expand Down
4 changes: 2 additions & 2 deletions src/data-import/inline-field.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** Parse inline fields and other embedded metadata in a line. */

import { EXPRESSION } from "expression/parse";
import { Literal } from "data-model/value";
import { EXPRESSION } from "../expression/parse";
import { Literal } from "../data-model/value";
import * as P from "parsimmon";
import emojiRegex from "emoji-regex";

Expand Down
12 changes: 6 additions & 6 deletions src/data-import/markdown-file.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/** Importer for markdown documents. */

import { extractFullLineField, extractInlineFields, parseInlineValue, InlineField } from "data-import/inline-field";
import { ListItem, PageMetadata } from "data-model/markdown";
import { Literal, Link, Values } from "data-model/value";
import { EXPRESSION } from "expression/parse";
import { extractFullLineField, extractInlineFields, parseInlineValue, InlineField } from "../data-import/inline-field";
import { ListItem, PageMetadata } from "../data-model/markdown";
import { Literal, Link, Values } from "../data-model/value";
import { EXPRESSION } from "../expression/parse";
import { DateTime } from "luxon";
import { CachedMetadata, FileStats, FrontMatterCache, HeadingCache } from "obsidian";
import { canonicalizeVarName, extractDate, getFileTitle } from "util/normalize";
import * as common from "data-import/common";
import { canonicalizeVarName, extractDate, getFileTitle } from "../util/normalize";
import * as common from "../data-import/common";

/** Extract markdown metadata from the given Obsidian markdown file. */
export function parsePage(path: string, contents: string, stat: FileStats, metadata: CachedMetadata): PageMetadata {
Expand Down
4 changes: 2 additions & 2 deletions src/data-import/persister.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PageMetadata } from "data-model/markdown";
import { Transferable } from "data-model/transferable";
import { PageMetadata } from "../data-model/markdown";
import { Transferable } from "../data-model/transferable";
import localforage from "localforage";

/** A piece of data that has been cached for a specific version and time. */
Expand Down
4 changes: 2 additions & 2 deletions src/data-import/web-worker/import-entry.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** Entry-point script used by the index as a web worker. */
import { runImport } from "data-import/web-worker/import-impl";
import { Transferable } from "data-model/transferable";
import { runImport } from "../../data-import/web-worker/import-impl";
import { Transferable } from "../../data-model/transferable";
import { CachedMetadata, FileStats } from "obsidian";

/** An import which can fail and raise an exception, which will be caught by the handler. */
Expand Down
4 changes: 2 additions & 2 deletions src/data-import/web-worker/import-impl.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** Actual import implementation backend. This must remain separate from `import-entry` since it is used without web workers. */
import { parsePage } from "data-import/markdown-file";
import { PageMetadata } from "data-model/markdown";
import { parsePage } from "../../data-import/markdown-file";
import { PageMetadata } from "../../data-model/markdown";
import { CachedMetadata, FileStats } from "obsidian";

export function runImport(
Expand Down
2 changes: 1 addition & 1 deletion src/data-import/web-worker/import-manager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** Controls and creates Dataview file importers, allowing for asynchronous loading and parsing of files. */

import { Transferable } from "data-model/transferable";
import { Transferable } from "../../data-model/transferable";
import DataviewImportWorker from "web-worker:./import-entry.ts";
import { Component, MetadataCache, TFile, Vault } from "obsidian";

Expand Down
14 changes: 7 additions & 7 deletions src/data-index/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/** Stores various indices on all files in the vault to make dataview generation fast. */
import { Result } from "api/result";
import { parseCsv } from "data-import/csv";
import { LocalStorageCache } from "data-import/persister";
import { FileImporter } from "data-import/web-worker/import-manager";
import { PageMetadata } from "data-model/markdown";
import { DataObject } from "data-model/value";
import { Result } from "../api/result";
import { parseCsv } from "../data-import/csv";
import { LocalStorageCache } from "../data-import/persister";
import { FileImporter } from "../data-import/web-worker/import-manager";
import { PageMetadata } from "../data-model/markdown";
import { DataObject } from "../data-model/value";
import { DateTime } from "luxon";
import { App, Component, MetadataCache, TAbstractFile, TFile, TFolder, Vault } from "obsidian";
import { getParentFolder, setsEqual } from "util/normalize";
import { getParentFolder, setsEqual } from "../util/normalize";

/** Aggregate index which has several sub-indices and will initialize all of them. */
export class FullIndex extends Component {
Expand Down
4 changes: 2 additions & 2 deletions src/data-index/resolver.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** Collect data matching a source query. */

import { FullIndex, PathFilters } from "data-index/index";
import { Result } from "api/result";
import { FullIndex, PathFilters } from "../data-index/index";
import { Result } from "../api/result";
import { Source } from "./source";
import { DataObject, Link, Literal } from "../data-model/value";

Expand Down
10 changes: 5 additions & 5 deletions src/data-model/markdown.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { extractSubtags, getExtension, getFileTitle, getParentFolder, stripTime } from "util/normalize";
import { extractSubtags, getExtension, getFileTitle, getParentFolder, stripTime } from "../util/normalize";
import { DateTime } from "luxon";
import type { FullIndex } from "data-index/index";
import { Literal, Link, Values } from "data-model/value";
import { DataObject } from "index";
import { SListItem, SMarkdownPage } from "data-model/serialized/markdown";
import type { FullIndex } from "../data-index/index";
import { Literal, Link, Values } from "../data-model/value";
import { DataObject } from "../index";
import { SListItem, SMarkdownPage } from "../data-model/serialized/markdown";
import { Pos } from "obsidian";

/** All extracted markdown file metadata obtained from a file. */
Expand Down
2 changes: 1 addition & 1 deletion src/data-model/serialized/markdown.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** Serialized / API facing data types for Dataview objects. */

import { Link, Literal } from "data-model/value";
import { Link, Literal } from "../../data-model/value";
import { DateTime } from "luxon";
import { Pos } from "obsidian";

Expand Down
2 changes: 1 addition & 1 deletion src/data-model/transferable.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Link, Values } from "data-model/value";
import { Link, Values } from "../data-model/value";
import { DateTime, Duration, SystemZone } from "luxon";

/** Simplifies passing dataview values across the JS web worker barrier. */
Expand Down
4 changes: 2 additions & 2 deletions src/data-model/value.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DateTime, Duration } from "luxon";
import { DEFAULT_QUERY_SETTINGS, QuerySettings } from "settings";
import { getFileTitle, normalizeHeaderForLink, renderMinimalDuration } from "util/normalize";
import { DEFAULT_QUERY_SETTINGS, QuerySettings } from "../settings";
import { getFileTitle, normalizeHeaderForLink, renderMinimalDuration } from "../util/normalize";

/** Shorthand for a mapping from keys to values. */
export type DataObject = { [key: string]: Literal };
Expand Down
10 changes: 5 additions & 5 deletions src/expression/binaryop.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/** Provides a global dispatch table for evaluating binary operators, including comparison. */
import { LiteralRepr, LiteralType, Literal, Values } from "data-model/value";
import { normalizeDuration } from "util/normalize";
import { Result } from "api/result";
import { BinaryOp } from "expression/field";
import type { Context } from "expression/context";
import { LiteralRepr, LiteralType, Literal, Values } from "../data-model/value";
import { normalizeDuration } from "../util/normalize";
import { Result } from "../api/result";
import { BinaryOp } from "../expression/field";
import type { Context } from "../expression/context";

/** A literal type or a catch-all '*'. */
export type LiteralTypeOrAll = LiteralType | "*";
Expand Down
6 changes: 3 additions & 3 deletions src/expression/context.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/** Core implementation of the query language evaluation engine. */

import { DataObject, Literal, Values } from "data-model/value";
import { Result } from "api/result";
import { DataObject, Literal, Values } from "../data-model/value";
import { Result } from "../api/result";
import { BinaryOpHandler, createBinaryOps } from "./binaryop";
import { Field, Fields } from "./field";
import { DEFAULT_FUNCTIONS, FunctionImpl } from "./functions";
import { QuerySettings } from "settings";
import { QuerySettings } from "../settings";

/** Handles link resolution and normalization inside of a context. */
export interface LinkHandler {
Expand Down
2 changes: 1 addition & 1 deletion src/expression/field.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** Defines the AST for a field which can be evaluated. */
import { Literal } from "data-model/value";
import { Literal } from "../data-model/value";

/** Comparison operators which yield true/false. */
export type CompareOp = ">" | ">=" | "<=" | "<" | "=" | "!=";
Expand Down
10 changes: 5 additions & 5 deletions src/expression/functions.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/** Default function implementations for the expression evaluator. */

import { DateTime } from "luxon";
import { LiteralType, Link, Literal, Values, Widgets } from "data-model/value";
import { currentLocale } from "util/locale";
import { LiteralType, Link, Literal, Values, Widgets } from "../data-model/value";
import { currentLocale } from "../util/locale";
import { LiteralReprAll, LiteralTypeOrAll } from "./binaryop";
import { Context } from "./context";
import { Fields } from "./field";
import { EXPRESSION } from "./parse";
import { escapeRegex, normalizeMarkdown } from "util/normalize";
import { DataArray } from "api/data-array";
import { cyrb53 } from "util/hash";
import { escapeRegex, normalizeMarkdown } from "../util/normalize";
import { DataArray } from "../api/data-array";
import { cyrb53 } from "../util/hash";

/**
* A function implementation which takes in a function context and a variable number of arguments. Throws an error if an
Expand Down
8 changes: 4 additions & 4 deletions src/expression/parse.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { DateTime, Duration } from "luxon";
import { Literal, Link } from "data-model/value";
import { Literal, Link } from "../data-model/value";
import * as P from "parsimmon";
import { BinaryOp, Field, Fields, LambdaField, ListField, LiteralField, ObjectField, VariableField } from "./field";
import { FolderSource, NegatedSource, Source, SourceOp, Sources, TagSource, CsvSource } from "data-index/source";
import { normalizeDuration } from "util/normalize";
import { Result } from "api/result";
import { FolderSource, NegatedSource, Source, SourceOp, Sources, TagSource, CsvSource } from "../data-index/source";
import { normalizeDuration } from "../util/normalize";
import { Result } from "../api/result";
import emojiRegex from "emoji-regex";

/** Emoji regex without any additional flags. */
Expand Down
27 changes: 14 additions & 13 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Basic API type.
export type { DataviewApi } from "api/plugin-api";
export type { DataviewInlineApi, DataviewInlineIOApi } from "api/inline-api";
export type { DataviewApi } from "./api/plugin-api";
export type { DataviewInlineApi, DataviewInlineIOApi } from "./api/inline-api";

// Core Dataview types.
export type { DateTime, Duration } from "luxon";
export type {
export {
Link,
DataObject,
LiteralType,
Expand All @@ -13,17 +13,18 @@ export type {
WrappedLiteral,
LiteralWrapper,
Widget,
} from "data-model/value";
Values
} from "./data-model/value";

export type { Result, Success, Failure } from "api/result";
export type { DataArray } from "api/data-array";
export type { Result, Success, Failure } from "./api/result";
export type { DataArray } from "./api/data-array";

// Dataview Index.
export type { ListItem, PageMetadata } from "data-model/markdown";
export type { FullIndex, PrefixIndex, IndexMap } from "data-index/index";
export type { ListItem, PageMetadata } from "./data-model/markdown";
export type { FullIndex, PrefixIndex, IndexMap } from "./data-index/index";

// Serialized types which describe all outputs of serialization.
export type { SMarkdownPage, SListEntry, STask } from "data-model/serialized/markdown";
export type { SMarkdownPage, SListEntry, STask } from "./data-model/serialized/markdown";

// Useful utilities for directly using dataview parsers.
export {
Expand All @@ -33,15 +34,15 @@ export {
ExpressionLanguage,
EXPRESSION,
parseField,
} from "expression/parse";
export { QUERY_LANGUAGE } from "query/parse";
export { Query } from "query/query";
} from "./expression/parse";
export { QUERY_LANGUAGE } from "./query/parse";
export { Query } from "./query/query";

////////////////////
// Implementation //
////////////////////

import type { DataviewApi } from "api/plugin-api";
import type { DataviewApi } from "./api/plugin-api";

import "obsidian";
import type { App } from "obsidian";
Expand Down
Loading