rustfava 0.1.0__py3-none-any.whl
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.
- rustfava/__init__.py +30 -0
- rustfava/_ctx_globals_class.py +55 -0
- rustfava/api_models.py +36 -0
- rustfava/application.py +534 -0
- rustfava/beans/__init__.py +6 -0
- rustfava/beans/abc.py +327 -0
- rustfava/beans/account.py +79 -0
- rustfava/beans/create.py +377 -0
- rustfava/beans/flags.py +20 -0
- rustfava/beans/funcs.py +38 -0
- rustfava/beans/helpers.py +52 -0
- rustfava/beans/ingest.py +75 -0
- rustfava/beans/load.py +31 -0
- rustfava/beans/prices.py +151 -0
- rustfava/beans/protocols.py +82 -0
- rustfava/beans/str.py +454 -0
- rustfava/beans/types.py +63 -0
- rustfava/cli.py +187 -0
- rustfava/context.py +13 -0
- rustfava/core/__init__.py +729 -0
- rustfava/core/accounts.py +161 -0
- rustfava/core/attributes.py +145 -0
- rustfava/core/budgets.py +207 -0
- rustfava/core/charts.py +301 -0
- rustfava/core/commodities.py +37 -0
- rustfava/core/conversion.py +229 -0
- rustfava/core/documents.py +87 -0
- rustfava/core/extensions.py +132 -0
- rustfava/core/fava_options.py +255 -0
- rustfava/core/file.py +542 -0
- rustfava/core/filters.py +484 -0
- rustfava/core/group_entries.py +97 -0
- rustfava/core/ingest.py +509 -0
- rustfava/core/inventory.py +167 -0
- rustfava/core/misc.py +105 -0
- rustfava/core/module_base.py +18 -0
- rustfava/core/number.py +106 -0
- rustfava/core/query.py +180 -0
- rustfava/core/query_shell.py +301 -0
- rustfava/core/tree.py +265 -0
- rustfava/core/watcher.py +219 -0
- rustfava/ext/__init__.py +232 -0
- rustfava/ext/auto_commit.py +61 -0
- rustfava/ext/portfolio_list/PortfolioList.js +34 -0
- rustfava/ext/portfolio_list/__init__.py +29 -0
- rustfava/ext/portfolio_list/templates/PortfolioList.html +15 -0
- rustfava/ext/rustfava_ext_test/RustfavaExtTest.js +42 -0
- rustfava/ext/rustfava_ext_test/__init__.py +207 -0
- rustfava/ext/rustfava_ext_test/templates/RustfavaExtTest.html +45 -0
- rustfava/ext/rustfava_ext_test/templates/RustfavaExtTestInclude.html +1 -0
- rustfava/help/__init__.py +15 -0
- rustfava/help/_index.md +29 -0
- rustfava/help/beancount_syntax.md +156 -0
- rustfava/help/budgets.md +31 -0
- rustfava/help/conversion.md +29 -0
- rustfava/help/extensions.md +111 -0
- rustfava/help/features.md +179 -0
- rustfava/help/filters.md +103 -0
- rustfava/help/import.md +27 -0
- rustfava/help/options.md +289 -0
- rustfava/helpers.py +30 -0
- rustfava/internal_api.py +221 -0
- rustfava/json_api.py +952 -0
- rustfava/plugins/__init__.py +3 -0
- rustfava/plugins/link_documents.py +107 -0
- rustfava/plugins/tag_discovered_documents.py +44 -0
- rustfava/py.typed +0 -0
- rustfava/rustledger/__init__.py +31 -0
- rustfava/rustledger/constants.py +76 -0
- rustfava/rustledger/engine.py +485 -0
- rustfava/rustledger/loader.py +273 -0
- rustfava/rustledger/options.py +202 -0
- rustfava/rustledger/query.py +331 -0
- rustfava/rustledger/types.py +830 -0
- rustfava/serialisation.py +220 -0
- rustfava/static/app.css +2988 -0
- rustfava/static/app.css.map +7 -0
- rustfava/static/app.js +12854 -0
- rustfava/static/app.js.map +7 -0
- rustfava/static/beancount-JFV44ZVZ.css +5 -0
- rustfava/static/beancount-JFV44ZVZ.css.map +7 -0
- rustfava/static/beancount-VTTKRGSK.js +4642 -0
- rustfava/static/beancount-VTTKRGSK.js.map +7 -0
- rustfava/static/bql-MGFRUMBP.js +333 -0
- rustfava/static/bql-MGFRUMBP.js.map +7 -0
- rustfava/static/chunk-E7ZF4ASL.js +23061 -0
- rustfava/static/chunk-E7ZF4ASL.js.map +7 -0
- rustfava/static/chunk-V24TLQHT.js +12673 -0
- rustfava/static/chunk-V24TLQHT.js.map +7 -0
- rustfava/static/favicon.ico +0 -0
- rustfava/static/fira-mono-cyrillic-400-normal-BLAGXRCE.woff2 +0 -0
- rustfava/static/fira-mono-cyrillic-500-normal-EN7JUAAW.woff2 +0 -0
- rustfava/static/fira-mono-cyrillic-ext-400-normal-EX7VARTS.woff2 +0 -0
- rustfava/static/fira-mono-cyrillic-ext-500-normal-ZDPTUPRR.woff2 +0 -0
- rustfava/static/fira-mono-greek-400-normal-COGHKMOA.woff2 +0 -0
- rustfava/static/fira-mono-greek-500-normal-4EN2PKZT.woff2 +0 -0
- rustfava/static/fira-mono-greek-ext-400-normal-DYEQIJH7.woff2 +0 -0
- rustfava/static/fira-mono-greek-ext-500-normal-SG73CVKQ.woff2 +0 -0
- rustfava/static/fira-mono-latin-400-normal-NA3VLV7E.woff2 +0 -0
- rustfava/static/fira-mono-latin-500-normal-YC77GFWD.woff2 +0 -0
- rustfava/static/fira-mono-latin-ext-400-normal-DIKTZ5PW.woff2 +0 -0
- rustfava/static/fira-mono-latin-ext-500-normal-ZWY4UO4V.woff2 +0 -0
- rustfava/static/fira-mono-symbols2-400-normal-UITXT77Q.woff2 +0 -0
- rustfava/static/fira-mono-symbols2-500-normal-VWPC2EFN.woff2 +0 -0
- rustfava/static/fira-sans-cyrillic-400-normal-KLQMBCA6.woff2 +0 -0
- rustfava/static/fira-sans-cyrillic-500-normal-NFG7UD6J.woff2 +0 -0
- rustfava/static/fira-sans-cyrillic-ext-400-normal-GWO44OPC.woff2 +0 -0
- rustfava/static/fira-sans-cyrillic-ext-500-normal-SP47E5SC.woff2 +0 -0
- rustfava/static/fira-sans-greek-400-normal-UMQBTLC3.woff2 +0 -0
- rustfava/static/fira-sans-greek-500-normal-4ZKHN4FQ.woff2 +0 -0
- rustfava/static/fira-sans-greek-ext-400-normal-O2DVJAJZ.woff2 +0 -0
- rustfava/static/fira-sans-greek-ext-500-normal-SK6GNWGO.woff2 +0 -0
- rustfava/static/fira-sans-latin-400-normal-OYYTPMAV.woff2 +0 -0
- rustfava/static/fira-sans-latin-500-normal-SMQPZW5A.woff2 +0 -0
- rustfava/static/fira-sans-latin-ext-400-normal-OAUP3WK5.woff2 +0 -0
- rustfava/static/fira-sans-latin-ext-500-normal-LY3YDR5Y.woff2 +0 -0
- rustfava/static/fira-sans-vietnamese-400-normal-OBMQ72MR.woff2 +0 -0
- rustfava/static/fira-sans-vietnamese-500-normal-Y4NZR5EU.woff2 +0 -0
- rustfava/static/source-code-pro-cyrillic-400-normal-TO22V6M3.woff2 +0 -0
- rustfava/static/source-code-pro-cyrillic-500-normal-OGBWWWYW.woff2 +0 -0
- rustfava/static/source-code-pro-cyrillic-ext-400-normal-XH44UCIA.woff2 +0 -0
- rustfava/static/source-code-pro-cyrillic-ext-500-normal-3Z6MMVM6.woff2 +0 -0
- rustfava/static/source-code-pro-greek-400-normal-OUXXUQWK.woff2 +0 -0
- rustfava/static/source-code-pro-greek-500-normal-JA2Z5UXO.woff2 +0 -0
- rustfava/static/source-code-pro-greek-ext-400-normal-WCDKMX7U.woff2 +0 -0
- rustfava/static/source-code-pro-greek-ext-500-normal-ZHVI4VKW.woff2 +0 -0
- rustfava/static/source-code-pro-latin-400-normal-QOGTXED5.woff2 +0 -0
- rustfava/static/source-code-pro-latin-500-normal-X57QEOLQ.woff2 +0 -0
- rustfava/static/source-code-pro-latin-ext-400-normal-QXC74NBF.woff2 +0 -0
- rustfava/static/source-code-pro-latin-ext-500-normal-QGOY7MTT.woff2 +0 -0
- rustfava/static/source-code-pro-vietnamese-400-normal-NPDCDTBA.woff2 +0 -0
- rustfava/static/source-code-pro-vietnamese-500-normal-M6PJKTR5.woff2 +0 -0
- rustfava/static/tree-sitter-beancount-MLXFQBZ5.wasm +0 -0
- rustfava/static/web-tree-sitter-RNOQ6E74.wasm +0 -0
- rustfava/template_filters.py +64 -0
- rustfava/templates/_journal_table.html +156 -0
- rustfava/templates/_layout.html +26 -0
- rustfava/templates/_query_table.html +88 -0
- rustfava/templates/beancount_file +18 -0
- rustfava/templates/help.html +23 -0
- rustfava/templates/macros/_account_macros.html +5 -0
- rustfava/templates/macros/_commodity_macros.html +13 -0
- rustfava/translations/bg/LC_MESSAGES/messages.mo +0 -0
- rustfava/translations/bg/LC_MESSAGES/messages.po +618 -0
- rustfava/translations/ca/LC_MESSAGES/messages.mo +0 -0
- rustfava/translations/ca/LC_MESSAGES/messages.po +618 -0
- rustfava/translations/de/LC_MESSAGES/messages.mo +0 -0
- rustfava/translations/de/LC_MESSAGES/messages.po +618 -0
- rustfava/translations/es/LC_MESSAGES/messages.mo +0 -0
- rustfava/translations/es/LC_MESSAGES/messages.po +619 -0
- rustfava/translations/fa/LC_MESSAGES/messages.mo +0 -0
- rustfava/translations/fa/LC_MESSAGES/messages.po +618 -0
- rustfava/translations/fr/LC_MESSAGES/messages.mo +0 -0
- rustfava/translations/fr/LC_MESSAGES/messages.po +618 -0
- rustfava/translations/ja/LC_MESSAGES/messages.mo +0 -0
- rustfava/translations/ja/LC_MESSAGES/messages.po +618 -0
- rustfava/translations/nl/LC_MESSAGES/messages.mo +0 -0
- rustfava/translations/nl/LC_MESSAGES/messages.po +617 -0
- rustfava/translations/pt/LC_MESSAGES/messages.mo +0 -0
- rustfava/translations/pt/LC_MESSAGES/messages.po +617 -0
- rustfava/translations/pt_BR/LC_MESSAGES/messages.mo +0 -0
- rustfava/translations/pt_BR/LC_MESSAGES/messages.po +618 -0
- rustfava/translations/ru/LC_MESSAGES/messages.mo +0 -0
- rustfava/translations/ru/LC_MESSAGES/messages.po +617 -0
- rustfava/translations/sk/LC_MESSAGES/messages.mo +0 -0
- rustfava/translations/sk/LC_MESSAGES/messages.po +623 -0
- rustfava/translations/sv/LC_MESSAGES/messages.mo +0 -0
- rustfava/translations/sv/LC_MESSAGES/messages.po +618 -0
- rustfava/translations/uk/LC_MESSAGES/messages.mo +0 -0
- rustfava/translations/uk/LC_MESSAGES/messages.po +618 -0
- rustfava/translations/zh/LC_MESSAGES/messages.mo +0 -0
- rustfava/translations/zh/LC_MESSAGES/messages.po +618 -0
- rustfava/translations/zh_Hant_TW/LC_MESSAGES/messages.mo +0 -0
- rustfava/translations/zh_Hant_TW/LC_MESSAGES/messages.po +618 -0
- rustfava/util/__init__.py +157 -0
- rustfava/util/date.py +576 -0
- rustfava/util/excel.py +118 -0
- rustfava/util/ranking.py +79 -0
- rustfava/util/sets.py +18 -0
- rustfava/util/unreachable.py +20 -0
- rustfava-0.1.0.dist-info/METADATA +102 -0
- rustfava-0.1.0.dist-info/RECORD +187 -0
- rustfava-0.1.0.dist-info/WHEEL +5 -0
- rustfava-0.1.0.dist-info/entry_points.txt +2 -0
- rustfava-0.1.0.dist-info/licenses/AUTHORS +11 -0
- rustfava-0.1.0.dist-info/licenses/LICENSE +21 -0
- rustfava-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EditorState,
|
|
3
|
+
EditorView,
|
|
4
|
+
HighlightStyle,
|
|
5
|
+
LanguageSupport,
|
|
6
|
+
StreamLanguage,
|
|
7
|
+
base_extensions,
|
|
8
|
+
keymap,
|
|
9
|
+
placeholder,
|
|
10
|
+
replace_contents,
|
|
11
|
+
syntaxHighlighting,
|
|
12
|
+
tags
|
|
13
|
+
} from "./chunk-E7ZF4ASL.js";
|
|
14
|
+
|
|
15
|
+
// src/codemirror/bql-highlight.ts
|
|
16
|
+
var bql_highlight = HighlightStyle.define([
|
|
17
|
+
{
|
|
18
|
+
// Keywords: Select, Where, And
|
|
19
|
+
tag: tags.keyword,
|
|
20
|
+
color: "var(--bql-keywords)"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
// Values
|
|
24
|
+
tag: [
|
|
25
|
+
tags.typeName,
|
|
26
|
+
tags.className,
|
|
27
|
+
tags.number,
|
|
28
|
+
tags.changed,
|
|
29
|
+
tags.annotation,
|
|
30
|
+
tags.modifier,
|
|
31
|
+
tags.self,
|
|
32
|
+
tags.namespace
|
|
33
|
+
],
|
|
34
|
+
color: "var(--bql-values)"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
// Strings
|
|
38
|
+
tag: [tags.processingInstruction, tags.string, tags.inserted],
|
|
39
|
+
color: "var(--bql-string)"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
// Errors
|
|
43
|
+
tag: [
|
|
44
|
+
tags.name,
|
|
45
|
+
tags.deleted,
|
|
46
|
+
tags.character,
|
|
47
|
+
tags.propertyName,
|
|
48
|
+
tags.macroName
|
|
49
|
+
],
|
|
50
|
+
color: "var(--bql-errors)"
|
|
51
|
+
}
|
|
52
|
+
]);
|
|
53
|
+
|
|
54
|
+
// src/codemirror/bql-grammar.ts
|
|
55
|
+
var bql_grammar_default = {
|
|
56
|
+
columns: [
|
|
57
|
+
"account",
|
|
58
|
+
"accounts",
|
|
59
|
+
"amount",
|
|
60
|
+
"balance",
|
|
61
|
+
"close",
|
|
62
|
+
"comment",
|
|
63
|
+
"cost_currency",
|
|
64
|
+
"cost_date",
|
|
65
|
+
"cost_label",
|
|
66
|
+
"cost_number",
|
|
67
|
+
"currency",
|
|
68
|
+
"date",
|
|
69
|
+
"day",
|
|
70
|
+
"description",
|
|
71
|
+
"discrepancy",
|
|
72
|
+
"entry",
|
|
73
|
+
"filename",
|
|
74
|
+
"flag",
|
|
75
|
+
"id",
|
|
76
|
+
"lineno",
|
|
77
|
+
"links",
|
|
78
|
+
"location",
|
|
79
|
+
"meta",
|
|
80
|
+
"month",
|
|
81
|
+
"name",
|
|
82
|
+
"narration",
|
|
83
|
+
"number",
|
|
84
|
+
"open",
|
|
85
|
+
"other_accounts",
|
|
86
|
+
"payee",
|
|
87
|
+
"position",
|
|
88
|
+
"posting_flag",
|
|
89
|
+
"price",
|
|
90
|
+
"tags",
|
|
91
|
+
"tolerance",
|
|
92
|
+
"type",
|
|
93
|
+
"weight",
|
|
94
|
+
"year"
|
|
95
|
+
],
|
|
96
|
+
functions: [
|
|
97
|
+
"abs",
|
|
98
|
+
"account_sortkey",
|
|
99
|
+
"any_meta",
|
|
100
|
+
"bool",
|
|
101
|
+
"close_date",
|
|
102
|
+
"commodity",
|
|
103
|
+
"commodity_meta",
|
|
104
|
+
"convert",
|
|
105
|
+
"cost",
|
|
106
|
+
"count",
|
|
107
|
+
"currency",
|
|
108
|
+
"currency_meta",
|
|
109
|
+
"date",
|
|
110
|
+
"date_add",
|
|
111
|
+
"date_bin",
|
|
112
|
+
"date_diff",
|
|
113
|
+
"date_part",
|
|
114
|
+
"date_trunc",
|
|
115
|
+
"day",
|
|
116
|
+
"decimal",
|
|
117
|
+
"empty",
|
|
118
|
+
"entry_meta",
|
|
119
|
+
"filter_currency",
|
|
120
|
+
"findfirst",
|
|
121
|
+
"first",
|
|
122
|
+
"getitem",
|
|
123
|
+
"getprice",
|
|
124
|
+
"grep",
|
|
125
|
+
"grepn",
|
|
126
|
+
"has_account",
|
|
127
|
+
"int",
|
|
128
|
+
"interval",
|
|
129
|
+
"joinstr",
|
|
130
|
+
"last",
|
|
131
|
+
"leaf",
|
|
132
|
+
"length",
|
|
133
|
+
"lower",
|
|
134
|
+
"max",
|
|
135
|
+
"maxwidth",
|
|
136
|
+
"meta",
|
|
137
|
+
"min",
|
|
138
|
+
"month",
|
|
139
|
+
"neg",
|
|
140
|
+
"number",
|
|
141
|
+
"only",
|
|
142
|
+
"open_date",
|
|
143
|
+
"open_meta",
|
|
144
|
+
"parent",
|
|
145
|
+
"parse_date",
|
|
146
|
+
"possign",
|
|
147
|
+
"quarter",
|
|
148
|
+
"repr",
|
|
149
|
+
"root",
|
|
150
|
+
"round",
|
|
151
|
+
"safediv",
|
|
152
|
+
"splitcomp",
|
|
153
|
+
"str",
|
|
154
|
+
"subst",
|
|
155
|
+
"substr",
|
|
156
|
+
"sum",
|
|
157
|
+
"today",
|
|
158
|
+
"units",
|
|
159
|
+
"upper",
|
|
160
|
+
"value",
|
|
161
|
+
"weekday",
|
|
162
|
+
"year",
|
|
163
|
+
"yearmonth"
|
|
164
|
+
],
|
|
165
|
+
keywords: [
|
|
166
|
+
"and",
|
|
167
|
+
"as",
|
|
168
|
+
"asc",
|
|
169
|
+
"balances",
|
|
170
|
+
"by",
|
|
171
|
+
"create",
|
|
172
|
+
"desc",
|
|
173
|
+
"distinct",
|
|
174
|
+
"false",
|
|
175
|
+
"from",
|
|
176
|
+
"group",
|
|
177
|
+
"having",
|
|
178
|
+
"in",
|
|
179
|
+
"insert",
|
|
180
|
+
"into",
|
|
181
|
+
"is",
|
|
182
|
+
"journal",
|
|
183
|
+
"limit",
|
|
184
|
+
"not",
|
|
185
|
+
"or",
|
|
186
|
+
"order",
|
|
187
|
+
"pivot",
|
|
188
|
+
"print",
|
|
189
|
+
"select",
|
|
190
|
+
"table",
|
|
191
|
+
"true",
|
|
192
|
+
"using",
|
|
193
|
+
"where"
|
|
194
|
+
]
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
// src/codemirror/bql-autocomplete.ts
|
|
198
|
+
var { columns, functions, keywords } = bql_grammar_default;
|
|
199
|
+
var columns_functions_keywords = [
|
|
200
|
+
...columns,
|
|
201
|
+
...functions.map((f) => `${f}(`),
|
|
202
|
+
...keywords
|
|
203
|
+
].map((label) => ({ label }));
|
|
204
|
+
var command_completions = [
|
|
205
|
+
"balances",
|
|
206
|
+
"errors",
|
|
207
|
+
"explain",
|
|
208
|
+
"help",
|
|
209
|
+
"lex",
|
|
210
|
+
"parse",
|
|
211
|
+
"print",
|
|
212
|
+
"runcustom",
|
|
213
|
+
"select",
|
|
214
|
+
"tokenize"
|
|
215
|
+
].map((label) => ({ label }));
|
|
216
|
+
var bql_completion = (context) => {
|
|
217
|
+
const token = context.matchBefore(/\w+/);
|
|
218
|
+
if (!token) {
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
if (token.from === 0) {
|
|
222
|
+
return { from: token.from, options: command_completions };
|
|
223
|
+
}
|
|
224
|
+
return { from: token.from, options: columns_functions_keywords };
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
// src/codemirror/bql-stream-parser.ts
|
|
228
|
+
var keywords2 = new Set(bql_grammar_default.keywords);
|
|
229
|
+
var columns2 = new Set(bql_grammar_default.columns);
|
|
230
|
+
var functions2 = new Set(bql_grammar_default.functions);
|
|
231
|
+
var string = /^("[^"]*"|'[^']*')/;
|
|
232
|
+
var date = /^(?:#(?:"[^"]*"|'[^']*')|\d\d\d\d-\d\d-\d\d)/;
|
|
233
|
+
var decimal = /^[-+]?([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)/;
|
|
234
|
+
var integer = /^[-+]?[0-9]+/;
|
|
235
|
+
var m = (s, p) => {
|
|
236
|
+
const match = s.match(p);
|
|
237
|
+
return match != null && match !== false;
|
|
238
|
+
};
|
|
239
|
+
var bql_stream_parser = {
|
|
240
|
+
token(stream) {
|
|
241
|
+
if (stream.eatSpace() || stream.eol()) {
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
244
|
+
if (m(stream, string)) {
|
|
245
|
+
return "string";
|
|
246
|
+
}
|
|
247
|
+
if (m(stream, date) || m(stream, decimal) || m(stream, integer)) {
|
|
248
|
+
return "number";
|
|
249
|
+
}
|
|
250
|
+
if (m(stream, /\w+/)) {
|
|
251
|
+
const word = stream.current().toLowerCase();
|
|
252
|
+
if (keywords2.has(word)) {
|
|
253
|
+
return "keyword";
|
|
254
|
+
}
|
|
255
|
+
if (columns2.has(word)) {
|
|
256
|
+
return "typeName";
|
|
257
|
+
}
|
|
258
|
+
if (functions2.has(word) && stream.peek() === "(") {
|
|
259
|
+
return "macroName";
|
|
260
|
+
}
|
|
261
|
+
return "name";
|
|
262
|
+
}
|
|
263
|
+
const char = stream.next();
|
|
264
|
+
if (char === "*") {
|
|
265
|
+
return "typeName";
|
|
266
|
+
}
|
|
267
|
+
return null;
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
// src/codemirror/bql-language.ts
|
|
272
|
+
var bql_language = StreamLanguage.define(bql_stream_parser);
|
|
273
|
+
var bql_language_support = new LanguageSupport(
|
|
274
|
+
bql_language,
|
|
275
|
+
bql_language.data.of({
|
|
276
|
+
autocomplete: bql_completion
|
|
277
|
+
})
|
|
278
|
+
);
|
|
279
|
+
|
|
280
|
+
// src/codemirror/bql.ts
|
|
281
|
+
function init_document_preview_editor() {
|
|
282
|
+
return new EditorView({
|
|
283
|
+
extensions: [
|
|
284
|
+
base_extensions,
|
|
285
|
+
EditorState.readOnly.of(true),
|
|
286
|
+
placeholder("Loading...")
|
|
287
|
+
]
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
function init_readonly_query_editor(value) {
|
|
291
|
+
return new EditorView({
|
|
292
|
+
doc: value,
|
|
293
|
+
extensions: [
|
|
294
|
+
bql_language_support,
|
|
295
|
+
syntaxHighlighting(bql_highlight),
|
|
296
|
+
EditorState.readOnly.of(true)
|
|
297
|
+
]
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
function init_query_editor(value, onDocChanges, placeholder_value, get_submit) {
|
|
301
|
+
return new EditorView({
|
|
302
|
+
doc: value,
|
|
303
|
+
extensions: [
|
|
304
|
+
bql_language_support,
|
|
305
|
+
EditorView.updateListener.of((update) => {
|
|
306
|
+
if (update.docChanged) {
|
|
307
|
+
onDocChanges(update.state);
|
|
308
|
+
}
|
|
309
|
+
}),
|
|
310
|
+
keymap.of([
|
|
311
|
+
{
|
|
312
|
+
key: "Control-Enter",
|
|
313
|
+
mac: "Meta-Enter",
|
|
314
|
+
run: () => {
|
|
315
|
+
const submit = get_submit();
|
|
316
|
+
submit();
|
|
317
|
+
return true;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
]),
|
|
321
|
+
placeholder(placeholder_value),
|
|
322
|
+
base_extensions,
|
|
323
|
+
syntaxHighlighting(bql_highlight)
|
|
324
|
+
]
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
export {
|
|
328
|
+
init_document_preview_editor,
|
|
329
|
+
init_query_editor,
|
|
330
|
+
init_readonly_query_editor,
|
|
331
|
+
replace_contents
|
|
332
|
+
};
|
|
333
|
+
//# sourceMappingURL=bql-MGFRUMBP.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../frontend/src/codemirror/bql-highlight.ts", "../../../frontend/src/codemirror/bql-grammar.ts", "../../../frontend/src/codemirror/bql-autocomplete.ts", "../../../frontend/src/codemirror/bql-stream-parser.ts", "../../../frontend/src/codemirror/bql-language.ts", "../../../frontend/src/codemirror/bql.ts"],
|
|
4
|
+
"sourcesContent": ["import { HighlightStyle } from \"@codemirror/language\";\nimport { tags } from \"@lezer/highlight\";\n\nexport const bql_highlight = HighlightStyle.define([\n {\n // Keywords: Select, Where, And\n tag: tags.keyword,\n color: \"var(--bql-keywords)\",\n },\n {\n // Values\n tag: [\n tags.typeName,\n tags.className,\n tags.number,\n tags.changed,\n tags.annotation,\n tags.modifier,\n tags.self,\n tags.namespace,\n ],\n color: \"var(--bql-values)\",\n },\n {\n // Strings\n tag: [tags.processingInstruction, tags.string, tags.inserted],\n color: \"var(--bql-string)\",\n },\n {\n // Errors\n tag: [\n tags.name,\n tags.deleted,\n tags.character,\n tags.propertyName,\n tags.macroName,\n ],\n color: \"var(--bql-errors)\",\n },\n]);\n", "export default {\n columns: [\n \"account\",\n \"accounts\",\n \"amount\",\n \"balance\",\n \"close\",\n \"comment\",\n \"cost_currency\",\n \"cost_date\",\n \"cost_label\",\n \"cost_number\",\n \"currency\",\n \"date\",\n \"day\",\n \"description\",\n \"discrepancy\",\n \"entry\",\n \"filename\",\n \"flag\",\n \"id\",\n \"lineno\",\n \"links\",\n \"location\",\n \"meta\",\n \"month\",\n \"name\",\n \"narration\",\n \"number\",\n \"open\",\n \"other_accounts\",\n \"payee\",\n \"position\",\n \"posting_flag\",\n \"price\",\n \"tags\",\n \"tolerance\",\n \"type\",\n \"weight\",\n \"year\",\n ],\n functions: [\n \"abs\",\n \"account_sortkey\",\n \"any_meta\",\n \"bool\",\n \"close_date\",\n \"commodity\",\n \"commodity_meta\",\n \"convert\",\n \"cost\",\n \"count\",\n \"currency\",\n \"currency_meta\",\n \"date\",\n \"date_add\",\n \"date_bin\",\n \"date_diff\",\n \"date_part\",\n \"date_trunc\",\n \"day\",\n \"decimal\",\n \"empty\",\n \"entry_meta\",\n \"filter_currency\",\n \"findfirst\",\n \"first\",\n \"getitem\",\n \"getprice\",\n \"grep\",\n \"grepn\",\n \"has_account\",\n \"int\",\n \"interval\",\n \"joinstr\",\n \"last\",\n \"leaf\",\n \"length\",\n \"lower\",\n \"max\",\n \"maxwidth\",\n \"meta\",\n \"min\",\n \"month\",\n \"neg\",\n \"number\",\n \"only\",\n \"open_date\",\n \"open_meta\",\n \"parent\",\n \"parse_date\",\n \"possign\",\n \"quarter\",\n \"repr\",\n \"root\",\n \"round\",\n \"safediv\",\n \"splitcomp\",\n \"str\",\n \"subst\",\n \"substr\",\n \"sum\",\n \"today\",\n \"units\",\n \"upper\",\n \"value\",\n \"weekday\",\n \"year\",\n \"yearmonth\",\n ],\n keywords: [\n \"and\",\n \"as\",\n \"asc\",\n \"balances\",\n \"by\",\n \"create\",\n \"desc\",\n \"distinct\",\n \"false\",\n \"from\",\n \"group\",\n \"having\",\n \"in\",\n \"insert\",\n \"into\",\n \"is\",\n \"journal\",\n \"limit\",\n \"not\",\n \"or\",\n \"order\",\n \"pivot\",\n \"print\",\n \"select\",\n \"table\",\n \"true\",\n \"using\",\n \"where\",\n ],\n};\n", "import type { CompletionSource } from \"@codemirror/autocomplete\";\n\nimport bql_grammar from \"./bql-grammar.ts\";\n\nconst { columns, functions, keywords } = bql_grammar;\n\nconst columns_functions_keywords = [\n ...columns,\n ...functions.map((f) => `${f}(`),\n ...keywords,\n].map((label) => ({ label }));\n\nconst command_completions = [\n \"balances\",\n \"errors\",\n \"explain\",\n \"help\",\n \"lex\",\n \"parse\",\n \"print\",\n \"runcustom\",\n \"select\",\n \"tokenize\",\n].map((label) => ({ label }));\n\nexport const bql_completion: CompletionSource = (context) => {\n const token = context.matchBefore(/\\w+/);\n if (!token) {\n return null;\n }\n if (token.from === 0) {\n return { from: token.from, options: command_completions };\n }\n return { from: token.from, options: columns_functions_keywords };\n};\n", "import type { StreamParser, StringStream } from \"@codemirror/language\";\n\n// Import the autogenerated (by a script in the 'contrib' directory) lists\nimport bql_grammar from \"./bql-grammar.ts\";\n\nconst keywords = new Set(bql_grammar.keywords);\nconst columns = new Set(bql_grammar.columns);\nconst functions = new Set(bql_grammar.functions);\n\n// This should match the grammar defined in Beancount (`query/query_parser.py`).\nconst string = /^(\"[^\"]*\"|'[^']*')/;\nconst date = /^(?:#(?:\"[^\"]*\"|'[^']*')|\\d\\d\\d\\d-\\d\\d-\\d\\d)/;\nconst decimal = /^[-+]?([0-9]+\\.[0-9]*|[0-9]*\\.[0-9]+)/;\nconst integer = /^[-+]?[0-9]+/;\n\n// Check for matches - convert the response of StringStream.match into a boolean explicitly\nconst m = (s: StringStream, p: RegExp) => {\n const match = s.match(p);\n return match != null && match !== false;\n};\n\nexport const bql_stream_parser: StreamParser<unknown> = {\n token(stream) {\n if (stream.eatSpace() || stream.eol()) {\n return null;\n }\n if (m(stream, string)) {\n return \"string\";\n }\n if (m(stream, date) || m(stream, decimal) || m(stream, integer)) {\n return \"number\";\n }\n if (m(stream, /\\w+/)) {\n const word = stream.current().toLowerCase();\n if (keywords.has(word)) {\n return \"keyword\";\n }\n if (columns.has(word)) {\n return \"typeName\";\n }\n if (functions.has(word) && stream.peek() === \"(\") {\n return \"macroName\";\n }\n return \"name\";\n }\n // Skip one character since no known token matched.\n const char = stream.next();\n if (char === \"*\") {\n return \"typeName\";\n }\n return null;\n },\n};\n", "import { LanguageSupport, StreamLanguage } from \"@codemirror/language\";\n\nimport { bql_completion } from \"./bql-autocomplete.ts\";\nimport { bql_stream_parser } from \"./bql-stream-parser.ts\";\n\nconst bql_language = StreamLanguage.define(bql_stream_parser);\n\nexport const bql_language_support = new LanguageSupport(\n bql_language,\n bql_language.data.of({\n autocomplete: bql_completion,\n }),\n);\n", "import { syntaxHighlighting } from \"@codemirror/language\";\nimport { EditorState } from \"@codemirror/state\";\nimport { EditorView, keymap, placeholder } from \"@codemirror/view\";\n\nimport { base_extensions } from \"./base-extensions.ts\";\nimport { bql_highlight } from \"./bql-highlight.ts\";\nimport { bql_language_support } from \"./bql-language.ts\";\n\nexport { replace_contents } from \"./editor-transactions.ts\";\n\n/**\n * A basic readonly editor for an asynchronously loaded document.\n *\n * This doesn't use any of the BQL syntax but is provided in this file\n * to avoid more smaller chunks.\n */\nexport function init_document_preview_editor(): EditorView {\n return new EditorView({\n extensions: [\n base_extensions,\n EditorState.readOnly.of(true),\n placeholder(\"Loading...\"),\n ],\n });\n}\n\n/**\n * A basic readonly BQL editor that only does syntax highlighting.\n */\nexport function init_readonly_query_editor(value: string): EditorView {\n return new EditorView({\n doc: value,\n extensions: [\n bql_language_support,\n syntaxHighlighting(bql_highlight),\n EditorState.readOnly.of(true),\n ],\n });\n}\n\n/**\n * The main BQL editor.\n */\nexport function init_query_editor(\n value: string,\n onDocChanges: (s: EditorState) => void,\n placeholder_value: string,\n get_submit: () => () => void,\n): EditorView {\n return new EditorView({\n doc: value,\n extensions: [\n bql_language_support,\n EditorView.updateListener.of((update) => {\n if (update.docChanged) {\n onDocChanges(update.state);\n }\n }),\n keymap.of([\n {\n key: \"Control-Enter\",\n mac: \"Meta-Enter\",\n run: () => {\n const submit = get_submit();\n submit();\n return true;\n },\n },\n ]),\n placeholder(placeholder_value),\n base_extensions,\n syntaxHighlighting(bql_highlight),\n ],\n });\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;AAGO,IAAM,gBAAgB,eAAe,OAAO;AAAA,EACjD;AAAA;AAAA,IAEE,KAAK,KAAK;AAAA,IACV,OAAO;AAAA,EACT;AAAA,EACA;AAAA;AAAA,IAEE,KAAK;AAAA,MACH,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,IACP;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