Skip to content

Commit 7609ead

Browse files
Changes from apr-2024 to jun-2024
1 parent 2f1e5a8 commit 7609ead

File tree

951 files changed

+27081
-14301
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

951 files changed

+27081
-14301
lines changed

.cargo/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ rustflags = [
66
"-Ctarget-feature=+atomics,+bulk-memory",
77
"-Clink-args=-pthread -sPTHREAD_POOL_SIZE=3",
88
"-Clink-args=--post-js apps/browser/wasm/js/post.js -o apps/browser/wasm/dist/gramax-wasm.js",
9-
"-Clink-args=-sASSERTIONS=0 -sWASM=1 -sWASMFS=1 -sUSE_ZLIB=1 -sEXPORT_ES6=1 -sEXPORTED_RUNTIME_METHODS=FS,wasmMemory -sALLOW_MEMORY_GROWTH=0 -sINITIAL_MEMORY=1500mb -sSTACK_SIZE=10mb",
9+
"-Clink-args=-sASSERTIONS=0 -sWASM=1 -sWASMFS=1 -sUSE_ZLIB=1 -sEXPORT_ES6=1 -sMALLOC=emmalloc -sEXPORTED_RUNTIME_METHODS=FS,wasmMemory -sALLOW_MEMORY_GROWTH=1 -sMAXIMUM_MEMORY=4gb -sINITIAL_MEMORY=500mb -sSTACK_SIZE=15mb",
1010
"-Clink-args=-sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE=$writeArrayToMemory",
1111
"-Clink-args=-sEXPORTED_FUNCTIONS=@.cargo/exported-functions",
1212
]

.cargo/exported-functions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@ _rename
4040
_getstat
4141
_rmfile
4242
_write_file
43+
_graph_head_upstream_files

.vscode/settings.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{
22
// "rust-analyzer.cargo.target": "x86_64-pc-windows-msvc",
33
// "rust-analyzer.cargo.target": "x86_64-apple-darwin",
4-
"rust-analyzer.cargo.target": "aarch64-apple-darwin",
4+
// "rust-analyzer.cargo.target": "aarch64-apple-darwin",
55
// "rust-analyzer.cargo.target": "wasm32-unknown-emscripten",
66
// "rust-analyzer.cargo.target": "aarch64-linux-android",
77
// "rust-analyzer.cargo.target": "aarch64-apple-ios",
88

99
"rust-analyzer.check.allTargets": true,
10+
"rust-analyzer.check.features": "all",
1011

1112
"editor.tabCompletion": "on",
1213

@@ -49,8 +50,17 @@
4950
"editor.defaultFormatter": "redhat.vscode-yaml"
5051
},
5152

53+
"yaml.schemas": {
54+
"https://gitlab.com/gitlab-org/gitlab/-/raw/master/app/assets/javascripts/editor/schema/ci.json": [
55+
"/.ci/*.yml",
56+
"/.ci/**/*.yml",
57+
"/.gitlab-ci.yml"
58+
]
59+
},
60+
5261
"typescript.preferences.importModuleSpecifier": "non-relative",
5362
"typescript.tsserver.experimental.enableProjectDiagnostics": true,
5463

55-
"cSpell.words": ["katex", "Markdoc", "prosemirror", "Renderable", "tiptap", "traptitech", "Bugsnag"]
64+
"cSpell.words": ["katex", "Markdoc", "prosemirror", "Renderable", "tiptap", "traptitech", "Bugsnag"],
65+
"typescript.tsdk": "node_modules/typescript/lib"
5666
}

Cargo.toml

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ members = [
1313
"rlibs/fs",
1414

1515
"rbins/warp-spa",
16+
"rlibs/test-utils",
1617
]
1718

1819
[workspace.package]
@@ -22,31 +23,27 @@ description = "Gramax"
2223
edition = "2021"
2324

