@riebeckite/plugin-bases 0.0.26 → 0.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +146 -162
- package/README_ja.md +137 -135
- package/dist/index.d.ts +5 -2
- package/dist/index.js +1588 -170
- package/dist/src/dependencies.d.ts +3 -0
- package/dist/src/evaluate.d.ts +5 -1
- package/dist/src/expression.d.ts +9 -0
- package/dist/src/page.d.ts +17 -0
- package/dist/src/runtime.d.ts +4 -1
- package/dist/src/transform.d.ts +10 -0
- package/dist/src/types.d.ts +55 -4
- package/dist/src/yaml.d.ts +7 -0
- package/package.json +2 -2
- package/style.css +94 -5
package/dist/src/evaluate.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { ContentManifestEntry } from "@riebeckite/core";
|
|
2
|
-
import type { BasesCondition, BasesValueRef } from "./types.js";
|
|
2
|
+
import type { BasesCondition, BasesExpression, BasesValueRef } from "./types.js";
|
|
3
|
+
export declare class BasesEvaluationError extends Error {
|
|
4
|
+
constructor(message: string);
|
|
5
|
+
}
|
|
3
6
|
/** Evaluates a compiled condition against one manifest entry. */
|
|
4
7
|
export declare function matchesCondition(condition: BasesCondition, entry: ContentManifestEntry): boolean;
|
|
8
|
+
export declare function evaluateBasesExpression(expression: BasesExpression, entry: ContentManifestEntry, formulas?: Readonly<Record<string, BasesExpression>>, scope?: Readonly<Record<string, unknown>>, active?: ReadonlySet<string>): unknown;
|
|
5
9
|
/** Reads the entry value a filter reference points at. */
|
|
6
10
|
export declare function resolveValueRef(reference: BasesValueRef, entry: ContentManifestEntry): unknown;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BasesExpression } from "./types.js";
|
|
2
|
+
export type ExpressionResult = {
|
|
3
|
+
readonly ok: true;
|
|
4
|
+
readonly value: BasesExpression;
|
|
5
|
+
} | {
|
|
6
|
+
readonly ok: false;
|
|
7
|
+
readonly message: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function parseBasesExpression(source: string): ExpressionResult;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ContentManifest, type ContentSource, type Diagnostic, type PluginPage } from "@riebeckite/core";
|
|
2
|
+
import type { BasesOptions } from "./types.js";
|
|
3
|
+
export type BaseDocument = {
|
|
4
|
+
readonly pathname: string;
|
|
5
|
+
readonly dependencies: readonly import("@riebeckite/core").OutputDependency[];
|
|
6
|
+
};
|
|
7
|
+
export declare function listBaseDocuments(input: {
|
|
8
|
+
readonly manifest: ContentManifest;
|
|
9
|
+
readonly contentSource?: ContentSource;
|
|
10
|
+
readonly diagnostics: Diagnostic[];
|
|
11
|
+
}): Promise<readonly BaseDocument[]>;
|
|
12
|
+
export declare function resolveBaseDocument(input: {
|
|
13
|
+
readonly manifest: ContentManifest;
|
|
14
|
+
readonly contentSource?: ContentSource;
|
|
15
|
+
readonly pathname: string;
|
|
16
|
+
readonly diagnostics: Diagnostic[];
|
|
17
|
+
}, options: BasesOptions): Promise<PluginPage | null>;
|
package/dist/src/runtime.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import type { ContentManifest, Diagnostic, ResolvedRiebeckiteConfig } from "@riebeckite/core";
|
|
1
|
+
import type { ContentManifest, Diagnostic, OutputDependency, ResolvedRiebeckiteConfig } from "@riebeckite/core";
|
|
2
2
|
import type { BasesOptions } from "./types.js";
|
|
3
3
|
export type BasesRuntime = {
|
|
4
4
|
/** Replaces every Base placeholder in the manifest with rendered output. */
|
|
5
5
|
resolve(manifest: ContentManifest, diagnostics: Diagnostic[], config?: ResolvedRiebeckiteConfig): void;
|
|
6
|
+
dependenciesFor(slug: string): readonly OutputDependency[];
|
|
7
|
+
dependenciesForPage(pathname: string): readonly OutputDependency[];
|
|
8
|
+
setDocumentDependencies(dependencies: ReadonlyMap<string, readonly OutputDependency[]>): void;
|
|
6
9
|
};
|
|
7
10
|
export declare function createBasesRuntime(options: BasesOptions): BasesRuntime;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ContentManifestEntry } from "@riebeckite/core";
|
|
2
|
+
import type { BasesGroupKey, BasesSpec, BasesView } from "./types.js";
|
|
3
|
+
export type BasesGroup = {
|
|
4
|
+
readonly key: BasesGroupKey;
|
|
5
|
+
readonly entries: readonly ContentManifestEntry[];
|
|
6
|
+
};
|
|
7
|
+
export declare function resolveBasesProperty(entry: ContentManifestEntry, property: string, spec: BasesSpec): unknown;
|
|
8
|
+
export declare function sortBasesEntries(entries: readonly ContentManifestEntry[], view: BasesView, spec: BasesSpec): ContentManifestEntry[];
|
|
9
|
+
export declare function groupBasesEntries(entries: readonly ContentManifestEntry[], view: BasesView, spec: BasesSpec): readonly BasesGroup[];
|
|
10
|
+
export declare function summarizeBasesValues(values: readonly unknown[], name: string, spec: BasesSpec): unknown;
|
package/dist/src/types.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { ContentQuerySort } from "@riebeckite/core";
|
|
2
1
|
/** View kinds supported by the MVP renderer. */
|
|
3
2
|
export type BasesViewType = "table" | "cards";
|
|
4
3
|
/** Scalar literal that can appear on the right-hand side of a comparison. */
|
|
@@ -6,7 +5,47 @@ export type BasesLiteral = string | number | boolean | null;
|
|
|
6
5
|
/** Comparison operators supported in filter expressions. */
|
|
7
6
|
export type BasesOperator = "==" | "!=" | ">" | "<" | ">=" | "<=" | "contains";
|
|
8
7
|
/** Built-in `file.*` values exposed to filter expressions. */
|
|
9
|
-
export type BasesBuiltinValue = "file.name" | "file.path" | "file.slug" | "file.folder" | "file.title" | "file.link" | "file.permalink" | "file.tags";
|
|
8
|
+
export type BasesBuiltinValue = "file.name" | "file.path" | "file.slug" | "file.folder" | "file.title" | "file.link" | "file.permalink" | "file.tags" | "file.ext" | "file.size" | "file.mtime" | "file.ctime";
|
|
9
|
+
export type BasesExpression = {
|
|
10
|
+
readonly kind: "literal";
|
|
11
|
+
readonly value: BasesLiteral;
|
|
12
|
+
} | {
|
|
13
|
+
readonly kind: "reference";
|
|
14
|
+
readonly path: readonly string[];
|
|
15
|
+
} | {
|
|
16
|
+
readonly kind: "array";
|
|
17
|
+
readonly values: readonly BasesExpression[];
|
|
18
|
+
} | {
|
|
19
|
+
readonly kind: "unary";
|
|
20
|
+
readonly operator: "!" | "-";
|
|
21
|
+
readonly value: BasesExpression;
|
|
22
|
+
} | {
|
|
23
|
+
readonly kind: "binary";
|
|
24
|
+
readonly operator: "+" | "-" | "*" | "/" | "%" | "==" | "!=" | ">" | "<" | ">=" | "<=" | "&&" | "||";
|
|
25
|
+
readonly left: BasesExpression;
|
|
26
|
+
readonly right: BasesExpression;
|
|
27
|
+
} | {
|
|
28
|
+
readonly kind: "call";
|
|
29
|
+
readonly callee: BasesExpression;
|
|
30
|
+
readonly arguments: readonly BasesExpression[];
|
|
31
|
+
} | {
|
|
32
|
+
readonly kind: "member";
|
|
33
|
+
readonly object: BasesExpression;
|
|
34
|
+
readonly property: string;
|
|
35
|
+
} | {
|
|
36
|
+
readonly kind: "index";
|
|
37
|
+
readonly object: BasesExpression;
|
|
38
|
+
readonly index: BasesExpression;
|
|
39
|
+
};
|
|
40
|
+
export type BasesSort = {
|
|
41
|
+
readonly property: string;
|
|
42
|
+
readonly direction: "asc" | "desc";
|
|
43
|
+
};
|
|
44
|
+
export type BasesGroupBy = {
|
|
45
|
+
readonly property: string;
|
|
46
|
+
readonly direction: "asc" | "desc";
|
|
47
|
+
};
|
|
48
|
+
export type BasesGroupKey = string | number | boolean | Date | null;
|
|
10
49
|
/** A value read either from a built-in or from frontmatter. */
|
|
11
50
|
export type BasesValueRef = {
|
|
12
51
|
readonly source: "builtin";
|
|
@@ -42,6 +81,9 @@ export type BasesCondition = {
|
|
|
42
81
|
readonly left: BasesValueRef;
|
|
43
82
|
readonly operator: BasesOperator;
|
|
44
83
|
readonly right: BasesLiteral;
|
|
84
|
+
} | {
|
|
85
|
+
readonly kind: "expression";
|
|
86
|
+
readonly expression: BasesExpression;
|
|
45
87
|
};
|
|
46
88
|
/** A compiled Base view. */
|
|
47
89
|
export type BasesView = {
|
|
@@ -52,8 +94,14 @@ export type BasesView = {
|
|
|
52
94
|
readonly columns: readonly string[];
|
|
53
95
|
/** View-local filter, combined with the top-level filter using AND. */
|
|
54
96
|
readonly filter?: BasesCondition;
|
|
55
|
-
/** Sort keys,
|
|
56
|
-
readonly sort?: readonly
|
|
97
|
+
/** Sort keys, including formula properties. */
|
|
98
|
+
readonly sort?: readonly BasesSort[];
|
|
99
|
+
/** The single property used by Obsidian Bases to form row groups. */
|
|
100
|
+
readonly groupBy?: BasesGroupBy;
|
|
101
|
+
/** Manual group visibility and order, when configured by Obsidian. */
|
|
102
|
+
readonly groupOrder?: readonly BasesGroupKey[];
|
|
103
|
+
/** Property id -> named top-level summary formula. */
|
|
104
|
+
readonly summaries?: Readonly<Record<string, string>>;
|
|
57
105
|
/** View-local row cap. Still bounded by {@link BasesOptions.limit}. */
|
|
58
106
|
readonly limit?: number;
|
|
59
107
|
};
|
|
@@ -63,6 +111,9 @@ export type BasesSpec = {
|
|
|
63
111
|
readonly filter?: BasesCondition;
|
|
64
112
|
/** Property id -> display label. */
|
|
65
113
|
readonly properties: Readonly<Record<string, string>>;
|
|
114
|
+
readonly formulas: Readonly<Record<string, BasesExpression>>;
|
|
115
|
+
/** Named summary expressions, evaluated with `values` in scope. */
|
|
116
|
+
readonly summaries: Readonly<Record<string, BasesExpression>>;
|
|
66
117
|
readonly views: readonly BasesView[];
|
|
67
118
|
};
|
|
68
119
|
export type BasesOptions = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riebeckite/plugin-bases",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.28",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"@types/mdast": "^4.0.4",
|
|
19
19
|
"unist-util-visit": "^5.1.0",
|
|
20
20
|
"vfile-matter": "^5.0.1",
|
|
21
|
-
"@riebeckite/core": "0.0.
|
|
21
|
+
"@riebeckite/core": "0.0.28"
|
|
22
22
|
},
|
|
23
23
|
"publishConfig": {
|
|
24
24
|
"access": "public"
|
package/style.css
CHANGED
|
@@ -17,26 +17,58 @@
|
|
|
17
17
|
color: var(--rb-bases-ink);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
.rb-
|
|
20
|
+
.rb-bases-page {
|
|
21
|
+
margin: 0 auto;
|
|
22
|
+
max-width: 72rem;
|
|
23
|
+
padding: 1.5rem;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.rb-bases-page__title {
|
|
27
|
+
margin: 0;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.rb-bases-page__title + .rb-bases {
|
|
21
31
|
margin-top: 1.5rem;
|
|
22
32
|
}
|
|
23
33
|
|
|
34
|
+
.rb-bases__view + .rb-bases__view {
|
|
35
|
+
margin-top: 2rem;
|
|
36
|
+
}
|
|
37
|
+
|
|
24
38
|
.rb-bases__view-name {
|
|
25
|
-
margin: 0
|
|
26
|
-
font-size:
|
|
39
|
+
margin: 0;
|
|
40
|
+
font-size: 1rem;
|
|
27
41
|
font-weight: 700;
|
|
28
|
-
letter-spacing: 0
|
|
42
|
+
letter-spacing: 0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.rb-bases__count {
|
|
46
|
+
margin: 0.25rem 0 0.75rem;
|
|
47
|
+
color: var(--rb-bases-muted);
|
|
48
|
+
font-size: 0.8125rem;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.rb-bases__table-scroll {
|
|
52
|
+
overflow-x: auto;
|
|
53
|
+
border: 1px solid var(--rb-bases-rule);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.rb-bases__table-scroll:focus-visible {
|
|
57
|
+
outline: 2px solid var(--rb-bases-accent);
|
|
58
|
+
outline-offset: 2px;
|
|
29
59
|
}
|
|
30
60
|
|
|
31
61
|
.rb-bases__table {
|
|
32
62
|
width: 100%;
|
|
63
|
+
min-width: 36rem;
|
|
33
64
|
border-collapse: collapse;
|
|
34
65
|
font-size: 0.9375rem;
|
|
35
66
|
}
|
|
36
67
|
|
|
37
68
|
.rb-bases__heading {
|
|
38
69
|
padding: 0.5rem 0.75rem;
|
|
39
|
-
border-bottom: 1px solid var(--rb-bases-
|
|
70
|
+
border-bottom: 1px solid var(--rb-bases-rule);
|
|
71
|
+
background: var(--rb-bases-surface);
|
|
40
72
|
text-align: left;
|
|
41
73
|
font-weight: 700;
|
|
42
74
|
}
|
|
@@ -44,12 +76,39 @@
|
|
|
44
76
|
.rb-bases__cell {
|
|
45
77
|
padding: 0.5rem 0.75rem;
|
|
46
78
|
vertical-align: top;
|
|
79
|
+
overflow-wrap: anywhere;
|
|
47
80
|
}
|
|
48
81
|
|
|
49
82
|
.rb-bases__row:not(:last-child) .rb-bases__cell {
|
|
50
83
|
border-bottom: 1px solid var(--rb-bases-rule);
|
|
51
84
|
}
|
|
52
85
|
|
|
86
|
+
.rb-bases__group th,
|
|
87
|
+
.rb-bases__summary {
|
|
88
|
+
padding: 0.45rem 0.75rem;
|
|
89
|
+
border-top: 1px solid var(--rb-bases-rule);
|
|
90
|
+
color: var(--rb-bases-muted);
|
|
91
|
+
text-align: left;
|
|
92
|
+
font-size: 0.8125rem;
|
|
93
|
+
font-weight: 600;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.rb-bases__group-count {
|
|
97
|
+
color: var(--rb-bases-muted);
|
|
98
|
+
font-weight: 400;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.rb-bases__empty-row td {
|
|
102
|
+
padding: 0.625rem 0.75rem;
|
|
103
|
+
color: var(--rb-bases-muted);
|
|
104
|
+
font-size: 0.875rem;
|
|
105
|
+
font-style: italic;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.rb-bases__summary-row--overall .rb-bases__summary {
|
|
109
|
+
border-top: 1px solid var(--rb-bases-ink);
|
|
110
|
+
}
|
|
111
|
+
|
|
53
112
|
.rb-bases__link {
|
|
54
113
|
color: inherit;
|
|
55
114
|
text-decoration: underline;
|
|
@@ -78,12 +137,30 @@
|
|
|
78
137
|
list-style: none;
|
|
79
138
|
}
|
|
80
139
|
|
|
140
|
+
.rb-bases__card-group + .rb-bases__card-group {
|
|
141
|
+
margin-top: 1rem;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.rb-bases__group-title {
|
|
145
|
+
margin: 0 0 0.5rem;
|
|
146
|
+
font-size: 0.9375rem;
|
|
147
|
+
}
|
|
148
|
+
|
|
81
149
|
.rb-bases__card {
|
|
82
150
|
padding: 0.75rem 1rem;
|
|
83
151
|
border: 1px solid var(--rb-bases-rule);
|
|
84
152
|
background: var(--rb-bases-surface);
|
|
85
153
|
}
|
|
86
154
|
|
|
155
|
+
.rb-bases__card-empty {
|
|
156
|
+
grid-column: 1 / -1;
|
|
157
|
+
padding: 0.75rem 1rem;
|
|
158
|
+
border: 1px dashed var(--rb-bases-rule);
|
|
159
|
+
color: var(--rb-bases-muted);
|
|
160
|
+
font-size: 0.875rem;
|
|
161
|
+
font-style: italic;
|
|
162
|
+
}
|
|
163
|
+
|
|
87
164
|
.rb-bases__card-title {
|
|
88
165
|
font-weight: 700;
|
|
89
166
|
}
|
|
@@ -107,6 +184,7 @@
|
|
|
107
184
|
|
|
108
185
|
.rb-bases__field-value {
|
|
109
186
|
margin: 0;
|
|
187
|
+
overflow-wrap: anywhere;
|
|
110
188
|
}
|
|
111
189
|
|
|
112
190
|
.rb-bases__empty {
|
|
@@ -115,6 +193,17 @@
|
|
|
115
193
|
font-style: italic;
|
|
116
194
|
}
|
|
117
195
|
|
|
196
|
+
.rb-bases__sr-only {
|
|
197
|
+
position: absolute;
|
|
198
|
+
width: 1px;
|
|
199
|
+
height: 1px;
|
|
200
|
+
padding: 0;
|
|
201
|
+
overflow: hidden;
|
|
202
|
+
clip: rect(0, 0, 0, 0);
|
|
203
|
+
white-space: nowrap;
|
|
204
|
+
border: 0;
|
|
205
|
+
}
|
|
206
|
+
|
|
118
207
|
.rb-bases__fallback {
|
|
119
208
|
margin-top: 1rem;
|
|
120
209
|
color: var(--rb-bases-muted);
|