2425
[workspace.dependencies]
25-
tauri-build = { git = "https://github.com/gram-ax/tauri.git", branch = "locked-version" }
26-
27-
28-
tauri = { git = "https://github.com/gram-ax/tauri.git", branch = "locked-version", features = [
26+
tauri = { version = "^2.0.0-beta", features = [
2927
"macos-private-api",
28+
"unstable",
3029
"devtools",
3130
] }
32-
tauri-plugin-dialog = { version = "^2.0.0-alpha", git = "https://github.com/gram-ax/tauri-plugins.git", branch = "locked-version" }
33-
tauri-plugin-log = { version = "^2.0.0-alpha", git = "https://github.com/gram-ax/tauri-plugins.git", branch = "locked-version" }
34-
tauri-plugin-updater = { version = "^2.0.0-alpha", git = "https://github.com/gram-ax/tauri-plugins.git", branch = "updater-chunk-timeout" }
35-
tauri-plugin-shell = { version = "^2.0.0-alpha", git = "https://github.com/gram-ax/tauri-plugins.git", branch = "locked-version" }
31+
tauri-plugin = { version = "^2.0.0-beta", features = ["build"] }
32+
tauri-build = "^2.0.0-beta"
33+
34+
tauri-plugin-deep-link = "2.0.0-beta"
35+
tauri-plugin-dialog = "^2.0.0-beta"
36+
tauri-plugin-log = "^2.0.0-beta"
37+
tauri-plugin-updater = { version = "^2.0.0-beta", features = ["zip"] }
38+
tauri-plugin-shell = "^2.0.0-beta"
39+
40+
serde = { version = "^1.0", features = ["derive"] }
41+
serde_json = "^1.0"
3642

37-
serde = { version = "1.0.200", features = ["derive"] }
43+
log = "^0.4"
3844

3945
[profile.release]
4046
codegen-units = 1
4147
lto = true
4248
incremental = false
4349
opt-level = "s"
44-
45-
[patch.crates-io]
46-
tauri = { git = "https://github.com/gram-ax/tauri.git", branch = "locked-version", features = [
47-
"macos-private-api",
48-
"devtools",
49-
] }
50-
tauri-build = { git = "https://github.com/gram-ax/tauri.git", branch = "locked-version" }
51-
tauri-plugin-fs = { git = "https://github.com/gram-ax/tauri-plugins.git", branch = "locked-version" }
52-
wry = { git = "https://github.com/pashokitsme/wry.git", branch = "fix-proguard-v0.35.2" }

app/browser/app.ts

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
import resolveModule from "@app/resolveModule/backend";
2-
import { getExecutingEnvironment } from "@app/resolveModule/env";
32
import { ContextFactory } from "@core/Context/ContextFactory";
43
import DiskFileProvider from "@core/FileProvider/DiskFileProvider/DiskFileProvider";
54
import Path from "@core/FileProvider/Path/Path";
65
import Hash from "@core/Hash/Hash";
7-
import Library from "@core/Library/Library";
8-
import deleteAnyFolderRule from "@core/Library/Rules/DeleteAnyFolderRule/DeleteAnyFolderRule";
96
import PluginImporterType from "@core/Plugin/PluginImporter/logic/PluginImporterType";
107
import PluginProvider from "@core/Plugin/logic/PluginProvider";
118
import CustomArticlePresenter from "@core/SitePresenter/CustomArticlePresenter";
129
import SitePresenterFactory from "@core/SitePresenter/SitePresenterFactory";
1310
import { TableDB } from "@core/components/tableDB/table";
1411
import VideoUrlRepository from "@core/components/video/videoUrlRepository";
12+
import YamlFileConfig from "@core/utils/YamlFileConfig";
1513
import Cache from "@ext/Cache";
1614
import { Encoder } from "@ext/Encoder/Encoder";
1715
import MailProvider from "@ext/MailProvider";
@@ -20,15 +18,16 @@ import RepositoryProvider from "@ext/git/core/Repository/RepositoryProvider";
2018
import HtmlParser from "@ext/html/HtmlParser";
2119
import FSLocalizationRules from "@ext/localization/core/rules/FSLocalizationRules";
2220
import BugsnagLogger from "@ext/loggers/BugsnagLogger";
21+
import ConsoleLogger from "@ext/loggers/ConsoleLogger";
2322
import Logger from "@ext/loggers/Logger";
2423
import MarkdownParser from "@ext/markdown/core/Parser/Parser";
2524
import ParserContextFactory from "@ext/markdown/core/Parser/ParserContext/ParserContextFactory";
2625
import MarkdownFormatter from "@ext/markdown/core/edit/logic/Formatter/Formatter";
2726
import AuthManager from "@ext/security/logic/AuthManager";
2827
import Sso from "@ext/security/logic/AuthProviders/Sso";
2928
import { TicketManager } from "@ext/security/logic/TicketManager/TicketManager";
30-
import { BrowserFileProvider } from "../../apps/browser/src/logic/FileProvider/BrowserFileProvider";
31-
import { AppConfig, getConfig } from "../config/AppConfig";
29+
import WorkspaceManager from "@ext/workspace/WorkspaceManager";
30+
import { AppConfig, getConfig, type AppGlobalConfig } from "../config/AppConfig";
3231
import Application from "../types/Application";
3332

3433
const _init = async (config: AppConfig): Promise<Application> => {
@@ -40,53 +39,55 @@ const _init = async (config: AppConfig): Promise<Application> => {
4039
await resolveModule("initWasm")?.(config.services.cors.url);
4140

4241
const rp = new RepositoryProvider({ corsProxy: config.services.cors.url });
43-
const fp = new DiskFileProvider(config.paths.root);
44-
await fp.validate();
4542

46-
const obsoleteFp = getExecutingEnvironment() == "browser" && new BrowserFileProvider(Path.empty);
43+
const fileConfig = await YamlFileConfig.readFromFile<AppGlobalConfig>(
44+
new DiskFileProvider(config.paths.data),
45+
new Path("config.yaml"),
46+
);
47+
48+
const wm = new WorkspaceManager(
49+
(path) => new DiskFileProvider(path),
50+
(fs) => FSLocalizationRules.bind(fs),
51+
rp,
52+
config,
53+
fileConfig,
54+
);
4755

48-
const libRules = getExecutingEnvironment() == "browser" ? [deleteAnyFolderRule] : [];
49-
const lib = new Library(rp, config.isServerApp);
50-
await lib.addFileProvider(fp, (fs) => FSLocalizationRules.bind(fs), libRules);
56+
await wm.readWorkspaces();
5157

5258
const hashes = new Hash();
5359
const tm = new ThemeManager();
5460
const encoder = new Encoder();
55-
const ticketManager = new TicketManager(lib, encoder, config.tokens.share);
61+
const ticketManager = new TicketManager(wm, encoder, config.tokens.share);
5662
const parser = new MarkdownParser();
5763
const formatter = new MarkdownFormatter();
58-
const tablesManager = new TableDB(parser, lib);
64+
const tablesManager = new TableDB(parser, wm);
5965
const customArticlePresenter = new CustomArticlePresenter();
66+
6067
const parserContextFactory = new ParserContextFactory(
6168
config.paths.base,
62-
fp,
69+
wm,
6370
tablesManager,
6471
parser,
6572
formatter,
6673
config.services.sso.url,
6774
config.services.diagramRenderer.url,
6875
);
6976
const htmlParser = new HtmlParser(parser, parserContextFactory);
70-
const logger: Logger = new BugsnagLogger(config.bugsnagApiKey);
71-
const sitePresenterFactory = new SitePresenterFactory(
72-
lib,
73-
parser,
74-
parserContextFactory,
75-
rp,
76-
customArticlePresenter,
77-
);
77+
const logger: Logger = config.isProduction ? new BugsnagLogger(config) : new ConsoleLogger();
78+
const sitePresenterFactory = new SitePresenterFactory(wm, parser, parserContextFactory, rp, customArticlePresenter);
79+
7880
const contextFactory = new ContextFactory(tm, config.tokens.cookie);
7981

80-
const cacheFileProvider = new DiskFileProvider(config.paths.userDataPath);
81-
const cache = new Cache(cacheFileProvider);
82-
const pluginProvider = new PluginProvider(lib, htmlParser, cache, PluginImporterType.browser);
82+
const cache = new Cache(new DiskFileProvider(config.paths.cache));
83+
const pluginProvider = new PluginProvider(wm, htmlParser, cache, PluginImporterType.browser);
8384

8485
return {
8586
am,
8687
tm,
8788
mp,
8889
sso,
89-
lib,
90+
wm,
9091
vur,
9192
rp,
9293
cache,
@@ -102,7 +103,6 @@ const _init = async (config: AppConfig): Promise<Application> => {
102103
parserContextFactory,
103104
pluginProvider,
104105
customArticlePresenter,
105-
obsoleteFp,
106106
conf: {
107107
services: config.services,
108108

@@ -115,6 +115,7 @@ const _init = async (config: AppConfig): Promise<Application> => {
115115

116116
bugsnagApiKey: config.bugsnagApiKey,
117117
version: config.version,
118+
buildVersion: config.buildVersion,
118119
},
119120
};
120121
};

app/commands/article/create.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ const create: Command<{ ctx: Context; catalogName: string; parentPath?: Path },
1616
middlewares: [new AuthorizeMiddleware(), new DesktopModeMiddleware(), new ReloadConfirmMiddleware()],
1717

1818
async do({ ctx, catalogName, parentPath }) {
19-
const { formatter, lib, parser, parserContextFactory } = this._app;
20-
const catalog = await lib.getCatalog(catalogName);
21-
const fp = lib.getFileProviderByCatalog(catalog);
19+
const { formatter, parser, parserContextFactory, wm } = this._app;
20+
const workspace = wm.current();
21+
22+
const catalog = await workspace.getCatalog(catalogName);
23+
const fp = workspace.getFileProvider();
2224
const parentRef = fp.getItemRef(parentPath);
2325

2426
const markdown = "\n\n";

app/commands/article/editOn/app.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ const app: Command<{ catalogName: string; articlePath: Path }, string> = Command
99
kind: ResponseKind.plain,
1010

1111
async do({ catalogName, articlePath }) {
12-
const { lib } = this._app;
13-
const catalog = await lib.getCatalog(catalogName);
12+
const workspace = this._app.wm.current();
13+
const catalog = await workspace.getCatalog(catalogName);
1414
if (!catalog) return;
15-
const fp = lib.getFileProviderByCatalog(catalog);
15+
const fp = workspace.getFileProvider();
1616
const itemRef = fp.getItemRef(articlePath);
1717
const item = catalog.findArticleByItemRef(itemRef);
1818
return RouterPathProvider.getPathname(await catalog.getPathnameData(item)).value;

app/commands/article/editOn/source.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ const source: Command<{ catalogName: string; articlePath: Path }, string> = Comm
88
kind: ResponseKind.plain,
99

1010
async do({ catalogName, articlePath }) {
11-
const { lib } = this._app;
12-
const catalog = await lib.getCatalog(catalogName);
11+
const workspace = this._app.wm.current();
12+
const catalog = await workspace.getCatalog(catalogName);
1313
if (!catalog) return;
1414
if (!articlePath.startsWith(catalog.getBasePath())) return;
15-
const fp = lib.getFileProviderByCatalog(catalog);
15+
const fp = workspace.getFileProvider();
1616
const itemRef = fp.getItemRef(articlePath);
1717
const path = catalog.getRelativeRepPath(itemRef);
1818
const { gitVersionControl } = await catalog.repo.gvc.getGitVersionControlContainsItem(path);

app/commands/article/features/checkLastModified.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { AuthorizeMiddleware } from "@core/Api/middleware/AuthorizeMiddleware";
33
import Context from "@core/Context/Context";
44
import Path from "@core/FileProvider/Path/Path";
55
import { Article } from "@core/FileStructue/Article/Article";
6+
import FileStructueErrorCode from "@core/FileStructue/error/model/FileStructueErrorCode";
67
import { ArticlePageData } from "@core/SitePresenter/SitePresenter";
78
import DefaultError from "../../../../core/extensions/errorHandlers/logic/DefaultError";
89
import { Command } from "../../../types/Command";
@@ -16,11 +17,12 @@ const checkLastModified: Command<{ ctx: Context; articlePath: Path; catalogName:
1617
middlewares: [new AuthorizeMiddleware()],
1718

1819
async do({ ctx, articlePath, catalogName }) {
19-
const { lib, sitePresenterFactory } = this._app;
20-
const catalog = await lib.getCatalog(catalogName);
20+
const { sitePresenterFactory, wm } = this._app;
21+
const workspace = wm.current();
22+
const catalog = await workspace.getCatalog(catalogName);
2123
if (!catalog || !catalog.getRootCategory().items.length) return;
2224

23-
const fp = lib.getFileProviderByCatalog(catalog);
25+
const fp = workspace.getFileProvider();
2426
const itemRef = fp.getItemRef(articlePath);
2527
const article = catalog.findItemByItemRef<Article>(itemRef);
2628
if (!article || article.props.welcome) return;
@@ -30,7 +32,8 @@ const checkLastModified: Command<{ ctx: Context; articlePath: Path; catalogName:
3032
const stat = await fp.getStat(article.ref.path);
3133
res = await article.checkLastModified(stat.mtimeMs);
3234
} catch (e) {
33-
if (e?.code === "ENOENT") throw new DefaultError(null, e, { errorCode: e?.code });
35+
if (e?.code === "ENOENT")
36+
throw new DefaultError(null, e, { errorCode: FileStructueErrorCode.ArticleNotFoundError });
3437
}
3538

3639
return res ? await sitePresenterFactory.fromContext(ctx).getArticlePageData(article, catalog) : null;
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { Command } from "@app/types/Command";
2+
import { ResponseKind } from "@app/types/ResponseKind";
3+
import { TitleItem } from "@core-ui/ContextServices/LinkTitleTooltip";
4+
import Context from "@core/Context/Context";
5+
import Path from "@core/FileProvider/Path/Path";
6+
import { Article } from "@core/FileStructue/Article/Article";
7+
import parseContent from "@core/FileStructue/Article/parseContent";
8+
import { getLevelTocItemsByRenderableTree } from "@ext/navigation/article/logic/createTocItems";
9+
10+
const getArticleHeadersByRelativePath: Command<
11+
{ ctx: Context; articlePath: Path; catalogName: string; articleRelativePath: Path },
12+
TitleItem[]
13+
> = Command.create({
14+
path: "article/features/getArticleHeadersByRelativePath",
15+
kind: ResponseKind.json,
16+
17+
async do({ ctx, catalogName, articlePath, articleRelativePath }) {
18+
const { parser, parserContextFactory, wm } = this._app;
19+
const workspace = wm.current();
20+
if (!articleRelativePath.value) return null;
21+
22+
const path = articlePath.parentDirectoryPath.join(articleRelativePath);
23+
const catalog = await workspace.getCatalog(catalogName);
24+
const article: Article = catalog.findItemByItemPath(path);
25+
if (!article) return null;
26+
27+
await parseContent(article, catalog, ctx, parser, parserContextFactory);
28+
29+
const { renderTree } = article.parsedContent;
30+
if (!renderTree || typeof renderTree === "string") return null;
31+
32+
const headersTocItem = getLevelTocItemsByRenderableTree(renderTree.children);
33+
if (headersTocItem.length === 0) return [];
34+
35+
const minLevel = Math.min(...headersTocItem.map((node) => node.level));
36+
37+
return headersTocItem.map((headerItem) => {
38+
return { level: headerItem.level - minLevel, url: headerItem.url, title: headerItem.title };
39+
});
40+
},
41+
42+
params(ctx, q) {
43+
const catalogName = q.catalogName;
44+
const articlePath = new Path(q.articlePath);
45+
const articleRelativePath = new Path(q.articleRelativePath);
46+
return { ctx, catalogName, articlePath, articleRelativePath };
47+
},
48+
});
49+
50+
export default getArticleHeadersByRelativePath;

0 commit comments

Comments
 (0)