@xwiki/cristal-electron-storage 0.14.0 → 0.16.0
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/CHANGELOG.md +31 -0
- package/dist/default/components/FileSystemConfig.d.ts +1 -0
- package/dist/default/electron/preload/apiTypes.d.ts +1 -0
- package/dist/default/index.es.js +17 -14
- package/dist/default/index.es.js.map +1 -1
- package/dist/default/index.umd.js +1 -1
- package/dist/default/index.umd.js.map +1 -1
- package/dist/main/components/FileSystemConfig.d.ts +1 -0
- package/dist/main/electron/preload/apiTypes.d.ts +1 -0
- package/dist/main/index.es.js +17 -14
- package/dist/main/index.es.js.map +1 -1
- package/dist/main/index.umd.js +1 -1
- package/dist/main/index.umd.js.map +1 -1
- package/dist/preload/components/FileSystemConfig.d.ts +1 -0
- package/dist/preload/electron/preload/apiTypes.d.ts +1 -0
- package/dist/preload/index.es.js +17 -14
- package/dist/preload/index.es.js.map +1 -1
- package/dist/preload/index.umd.js +1 -1
- package/dist/preload/index.umd.js.map +1 -1
- package/package.json +13 -12
- package/src/components/FileSystemConfig.ts +11 -1
- package/src/components/fileSystemStorage.ts +1 -1
- package/src/componentsInit.ts +2 -2
- package/src/electron/main/index.ts +46 -30
- package/src/electron/preload/apiTypes.ts +2 -0
- package/src/electron/preload/index.ts +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# @xwiki/cristal-electron-storage
|
|
2
2
|
|
|
3
|
+
## 0.16.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Cristal 0.16 Release
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @xwiki/cristal-api@0.16.0
|
|
13
|
+
- @xwiki/cristal-backend-api@0.16.0
|
|
14
|
+
- @xwiki/cristal-link-suggest-api@0.16.0
|
|
15
|
+
- @xwiki/cristal-model-api@0.16.0
|
|
16
|
+
- @xwiki/cristal-model-remote-url-filesystem-api@0.16.0
|
|
17
|
+
- @xwiki/cristal-electron-state@0.16.0
|
|
18
|
+
|
|
19
|
+
## 0.15.0
|
|
20
|
+
|
|
21
|
+
### Minor Changes
|
|
22
|
+
|
|
23
|
+
- Cristal 0.15 Release
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- Updated dependencies
|
|
28
|
+
- @xwiki/cristal-api@0.15.0
|
|
29
|
+
- @xwiki/cristal-backend-api@0.15.0
|
|
30
|
+
- @xwiki/cristal-link-suggest-api@0.15.0
|
|
31
|
+
- @xwiki/cristal-model-api@0.15.0
|
|
32
|
+
- @xwiki/cristal-model-remote-url-filesystem-api@0.15.0
|
|
33
|
+
|
|
3
34
|
## 0.14.0
|
|
4
35
|
|
|
5
36
|
### Minor Changes
|
|
@@ -2,6 +2,7 @@ import { PageAttachment, PageData } from '@xwiki/cristal-api';
|
|
|
2
2
|
import { LinkType } from '@xwiki/cristal-link-suggest-api';
|
|
3
3
|
import { EntityType } from '@xwiki/cristal-model-api';
|
|
4
4
|
export interface APITypes {
|
|
5
|
+
initRootDirectory(): void;
|
|
5
6
|
resolvePath(page: string): Promise<string>;
|
|
6
7
|
resolveAttachmentsPath(page: string): Promise<string>;
|
|
7
8
|
resolveAttachmentPath(page: string, filename: string): Promise<string>;
|
package/dist/default/index.es.js
CHANGED
|
@@ -1,30 +1,33 @@
|
|
|
1
1
|
import { DefaultWikiConfig as h, DefaultPageData as S } from "@xwiki/cristal-api";
|
|
2
|
-
import { injectable as c, inject as
|
|
2
|
+
import { injectable as c, inject as l, named as u } from "inversify";
|
|
3
3
|
import { AbstractStorage as f } from "@xwiki/cristal-backend-api";
|
|
4
|
-
var p = Object.defineProperty,
|
|
5
|
-
for (var s = a > 1 ? void 0 : a ?
|
|
4
|
+
var p = Object.defineProperty, y = Object.getOwnPropertyDescriptor, P = (t, e, r, a) => {
|
|
5
|
+
for (var s = a > 1 ? void 0 : a ? y(e, r) : e, o = t.length - 1, n; o >= 0; o--)
|
|
6
6
|
(n = t[o]) && (s = (a ? n(e, r, s) : n(s)) || s);
|
|
7
7
|
return a && s && p(e, r, s), s;
|
|
8
8
|
}, i = (t, e) => (r, a) => e(r, a, t);
|
|
9
|
-
let
|
|
9
|
+
let g = class extends h {
|
|
10
10
|
constructor(t, e, r) {
|
|
11
11
|
super(t), this.storage = e, this.cristal = r, this.storage.setWikiConfig(this), this.homePage === "" && (this.homePage = "index.md");
|
|
12
12
|
}
|
|
13
13
|
getType() {
|
|
14
14
|
return "FileSystem";
|
|
15
15
|
}
|
|
16
|
+
initialize() {
|
|
17
|
+
super.initialize(), fileSystemStorage.initRootDirectory();
|
|
18
|
+
}
|
|
16
19
|
};
|
|
17
|
-
|
|
20
|
+
g = P([
|
|
18
21
|
c(),
|
|
19
|
-
i(0,
|
|
20
|
-
i(1,
|
|
22
|
+
i(0, l("Logger")),
|
|
23
|
+
i(1, l("Storage")),
|
|
21
24
|
i(1, u("FileSystem")),
|
|
22
|
-
i(2,
|
|
23
|
-
],
|
|
24
|
-
var
|
|
25
|
-
for (var s = a > 1 ? void 0 : a ?
|
|
25
|
+
i(2, l("CristalApp"))
|
|
26
|
+
], g);
|
|
27
|
+
var d = Object.defineProperty, v = Object.getOwnPropertyDescriptor, w = (t, e, r, a) => {
|
|
28
|
+
for (var s = a > 1 ? void 0 : a ? v(e, r) : e, o = t.length - 1, n; o >= 0; o--)
|
|
26
29
|
(n = t[o]) && (s = (a ? n(e, r, s) : n(s)) || s);
|
|
27
|
-
return a && s &&
|
|
30
|
+
return a && s && d(e, r, s), s;
|
|
28
31
|
}, _ = (t, e) => (r, a) => e(r, a, t);
|
|
29
32
|
let m = class extends f {
|
|
30
33
|
constructor(t) {
|
|
@@ -92,12 +95,12 @@ let m = class extends f {
|
|
|
92
95
|
};
|
|
93
96
|
m = w([
|
|
94
97
|
c(),
|
|
95
|
-
_(0,
|
|
98
|
+
_(0, l("Logger"))
|
|
96
99
|
], m);
|
|
97
100
|
class D {
|
|
98
101
|
constructor(e) {
|
|
99
102
|
var r, a;
|
|
100
|
-
this.logger = e.get("Logger"), this.logger.setModule("electron.storage.components.componentsInit"), (r = this.logger) == null || r.debug("Init Sample Module components begin"), e.bind("WikiConfig").to(
|
|
103
|
+
this.logger = e.get("Logger"), this.logger.setModule("electron.storage.components.componentsInit"), (r = this.logger) == null || r.debug("Init Sample Module components begin"), e.bind("WikiConfig").to(g).whenNamed("FileSystem"), e.bind("Storage").to(m).whenNamed("FileSystem"), (a = this.logger) == null || a.debug("Init Sample Module components end");
|
|
101
104
|
}
|
|
102
105
|
}
|
|
103
106
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../../src/components/FileSystemConfig.ts","../../src/components/fileSystemStorage.ts","../../src/componentsInit.ts"],"sourcesContent":["/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { DefaultWikiConfig } from \"@xwiki/cristal-api\";\nimport { inject, injectable, named } from \"inversify\";\nimport type { CristalApp, Logger, Storage } from \"@xwiki/cristal-api\";\n\n@injectable()\nexport class FileSystemConfig extends DefaultWikiConfig {\n override storage: Storage;\n override cristal: CristalApp;\n constructor(\n @inject<Logger>(\"Logger\") logger: Logger,\n @inject(\"Storage\") @named(\"FileSystem\") storage: Storage,\n @inject(\"CristalApp\") cristal: CristalApp,\n ) {\n super(logger);\n this.storage = storage;\n this.cristal = cristal;\n this.storage.setWikiConfig(this);\n if (this.homePage === \"\") {\n this.homePage = \"index.md\";\n }\n }\n\n override getType(): string {\n return \"FileSystem\";\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport {\n AttachmentsData,\n DefaultPageData,\n PageAttachment,\n PageData,\n} from \"@xwiki/cristal-api\";\nimport { AbstractStorage } from \"@xwiki/cristal-backend-api\";\nimport { inject, injectable } from \"inversify\";\nimport type { Logger } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport default class FileSystemStorage extends AbstractStorage {\n constructor(@inject<Logger>(\"Logger\") logger: Logger) {\n super(logger, \"storage.components.fileSystemStorage\");\n }\n\n getEditField(): Promise<string> {\n return Promise.resolve(\"\");\n }\n\n getImageURL(): string {\n return \"\";\n }\n\n async getPageContent(page: string): Promise<PageData> {\n const decodedPage = decodeURI(page);\n const path = await fileSystemStorage.resolvePath(decodedPage);\n const pageData = await fileSystemStorage.readPage(path || \"\");\n if (pageData) {\n pageData.id = decodedPage;\n pageData.headline = pageData.name;\n pageData.headlineRaw = pageData.name;\n }\n return pageData;\n }\n\n async getAttachments(page: string): Promise<AttachmentsData | undefined> {\n const path = await fileSystemStorage.resolveAttachmentsPath(page);\n return {\n attachments: await fileSystemStorage.readAttachments(path),\n };\n }\n\n async getAttachment(\n page: string,\n name: string,\n ): Promise<PageAttachment | undefined> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, name);\n return fileSystemStorage.readAttachment(path);\n }\n\n getPageFromViewURL(): string | null {\n return null;\n }\n\n getPageRestURL(): string {\n return \"\";\n }\n\n getPanelContent(): Promise<PageData> {\n return Promise.resolve(new DefaultPageData());\n }\n\n isStorageReady(): Promise<boolean> {\n return Promise.resolve(true);\n }\n\n async save(page: string, content: string, title: string): Promise<void> {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.savePage(path, content, title);\n }\n\n async saveAttachments(page: string, files: File[]): Promise<unknown> {\n return Promise.all(files.map((file) => this.saveAttachment(page, file)));\n }\n\n async delete(page: string): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.deletePage(path);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n async move(\n page: string,\n newPage: string,\n preserveChildren: boolean,\n ): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n const newPath = await fileSystemStorage.resolvePath(newPage);\n await fileSystemStorage.movePage(path, newPath, preserveChildren);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n private async saveAttachment(page: string, file: File): Promise<unknown> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, file.name);\n await fileSystemStorage.saveAttachment(path, file);\n return;\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { FileSystemConfig } from \"./components/FileSystemConfig\";\nimport FileSystemStorage from \"./components/fileSystemStorage\";\nimport type { Logger, Storage, WikiConfig } from \"@xwiki/cristal-api\";\nimport type { Container } from \"inversify\";\n\nexport default class ComponentInit {\n logger: Logger;\n\n constructor(container: Container) {\n this.logger = container.get<Logger>(\"Logger\");\n this.logger.setModule(\"electron.storage.components.componentsInit\");\n\n this.logger?.debug(\"Init Sample Module components begin\");\n container\n .bind<WikiConfig>(\"WikiConfig\")\n .to(FileSystemConfig)\n .whenTargetNamed(\"FileSystem\");\n container\n .bind<Storage>(\"Storage\")\n .to(FileSystemStorage)\n .whenTargetNamed(\"FileSystem\");\n this.logger?.debug(\"Init Sample Module components end\");\n }\n}\n"],"names":["FileSystemConfig","DefaultWikiConfig","logger","storage","cristal","__decorateClass","injectable","__decorateParam","FileSystemStorage","AbstractStorage","page","decodedPage","path","pageData","name","DefaultPageData","content","title","files","file","error","newPage","preserveChildren","newPath","ComponentInit","container","_a","_b"],"mappings":";;;;;;;;AAyBa,IAAAA,IAAN,cAA+BC,EAAkB;AAAA,EAGtD,YAC4BC,GACcC,GAClBC,GACtB;AACA,UAAMF,CAAM,GACZ,KAAK,UAAUC,GACf,KAAK,UAAUC,GACV,KAAA,QAAQ,cAAc,IAAI,GAC3B,KAAK,aAAa,OACpB,KAAK,WAAW;AAAA,EAClB;AAAA,EAGO,UAAkB;AAClB,WAAA;AAAA,EAAA;AAEX;AApBaJ,IAANK,EAAA;AAAA,EADNC,EAAW;AAAA,EAKPC,OAAe,QAAQ,CAAA;AAAA,EACvBA,OAAO,SAAS,CAAA;AAAA,EAAGA,OAAM,YAAY,CAAA;AAAA,EACrCA,OAAO,YAAY,CAAA;AAAA,GANXP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AA,KAAA,WAAA,QAAAA,EAAQ,MAAM;AAAA,EAAmC;AAE1D;"}
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../../src/components/FileSystemConfig.ts","../../src/components/fileSystemStorage.ts","../../src/componentsInit.ts"],"sourcesContent":["/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport { DefaultWikiConfig } from \"@xwiki/cristal-api\";\nimport { inject, injectable, named } from \"inversify\";\nimport type { CristalApp, Logger, Storage } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport class FileSystemConfig extends DefaultWikiConfig {\n override storage: Storage;\n override cristal: CristalApp;\n constructor(\n @inject(\"Logger\") logger: Logger,\n @inject(\"Storage\") @named(\"FileSystem\") storage: Storage,\n @inject(\"CristalApp\") cristal: CristalApp,\n ) {\n super(logger);\n this.storage = storage;\n this.cristal = cristal;\n this.storage.setWikiConfig(this);\n if (this.homePage === \"\") {\n this.homePage = \"index.md\";\n }\n }\n\n override getType(): string {\n return \"FileSystem\";\n }\n\n override initialize(): void {\n super.initialize();\n // The initialization for the root directory needs to be done after a\n // configuration change, but before any storage operation.\n fileSystemStorage.initRootDirectory();\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport {\n AttachmentsData,\n DefaultPageData,\n PageAttachment,\n PageData,\n} from \"@xwiki/cristal-api\";\nimport { AbstractStorage } from \"@xwiki/cristal-backend-api\";\nimport { inject, injectable } from \"inversify\";\nimport type { Logger } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport default class FileSystemStorage extends AbstractStorage {\n constructor(@inject(\"Logger\") logger: Logger) {\n super(logger, \"storage.components.fileSystemStorage\");\n }\n\n getEditField(): Promise<string> {\n return Promise.resolve(\"\");\n }\n\n getImageURL(): string {\n return \"\";\n }\n\n async getPageContent(page: string): Promise<PageData> {\n const decodedPage = decodeURI(page);\n const path = await fileSystemStorage.resolvePath(decodedPage);\n const pageData = await fileSystemStorage.readPage(path || \"\");\n if (pageData) {\n pageData.id = decodedPage;\n pageData.headline = pageData.name;\n pageData.headlineRaw = pageData.name;\n }\n return pageData;\n }\n\n async getAttachments(page: string): Promise<AttachmentsData | undefined> {\n const path = await fileSystemStorage.resolveAttachmentsPath(page);\n return {\n attachments: await fileSystemStorage.readAttachments(path),\n };\n }\n\n async getAttachment(\n page: string,\n name: string,\n ): Promise<PageAttachment | undefined> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, name);\n return fileSystemStorage.readAttachment(path);\n }\n\n getPageFromViewURL(): string | null {\n return null;\n }\n\n getPageRestURL(): string {\n return \"\";\n }\n\n getPanelContent(): Promise<PageData> {\n return Promise.resolve(new DefaultPageData());\n }\n\n isStorageReady(): Promise<boolean> {\n return Promise.resolve(true);\n }\n\n async save(page: string, content: string, title: string): Promise<void> {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.savePage(path, content, title);\n }\n\n async saveAttachments(page: string, files: File[]): Promise<unknown> {\n return Promise.all(files.map((file) => this.saveAttachment(page, file)));\n }\n\n async delete(page: string): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.deletePage(path);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n async move(\n page: string,\n newPage: string,\n preserveChildren: boolean,\n ): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n const newPath = await fileSystemStorage.resolvePath(newPage);\n await fileSystemStorage.movePage(path, newPath, preserveChildren);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n private async saveAttachment(page: string, file: File): Promise<unknown> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, file.name);\n await fileSystemStorage.saveAttachment(path, file);\n return;\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { FileSystemConfig } from \"./components/FileSystemConfig\";\nimport FileSystemStorage from \"./components/fileSystemStorage\";\nimport type { Logger, Storage, WikiConfig } from \"@xwiki/cristal-api\";\nimport type { Container } from \"inversify\";\n\nexport default class ComponentInit {\n logger: Logger;\n\n constructor(container: Container) {\n this.logger = container.get<Logger>(\"Logger\");\n this.logger.setModule(\"electron.storage.components.componentsInit\");\n\n this.logger?.debug(\"Init Sample Module components begin\");\n container\n .bind<WikiConfig>(\"WikiConfig\")\n .to(FileSystemConfig)\n .whenNamed(\"FileSystem\");\n container\n .bind<Storage>(\"Storage\")\n .to(FileSystemStorage)\n .whenNamed(\"FileSystem\");\n this.logger?.debug(\"Init Sample Module components end\");\n }\n}\n"],"names":["FileSystemConfig","DefaultWikiConfig","logger","storage","cristal","__decorateClass","injectable","__decorateParam","FileSystemStorage","AbstractStorage","page","decodedPage","path","pageData","name","DefaultPageData","content","title","files","file","error","newPage","preserveChildren","newPath","ComponentInit","container","_a","_b"],"mappings":";;;;;;;;AA4Ba,IAAAA,IAAN,cAA+BC,EAAkB;AAAA,EAGtD,YACoBC,GACsBC,GAClBC,GACtB;AACA,UAAMF,CAAM,GACZ,KAAK,UAAUC,GACf,KAAK,UAAUC,GACV,KAAA,QAAQ,cAAc,IAAI,GAC3B,KAAK,aAAa,OACpB,KAAK,WAAW;AAAA,EAClB;AAAA,EAGO,UAAkB;AAClB,WAAA;AAAA,EAAA;AAAA,EAGA,aAAmB;AAC1B,UAAM,WAAW,GAGjB,kBAAkB,kBAAkB;AAAA,EAAA;AAExC;AA3BaJ,IAANK,EAAA;AAAA,EADNC,EAAW;AAAA,EAKPC,OAAO,QAAQ,CAAA;AAAA,EACfA,OAAO,SAAS,CAAA;AAAA,EAAGA,OAAM,YAAY,CAAA;AAAA,EACrCA,OAAO,YAAY,CAAA;AAAA,GANXP,CAAA;;;;;;ACMb,IAAqBQ,IAArB,cAA+CC,EAAgB;AAAA,EAC7D,YAA8BP,GAAgB;AAC5C,UAAMA,GAAQ,sCAAsC;AAAA,EAAA;AAAA,EAGtD,eAAgC;AACvB,WAAA,QAAQ,QAAQ,EAAE;AA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wiki/cristal-backend-api")):typeof define=="function"&&define.amd?define(["exports","@xwiki/cristal-api","inversify","@xwiki/cristal-backend-api"],l):(i=typeof globalThis<"u"?globalThis:i||self,l(i.cristal_storage={},i.cristalApi,i.inversify,i.cristalBackendApi))})(this,function(i,l,n,h){"use strict";var S=Object.defineProperty,f=Object.getOwnPropertyDescriptor,p=(t,e,r,a)=>{for(var s=a>1?void 0:a?f(e,r):e,o=t.length-1,c;o>=0;o--)(c=t[o])&&(s=(a?c(e,r,s):c(s))||s);return a&&s&&S(e,r,s),s},g=(t,e)=>(r,a)=>e(r,a,t);let m=class extends l.DefaultWikiConfig{constructor(t,e,r){super(t),this.storage=e,this.cristal=r,this.storage.setWikiConfig(this),this.homePage===""&&(this.homePage="index.md")}getType(){return"FileSystem"}initialize(){super.initialize(),fileSystemStorage.initRootDirectory()}};m=p([n.injectable(),g(0,n.inject("Logger")),g(1,n.inject("Storage")),g(1,n.named("FileSystem")),g(2,n.inject("CristalApp"))],m);var d=Object.defineProperty,y=Object.getOwnPropertyDescriptor,P=(t,e,r,a)=>{for(var s=a>1?void 0:a?y(e,r):e,o=t.length-1,c;o>=0;o--)(c=t[o])&&(s=(a?c(e,r,s):c(s))||s);return a&&s&&d(e,r,s),s},v=(t,e)=>(r,a)=>e(r,a,t);let u=class extends h.AbstractStorage{constructor(t){super(t,"storage.components.fileSystemStorage")}getEditField(){return Promise.resolve("")}getImageURL(){return""}async getPageContent(t){const e=decodeURI(t),r=await fileSystemStorage.resolvePath(e),a=await fileSystemStorage.readPage(r||"");return a&&(a.id=e,a.headline=a.name,a.headlineRaw=a.name),a}async getAttachments(t){const e=await fileSystemStorage.resolveAttachmentsPath(t);return{attachments:await fileSystemStorage.readAttachments(e)}}async getAttachment(t,e){const r=await fileSystemStorage.resolveAttachmentPath(t,e);return fileSystemStorage.readAttachment(r)}getPageFromViewURL(){return null}getPageRestURL(){return""}getPanelContent(){return Promise.resolve(new l.DefaultPageData)}isStorageReady(){return Promise.resolve(!0)}async save(t,e,r){const a=await fileSystemStorage.resolvePath(t);await fileSystemStorage.savePage(a,e,r)}async saveAttachments(t,e){return Promise.all(e.map(r=>this.saveAttachment(t,r)))}async delete(t){try{const e=await fileSystemStorage.resolvePath(t);return await fileSystemStorage.deletePage(e),{success:!0}}catch(e){return{success:!1,error:e.message}}}async move(t,e,r){try{const a=await fileSystemStorage.resolvePath(t),s=await fileSystemStorage.resolvePath(e);return await fileSystemStorage.movePage(a,s,r),{success:!0}}catch(a){return{success:!1,error:a.message}}}async saveAttachment(t,e){const r=await fileSystemStorage.resolveAttachmentPath(t,e.name);await fileSystemStorage.saveAttachment(r,e)}};u=P([n.injectable(),v(0,n.inject("Logger"))],u);class w{constructor(e){var r,a;this.logger=e.get("Logger"),this.logger.setModule("electron.storage.components.componentsInit"),(r=this.logger)==null||r.debug("Init Sample Module components begin"),e.bind("WikiConfig").to(m).whenNamed("FileSystem"),e.bind("Storage").to(u).whenNamed("FileSystem"),(a=this.logger)==null||a.debug("Init Sample Module components end")}}i.ComponentInit=w,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
|
|
2
2
|
//# sourceMappingURL=index.umd.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../../src/components/FileSystemConfig.ts","../../src/components/fileSystemStorage.ts","../../src/componentsInit.ts"],"sourcesContent":["/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { DefaultWikiConfig } from \"@xwiki/cristal-api\";\nimport { inject, injectable, named } from \"inversify\";\nimport type { CristalApp, Logger, Storage } from \"@xwiki/cristal-api\";\n\n@injectable()\nexport class FileSystemConfig extends DefaultWikiConfig {\n override storage: Storage;\n override cristal: CristalApp;\n constructor(\n @inject<Logger>(\"Logger\") logger: Logger,\n @inject(\"Storage\") @named(\"FileSystem\") storage: Storage,\n @inject(\"CristalApp\") cristal: CristalApp,\n ) {\n super(logger);\n this.storage = storage;\n this.cristal = cristal;\n this.storage.setWikiConfig(this);\n if (this.homePage === \"\") {\n this.homePage = \"index.md\";\n }\n }\n\n override getType(): string {\n return \"FileSystem\";\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport {\n AttachmentsData,\n DefaultPageData,\n PageAttachment,\n PageData,\n} from \"@xwiki/cristal-api\";\nimport { AbstractStorage } from \"@xwiki/cristal-backend-api\";\nimport { inject, injectable } from \"inversify\";\nimport type { Logger } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport default class FileSystemStorage extends AbstractStorage {\n constructor(@inject<Logger>(\"Logger\") logger: Logger) {\n super(logger, \"storage.components.fileSystemStorage\");\n }\n\n getEditField(): Promise<string> {\n return Promise.resolve(\"\");\n }\n\n getImageURL(): string {\n return \"\";\n }\n\n async getPageContent(page: string): Promise<PageData> {\n const decodedPage = decodeURI(page);\n const path = await fileSystemStorage.resolvePath(decodedPage);\n const pageData = await fileSystemStorage.readPage(path || \"\");\n if (pageData) {\n pageData.id = decodedPage;\n pageData.headline = pageData.name;\n pageData.headlineRaw = pageData.name;\n }\n return pageData;\n }\n\n async getAttachments(page: string): Promise<AttachmentsData | undefined> {\n const path = await fileSystemStorage.resolveAttachmentsPath(page);\n return {\n attachments: await fileSystemStorage.readAttachments(path),\n };\n }\n\n async getAttachment(\n page: string,\n name: string,\n ): Promise<PageAttachment | undefined> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, name);\n return fileSystemStorage.readAttachment(path);\n }\n\n getPageFromViewURL(): string | null {\n return null;\n }\n\n getPageRestURL(): string {\n return \"\";\n }\n\n getPanelContent(): Promise<PageData> {\n return Promise.resolve(new DefaultPageData());\n }\n\n isStorageReady(): Promise<boolean> {\n return Promise.resolve(true);\n }\n\n async save(page: string, content: string, title: string): Promise<void> {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.savePage(path, content, title);\n }\n\n async saveAttachments(page: string, files: File[]): Promise<unknown> {\n return Promise.all(files.map((file) => this.saveAttachment(page, file)));\n }\n\n async delete(page: string): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.deletePage(path);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n async move(\n page: string,\n newPage: string,\n preserveChildren: boolean,\n ): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n const newPath = await fileSystemStorage.resolvePath(newPage);\n await fileSystemStorage.movePage(path, newPath, preserveChildren);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n private async saveAttachment(page: string, file: File): Promise<unknown> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, file.name);\n await fileSystemStorage.saveAttachment(path, file);\n return;\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { FileSystemConfig } from \"./components/FileSystemConfig\";\nimport FileSystemStorage from \"./components/fileSystemStorage\";\nimport type { Logger, Storage, WikiConfig } from \"@xwiki/cristal-api\";\nimport type { Container } from \"inversify\";\n\nexport default class ComponentInit {\n logger: Logger;\n\n constructor(container: Container) {\n this.logger = container.get<Logger>(\"Logger\");\n this.logger.setModule(\"electron.storage.components.componentsInit\");\n\n this.logger?.debug(\"Init Sample Module components begin\");\n container\n .bind<WikiConfig>(\"WikiConfig\")\n .to(FileSystemConfig)\n .whenTargetNamed(\"FileSystem\");\n container\n .bind<Storage>(\"Storage\")\n .to(FileSystemStorage)\n .whenTargetNamed(\"FileSystem\");\n this.logger?.debug(\"Init Sample Module components end\");\n }\n}\n"],"names":["FileSystemConfig","DefaultWikiConfig","logger","storage","cristal","__decorateClass","injectable","__decorateParam","FileSystemStorage","AbstractStorage","page","decodedPage","path","pageData","name","DefaultPageData","content","title","files","file","error","newPage","preserveChildren","newPath","ComponentInit","container","_a","_b"],"mappings":"0oBAyBa,IAAAA,EAAN,cAA+BC,EAAAA,iBAAkB,CAGtD,YAC4BC,EACcC,EAClBC,EACtB,CACA,MAAMF,CAAM,EACZ,KAAK,QAAUC,EACf,KAAK,QAAUC,EACV,KAAA,QAAQ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BmB,EAAA,KAAA,SAAA,MAAAA,EAAQ,MAAM,oCAAmC,CAE1D"}
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../../src/components/FileSystemConfig.ts","../../src/components/fileSystemStorage.ts","../../src/componentsInit.ts"],"sourcesContent":["/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport { DefaultWikiConfig } from \"@xwiki/cristal-api\";\nimport { inject, injectable, named } from \"inversify\";\nimport type { CristalApp, Logger, Storage } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport class FileSystemConfig extends DefaultWikiConfig {\n override storage: Storage;\n override cristal: CristalApp;\n constructor(\n @inject(\"Logger\") logger: Logger,\n @inject(\"Storage\") @named(\"FileSystem\") storage: Storage,\n @inject(\"CristalApp\") cristal: CristalApp,\n ) {\n super(logger);\n this.storage = storage;\n this.cristal = cristal;\n this.storage.setWikiConfig(this);\n if (this.homePage === \"\") {\n this.homePage = \"index.md\";\n }\n }\n\n override getType(): string {\n return \"FileSystem\";\n }\n\n override initialize(): void {\n super.initialize();\n // The initialization for the root directory needs to be done after a\n // configuration change, but before any storage operation.\n fileSystemStorage.initRootDirectory();\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport {\n AttachmentsData,\n DefaultPageData,\n PageAttachment,\n PageData,\n} from \"@xwiki/cristal-api\";\nimport { AbstractStorage } from \"@xwiki/cristal-backend-api\";\nimport { inject, injectable } from \"inversify\";\nimport type { Logger } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport default class FileSystemStorage extends AbstractStorage {\n constructor(@inject(\"Logger\") logger: Logger) {\n super(logger, \"storage.components.fileSystemStorage\");\n }\n\n getEditField(): Promise<string> {\n return Promise.resolve(\"\");\n }\n\n getImageURL(): string {\n return \"\";\n }\n\n async getPageContent(page: string): Promise<PageData> {\n const decodedPage = decodeURI(page);\n const path = await fileSystemStorage.resolvePath(decodedPage);\n const pageData = await fileSystemStorage.readPage(path || \"\");\n if (pageData) {\n pageData.id = decodedPage;\n pageData.headline = pageData.name;\n pageData.headlineRaw = pageData.name;\n }\n return pageData;\n }\n\n async getAttachments(page: string): Promise<AttachmentsData | undefined> {\n const path = await fileSystemStorage.resolveAttachmentsPath(page);\n return {\n attachments: await fileSystemStorage.readAttachments(path),\n };\n }\n\n async getAttachment(\n page: string,\n name: string,\n ): Promise<PageAttachment | undefined> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, name);\n return fileSystemStorage.readAttachment(path);\n }\n\n getPageFromViewURL(): string | null {\n return null;\n }\n\n getPageRestURL(): string {\n return \"\";\n }\n\n getPanelContent(): Promise<PageData> {\n return Promise.resolve(new DefaultPageData());\n }\n\n isStorageReady(): Promise<boolean> {\n return Promise.resolve(true);\n }\n\n async save(page: string, content: string, title: string): Promise<void> {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.savePage(path, content, title);\n }\n\n async saveAttachments(page: string, files: File[]): Promise<unknown> {\n return Promise.all(files.map((file) => this.saveAttachment(page, file)));\n }\n\n async delete(page: string): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.deletePage(path);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n async move(\n page: string,\n newPage: string,\n preserveChildren: boolean,\n ): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n const newPath = await fileSystemStorage.resolvePath(newPage);\n await fileSystemStorage.movePage(path, newPath, preserveChildren);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n private async saveAttachment(page: string, file: File): Promise<unknown> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, file.name);\n await fileSystemStorage.saveAttachment(path, file);\n return;\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { FileSystemConfig } from \"./components/FileSystemConfig\";\nimport FileSystemStorage from \"./components/fileSystemStorage\";\nimport type { Logger, Storage, WikiConfig } from \"@xwiki/cristal-api\";\nimport type { Container } from \"inversify\";\n\nexport default class ComponentInit {\n logger: Logger;\n\n constructor(container: Container) {\n this.logger = container.get<Logger>(\"Logger\");\n this.logger.setModule(\"electron.storage.components.componentsInit\");\n\n this.logger?.debug(\"Init Sample Module components begin\");\n container\n .bind<WikiConfig>(\"WikiConfig\")\n .to(FileSystemConfig)\n .whenNamed(\"FileSystem\");\n container\n .bind<Storage>(\"Storage\")\n .to(FileSystemStorage)\n .whenNamed(\"FileSystem\");\n this.logger?.debug(\"Init Sample Module components end\");\n }\n}\n"],"names":["FileSystemConfig","DefaultWikiConfig","logger","storage","cristal","__decorateClass","injectable","__decorateParam","FileSystemStorage","AbstractStorage","page","decodedPage","path","pageData","name","DefaultPageData","content","title","files","file","error","newPage","preserveChildren","newPath","ComponentInit","container","_a","_b"],"mappings":"0oBA4Ba,IAAAA,EAAN,cAA+BC,EAAAA,iBAAkB,CAGtD,YACoBC,EACsBC,EAClBC,EACtB,CACA,MAAMF,CAAM,EACZ,KAAK,QAAUC,EACf,KAAK,QAAUC,EACV,KAAA,QAAQ,cAAc,IAAI,EAC3B,KAAK,WAAa,KACpB,KAAK,SAAW,WAClB,CAGO,SAAkB,CAClB,MAAA,YAAA,CAGA,YAAmB,CAC1B,MAAM,WAAW,EAGjB,kBAAkB,kBAAkB,CAAA,CAExC,EA3BaJ,EAANK,EAAA,CADNC,aAAW,EAKPC,aAAO,QAAQ,CAAA,EACfA,aAAO,SAAS,CAAA,EAAGA,YAAM,YAAY,CAAA,EACrCA,aAAO,YAAY,CAAA,CAAA,EANXP,CAAA,2NCMb,IAAqBQ,EAArB,cAA+CC,EAAAA,eAAgB,CAC7D,YAA8BP,EAAgB,CAC5C,MAAMA,EAAQ,sCAAsC,CAAA,CAGtD,cAAgC,CACvB,OAAA,QAAQ,QAAQ,EAAE,CAAA,CAG3B,aAAsB,CACb,MAAA,EAAA,CAGT,MAAM,eAAeQ,EAAiC,CAC9C,MAAAC,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AM,kBAAkB,YAAYF,CAAI,EAC/Ca,EAAU,MAAM,kBAAkB,YAAYF,CAAO,EAC3D,aAAM,kBAAkB,SAAST,EAAMW,EAASD,CAAgB,EACzD,CAAE,QAAS,EAAK,QAChBF,EAAO,CACd,MAAO,CAAE,QAAS,GAAO,MAAQA,EAAgB,OAAQ,CAAA,CAC3D,CAGF,MAAc,eAAeV,EAAcS,EAA8B,CACvE,MAAMP,EAAO,MAAM,kBAAkB,sBAAsBF,EAAMS,EAAK,IAAI,EACpE,MAAA,kBAAkB,eAAeP,EAAMO,CAAI,CACjD,CAEJ,EA/FqBX,EAArBH,EAAA,CADCC,aAAW,EAEGC,aAAO,QAAQ,CAAA,CAAA,EADTC,CAAA,ECTrB,MAAqBgB,CAAc,CAGjC,YAAYC,EAAsB,SAC3B,KAAA,OAASA,EAAU,IAAY,QAAQ,EACvC,KAAA,OAAO,UAAU,4CAA4C,GAE7DC,EAAA,KAAA,SAAA,MAAAA,EAAQ,MAAM,uCACnBD,EACG,KAAiB,YAAY,EAC7B,GAAGzB,CAAgB,EACnB,UAAU,YAAY,EACzByB,EACG,KAAc,SAAS,EACvB,GAAGjB,CAAiB,EACpB,UAAU,YAAY,GACpBmB,EAAA,KAAA,SAAA,MAAAA,EAAQ,MAAM,oCAAmC,CAE1D"}
|
|
@@ -2,6 +2,7 @@ import { PageAttachment, PageData } from '@xwiki/cristal-api';
|
|
|
2
2
|
import { LinkType } from '@xwiki/cristal-link-suggest-api';
|
|
3
3
|
import { EntityType } from '@xwiki/cristal-model-api';
|
|
4
4
|
export interface APITypes {
|
|
5
|
+
initRootDirectory(): void;
|
|
5
6
|
resolvePath(page: string): Promise<string>;
|
|
6
7
|
resolveAttachmentsPath(page: string): Promise<string>;
|
|
7
8
|
resolveAttachmentPath(page: string, filename: string): Promise<string>;
|
package/dist/main/index.es.js
CHANGED
|
@@ -1,30 +1,33 @@
|
|
|
1
1
|
import { DefaultWikiConfig as h, DefaultPageData as S } from "@xwiki/cristal-api";
|
|
2
|
-
import { injectable as c, inject as
|
|
2
|
+
import { injectable as c, inject as l, named as u } from "inversify";
|
|
3
3
|
import { AbstractStorage as f } from "@xwiki/cristal-backend-api";
|
|
4
|
-
var p = Object.defineProperty,
|
|
5
|
-
for (var s = a > 1 ? void 0 : a ?
|
|
4
|
+
var p = Object.defineProperty, y = Object.getOwnPropertyDescriptor, P = (t, e, r, a) => {
|
|
5
|
+
for (var s = a > 1 ? void 0 : a ? y(e, r) : e, o = t.length - 1, n; o >= 0; o--)
|
|
6
6
|
(n = t[o]) && (s = (a ? n(e, r, s) : n(s)) || s);
|
|
7
7
|
return a && s && p(e, r, s), s;
|
|
8
8
|
}, i = (t, e) => (r, a) => e(r, a, t);
|
|
9
|
-
let
|
|
9
|
+
let g = class extends h {
|
|
10
10
|
constructor(t, e, r) {
|
|
11
11
|
super(t), this.storage = e, this.cristal = r, this.storage.setWikiConfig(this), this.homePage === "" && (this.homePage = "index.md");
|
|
12
12
|
}
|
|
13
13
|
getType() {
|
|
14
14
|
return "FileSystem";
|
|
15
15
|
}
|
|
16
|
+
initialize() {
|
|
17
|
+
super.initialize(), fileSystemStorage.initRootDirectory();
|
|
18
|
+
}
|
|
16
19
|
};
|
|
17
|
-
|
|
20
|
+
g = P([
|
|
18
21
|
c(),
|
|
19
|
-
i(0,
|
|
20
|
-
i(1,
|
|
22
|
+
i(0, l("Logger")),
|
|
23
|
+
i(1, l("Storage")),
|
|
21
24
|
i(1, u("FileSystem")),
|
|
22
|
-
i(2,
|
|
23
|
-
],
|
|
24
|
-
var
|
|
25
|
-
for (var s = a > 1 ? void 0 : a ?
|
|
25
|
+
i(2, l("CristalApp"))
|
|
26
|
+
], g);
|
|
27
|
+
var d = Object.defineProperty, v = Object.getOwnPropertyDescriptor, w = (t, e, r, a) => {
|
|
28
|
+
for (var s = a > 1 ? void 0 : a ? v(e, r) : e, o = t.length - 1, n; o >= 0; o--)
|
|
26
29
|
(n = t[o]) && (s = (a ? n(e, r, s) : n(s)) || s);
|
|
27
|
-
return a && s &&
|
|
30
|
+
return a && s && d(e, r, s), s;
|
|
28
31
|
}, _ = (t, e) => (r, a) => e(r, a, t);
|
|
29
32
|
let m = class extends f {
|
|
30
33
|
constructor(t) {
|
|
@@ -92,12 +95,12 @@ let m = class extends f {
|
|
|
92
95
|
};
|
|
93
96
|
m = w([
|
|
94
97
|
c(),
|
|
95
|
-
_(0,
|
|
98
|
+
_(0, l("Logger"))
|
|
96
99
|
], m);
|
|
97
100
|
class D {
|
|
98
101
|
constructor(e) {
|
|
99
102
|
var r, a;
|
|
100
|
-
this.logger = e.get("Logger"), this.logger.setModule("electron.storage.components.componentsInit"), (r = this.logger) == null || r.debug("Init Sample Module components begin"), e.bind("WikiConfig").to(
|
|
103
|
+
this.logger = e.get("Logger"), this.logger.setModule("electron.storage.components.componentsInit"), (r = this.logger) == null || r.debug("Init Sample Module components begin"), e.bind("WikiConfig").to(g).whenNamed("FileSystem"), e.bind("Storage").to(m).whenNamed("FileSystem"), (a = this.logger) == null || a.debug("Init Sample Module components end");
|
|
101
104
|
}
|
|
102
105
|
}
|
|
103
106
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../../src/components/FileSystemConfig.ts","../../src/components/fileSystemStorage.ts","../../src/componentsInit.ts"],"sourcesContent":["/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { DefaultWikiConfig } from \"@xwiki/cristal-api\";\nimport { inject, injectable, named } from \"inversify\";\nimport type { CristalApp, Logger, Storage } from \"@xwiki/cristal-api\";\n\n@injectable()\nexport class FileSystemConfig extends DefaultWikiConfig {\n override storage: Storage;\n override cristal: CristalApp;\n constructor(\n @inject<Logger>(\"Logger\") logger: Logger,\n @inject(\"Storage\") @named(\"FileSystem\") storage: Storage,\n @inject(\"CristalApp\") cristal: CristalApp,\n ) {\n super(logger);\n this.storage = storage;\n this.cristal = cristal;\n this.storage.setWikiConfig(this);\n if (this.homePage === \"\") {\n this.homePage = \"index.md\";\n }\n }\n\n override getType(): string {\n return \"FileSystem\";\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport {\n AttachmentsData,\n DefaultPageData,\n PageAttachment,\n PageData,\n} from \"@xwiki/cristal-api\";\nimport { AbstractStorage } from \"@xwiki/cristal-backend-api\";\nimport { inject, injectable } from \"inversify\";\nimport type { Logger } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport default class FileSystemStorage extends AbstractStorage {\n constructor(@inject<Logger>(\"Logger\") logger: Logger) {\n super(logger, \"storage.components.fileSystemStorage\");\n }\n\n getEditField(): Promise<string> {\n return Promise.resolve(\"\");\n }\n\n getImageURL(): string {\n return \"\";\n }\n\n async getPageContent(page: string): Promise<PageData> {\n const decodedPage = decodeURI(page);\n const path = await fileSystemStorage.resolvePath(decodedPage);\n const pageData = await fileSystemStorage.readPage(path || \"\");\n if (pageData) {\n pageData.id = decodedPage;\n pageData.headline = pageData.name;\n pageData.headlineRaw = pageData.name;\n }\n return pageData;\n }\n\n async getAttachments(page: string): Promise<AttachmentsData | undefined> {\n const path = await fileSystemStorage.resolveAttachmentsPath(page);\n return {\n attachments: await fileSystemStorage.readAttachments(path),\n };\n }\n\n async getAttachment(\n page: string,\n name: string,\n ): Promise<PageAttachment | undefined> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, name);\n return fileSystemStorage.readAttachment(path);\n }\n\n getPageFromViewURL(): string | null {\n return null;\n }\n\n getPageRestURL(): string {\n return \"\";\n }\n\n getPanelContent(): Promise<PageData> {\n return Promise.resolve(new DefaultPageData());\n }\n\n isStorageReady(): Promise<boolean> {\n return Promise.resolve(true);\n }\n\n async save(page: string, content: string, title: string): Promise<void> {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.savePage(path, content, title);\n }\n\n async saveAttachments(page: string, files: File[]): Promise<unknown> {\n return Promise.all(files.map((file) => this.saveAttachment(page, file)));\n }\n\n async delete(page: string): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.deletePage(path);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n async move(\n page: string,\n newPage: string,\n preserveChildren: boolean,\n ): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n const newPath = await fileSystemStorage.resolvePath(newPage);\n await fileSystemStorage.movePage(path, newPath, preserveChildren);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n private async saveAttachment(page: string, file: File): Promise<unknown> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, file.name);\n await fileSystemStorage.saveAttachment(path, file);\n return;\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { FileSystemConfig } from \"./components/FileSystemConfig\";\nimport FileSystemStorage from \"./components/fileSystemStorage\";\nimport type { Logger, Storage, WikiConfig } from \"@xwiki/cristal-api\";\nimport type { Container } from \"inversify\";\n\nexport default class ComponentInit {\n logger: Logger;\n\n constructor(container: Container) {\n this.logger = container.get<Logger>(\"Logger\");\n this.logger.setModule(\"electron.storage.components.componentsInit\");\n\n this.logger?.debug(\"Init Sample Module components begin\");\n container\n .bind<WikiConfig>(\"WikiConfig\")\n .to(FileSystemConfig)\n .whenTargetNamed(\"FileSystem\");\n container\n .bind<Storage>(\"Storage\")\n .to(FileSystemStorage)\n .whenTargetNamed(\"FileSystem\");\n this.logger?.debug(\"Init Sample Module components end\");\n }\n}\n"],"names":["FileSystemConfig","DefaultWikiConfig","logger","storage","cristal","__decorateClass","injectable","__decorateParam","FileSystemStorage","AbstractStorage","page","decodedPage","path","pageData","name","DefaultPageData","content","title","files","file","error","newPage","preserveChildren","newPath","ComponentInit","container","_a","_b"],"mappings":";;;;;;;;AAyBa,IAAAA,IAAN,cAA+BC,EAAkB;AAAA,EAGtD,YAC4BC,GACcC,GAClBC,GACtB;AACA,UAAMF,CAAM,GACZ,KAAK,UAAUC,GACf,KAAK,UAAUC,GACV,KAAA,QAAQ,cAAc,IAAI,GAC3B,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AC3B,SAAA,SAASA,EAAU,IAAY,QAAQ,GACvC,KAAA,OAAO,UAAU,4CAA4C,IAE7DC,IAAA,KAAA,WAAA,QAAAA,EAAQ,MAAM,wCACnBD,EACG,KAAiB,YAAY,EAC7B,GAAGzB,CAAgB,EACnB,gBAAgB,YAAY,GAC/ByB,EACG,KAAc,SAAS,EACvB,GAAGjB,CAAiB,EACpB,gBAAgB,YAAY,IAC1BmB,IAAA,KAAA,WAAA,QAAAA,EAAQ,MAAM;AAAA,EAAmC;AAE1D;"}
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../../src/components/FileSystemConfig.ts","../../src/components/fileSystemStorage.ts","../../src/componentsInit.ts"],"sourcesContent":["/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport { DefaultWikiConfig } from \"@xwiki/cristal-api\";\nimport { inject, injectable, named } from \"inversify\";\nimport type { CristalApp, Logger, Storage } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport class FileSystemConfig extends DefaultWikiConfig {\n override storage: Storage;\n override cristal: CristalApp;\n constructor(\n @inject(\"Logger\") logger: Logger,\n @inject(\"Storage\") @named(\"FileSystem\") storage: Storage,\n @inject(\"CristalApp\") cristal: CristalApp,\n ) {\n super(logger);\n this.storage = storage;\n this.cristal = cristal;\n this.storage.setWikiConfig(this);\n if (this.homePage === \"\") {\n this.homePage = \"index.md\";\n }\n }\n\n override getType(): string {\n return \"FileSystem\";\n }\n\n override initialize(): void {\n super.initialize();\n // The initialization for the root directory needs to be done after a\n // configuration change, but before any storage operation.\n fileSystemStorage.initRootDirectory();\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport {\n AttachmentsData,\n DefaultPageData,\n PageAttachment,\n PageData,\n} from \"@xwiki/cristal-api\";\nimport { AbstractStorage } from \"@xwiki/cristal-backend-api\";\nimport { inject, injectable } from \"inversify\";\nimport type { Logger } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport default class FileSystemStorage extends AbstractStorage {\n constructor(@inject(\"Logger\") logger: Logger) {\n super(logger, \"storage.components.fileSystemStorage\");\n }\n\n getEditField(): Promise<string> {\n return Promise.resolve(\"\");\n }\n\n getImageURL(): string {\n return \"\";\n }\n\n async getPageContent(page: string): Promise<PageData> {\n const decodedPage = decodeURI(page);\n const path = await fileSystemStorage.resolvePath(decodedPage);\n const pageData = await fileSystemStorage.readPage(path || \"\");\n if (pageData) {\n pageData.id = decodedPage;\n pageData.headline = pageData.name;\n pageData.headlineRaw = pageData.name;\n }\n return pageData;\n }\n\n async getAttachments(page: string): Promise<AttachmentsData | undefined> {\n const path = await fileSystemStorage.resolveAttachmentsPath(page);\n return {\n attachments: await fileSystemStorage.readAttachments(path),\n };\n }\n\n async getAttachment(\n page: string,\n name: string,\n ): Promise<PageAttachment | undefined> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, name);\n return fileSystemStorage.readAttachment(path);\n }\n\n getPageFromViewURL(): string | null {\n return null;\n }\n\n getPageRestURL(): string {\n return \"\";\n }\n\n getPanelContent(): Promise<PageData> {\n return Promise.resolve(new DefaultPageData());\n }\n\n isStorageReady(): Promise<boolean> {\n return Promise.resolve(true);\n }\n\n async save(page: string, content: string, title: string): Promise<void> {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.savePage(path, content, title);\n }\n\n async saveAttachments(page: string, files: File[]): Promise<unknown> {\n return Promise.all(files.map((file) => this.saveAttachment(page, file)));\n }\n\n async delete(page: string): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.deletePage(path);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n async move(\n page: string,\n newPage: string,\n preserveChildren: boolean,\n ): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n const newPath = await fileSystemStorage.resolvePath(newPage);\n await fileSystemStorage.movePage(path, newPath, preserveChildren);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n private async saveAttachment(page: string, file: File): Promise<unknown> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, file.name);\n await fileSystemStorage.saveAttachment(path, file);\n return;\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { FileSystemConfig } from \"./components/FileSystemConfig\";\nimport FileSystemStorage from \"./components/fileSystemStorage\";\nimport type { Logger, Storage, WikiConfig } from \"@xwiki/cristal-api\";\nimport type { Container } from \"inversify\";\n\nexport default class ComponentInit {\n logger: Logger;\n\n constructor(container: Container) {\n this.logger = container.get<Logger>(\"Logger\");\n this.logger.setModule(\"electron.storage.components.componentsInit\");\n\n this.logger?.debug(\"Init Sample Module components begin\");\n container\n .bind<WikiConfig>(\"WikiConfig\")\n .to(FileSystemConfig)\n .whenNamed(\"FileSystem\");\n container\n .bind<Storage>(\"Storage\")\n .to(FileSystemStorage)\n .whenNamed(\"FileSystem\");\n this.logger?.debug(\"Init Sample Module components end\");\n }\n}\n"],"names":["FileSystemConfig","DefaultWikiConfig","logger","storage","cristal","__decorateClass","injectable","__decorateParam","FileSystemStorage","AbstractStorage","page","decodedPage","path","pageData","name","DefaultPageData","content","title","files","file","error","newPage","preserveChildren","newPath","ComponentInit","container","_a","_b"],"mappings":";;;;;;;;AA4Ba,IAAAA,IAAN,cAA+BC,EAAkB;AAAA,EAGtD,YACoBC,GACsBC,GAClBC,GACtB;AACA,UAAMF,CAAM,GACZ,KAAK,UAAUC,GACf,KAAK,UAAUC,GACV,KAAA,QAAQ,cAAc,IAAI,GAC3B,KAAK,aAAa,OACpB,KAAK,WAAW;AAAA,EAClB;AAAA,EAGO,UAAkB;AAClB,WAAA;AAAA,EAAA;AAAA,EAGA,aAAmB;AAC1B,UAAM,WAAW,GAGjB,kBAAkB,kBAAkB;AAAA,EAAA;AAExC;AA3BaJ,IAANK,EAAA;AAAA,EADNC,EAAW;AAAA,EAKPC,OAAO,QAAQ,CAAA;AAAA,EACfA,O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,YAAY,GACzByB,EACG,KAAc,SAAS,EACvB,GAAGjB,CAAiB,EACpB,UAAU,YAAY,IACpBmB,IAAA,KAAA,WAAA,QAAAA,EAAQ,MAAM;AAAA,EAAmC;AAE1D;"}
|
package/dist/main/index.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(i,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("@xwiki/cristal-api"),require("inversify"),require("@xwiki/cristal-backend-api")):typeof define=="function"&&define.amd?define(["exports","@xwiki/cristal-api","inversify","@xwiki/cristal-backend-api"],l):(i=typeof globalThis<"u"?globalThis:i||self,l(i.cristal_storage={},i.cristalApi,i.inversify,i.cristalBackendApi))})(this,function(i,l,n,h){"use strict";var S=Object.defineProperty,f=Object.getOwnPropertyDescriptor,p=(t,e,r,a)=>{for(var s=a>1?void 0:a?f(e,r):e,o=t.length-1,c;o>=0;o--)(c=t[o])&&(s=(a?c(e,r,s):c(s))||s);return a&&s&&S(e,r,s),s},g=(t,e)=>(r,a)=>e(r,a,t);let m=class extends l.DefaultWikiConfig{constructor(t,e,r){super(t),this.storage=e,this.cristal=r,this.storage.setWikiConfig(this),this.homePage===""&&(this.homePage="index.md")}getType(){return"FileSystem"}initialize(){super.initialize(),fileSystemStorage.initRootDirectory()}};m=p([n.injectable(),g(0,n.inject("Logger")),g(1,n.inject("Storage")),g(1,n.named("FileSystem")),g(2,n.inject("CristalApp"))],m);var d=Object.defineProperty,y=Object.getOwnPropertyDescriptor,P=(t,e,r,a)=>{for(var s=a>1?void 0:a?y(e,r):e,o=t.length-1,c;o>=0;o--)(c=t[o])&&(s=(a?c(e,r,s):c(s))||s);return a&&s&&d(e,r,s),s},v=(t,e)=>(r,a)=>e(r,a,t);let u=class extends h.AbstractStorage{constructor(t){super(t,"storage.components.fileSystemStorage")}getEditField(){return Promise.resolve("")}getImageURL(){return""}async getPageContent(t){const e=decodeURI(t),r=await fileSystemStorage.resolvePath(e),a=await fileSystemStorage.readPage(r||"");return a&&(a.id=e,a.headline=a.name,a.headlineRaw=a.name),a}async getAttachments(t){const e=await fileSystemStorage.resolveAttachmentsPath(t);return{attachments:await fileSystemStorage.readAttachments(e)}}async getAttachment(t,e){const r=await fileSystemStorage.resolveAttachmentPath(t,e);return fileSystemStorage.readAttachment(r)}getPageFromViewURL(){return null}getPageRestURL(){return""}getPanelContent(){return Promise.resolve(new l.DefaultPageData)}isStorageReady(){return Promise.resolve(!0)}async save(t,e,r){const a=await fileSystemStorage.resolvePath(t);await fileSystemStorage.savePage(a,e,r)}async saveAttachments(t,e){return Promise.all(e.map(r=>this.saveAttachment(t,r)))}async delete(t){try{const e=await fileSystemStorage.resolvePath(t);return await fileSystemStorage.deletePage(e),{success:!0}}catch(e){return{success:!1,error:e.message}}}async move(t,e,r){try{const a=await fileSystemStorage.resolvePath(t),s=await fileSystemStorage.resolvePath(e);return await fileSystemStorage.movePage(a,s,r),{success:!0}}catch(a){return{success:!1,error:a.message}}}async saveAttachment(t,e){const r=await fileSystemStorage.resolveAttachmentPath(t,e.name);await fileSystemStorage.saveAttachment(r,e)}};u=P([n.injectable(),v(0,n.inject("Logger"))],u);class w{constructor(e){var r,a;this.logger=e.get("Logger"),this.logger.setModule("electron.storage.components.componentsInit"),(r=this.logger)==null||r.debug("Init Sample Module components begin"),e.bind("WikiConfig").to(m).whenNamed("FileSystem"),e.bind("Storage").to(u).whenNamed("FileSystem"),(a=this.logger)==null||a.debug("Init Sample Module components end")}}i.ComponentInit=w,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
|
|
2
2
|
//# sourceMappingURL=index.umd.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../../src/components/FileSystemConfig.ts","../../src/components/fileSystemStorage.ts","../../src/componentsInit.ts"],"sourcesContent":["/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { DefaultWikiConfig } from \"@xwiki/cristal-api\";\nimport { inject, injectable, named } from \"inversify\";\nimport type { CristalApp, Logger, Storage } from \"@xwiki/cristal-api\";\n\n@injectable()\nexport class FileSystemConfig extends DefaultWikiConfig {\n override storage: Storage;\n override cristal: CristalApp;\n constructor(\n @inject<Logger>(\"Logger\") logger: Logger,\n @inject(\"Storage\") @named(\"FileSystem\") storage: Storage,\n @inject(\"CristalApp\") cristal: CristalApp,\n ) {\n super(logger);\n this.storage = storage;\n this.cristal = cristal;\n this.storage.setWikiConfig(this);\n if (this.homePage === \"\") {\n this.homePage = \"index.md\";\n }\n }\n\n override getType(): string {\n return \"FileSystem\";\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport {\n AttachmentsData,\n DefaultPageData,\n PageAttachment,\n PageData,\n} from \"@xwiki/cristal-api\";\nimport { AbstractStorage } from \"@xwiki/cristal-backend-api\";\nimport { inject, injectable } from \"inversify\";\nimport type { Logger } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport default class FileSystemStorage extends AbstractStorage {\n constructor(@inject<Logger>(\"Logger\") logger: Logger) {\n super(logger, \"storage.components.fileSystemStorage\");\n }\n\n getEditField(): Promise<string> {\n return Promise.resolve(\"\");\n }\n\n getImageURL(): string {\n return \"\";\n }\n\n async getPageContent(page: string): Promise<PageData> {\n const decodedPage = decodeURI(page);\n const path = await fileSystemStorage.resolvePath(decodedPage);\n const pageData = await fileSystemStorage.readPage(path || \"\");\n if (pageData) {\n pageData.id = decodedPage;\n pageData.headline = pageData.name;\n pageData.headlineRaw = pageData.name;\n }\n return pageData;\n }\n\n async getAttachments(page: string): Promise<AttachmentsData | undefined> {\n const path = await fileSystemStorage.resolveAttachmentsPath(page);\n return {\n attachments: await fileSystemStorage.readAttachments(path),\n };\n }\n\n async getAttachment(\n page: string,\n name: string,\n ): Promise<PageAttachment | undefined> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, name);\n return fileSystemStorage.readAttachment(path);\n }\n\n getPageFromViewURL(): string | null {\n return null;\n }\n\n getPageRestURL(): string {\n return \"\";\n }\n\n getPanelContent(): Promise<PageData> {\n return Promise.resolve(new DefaultPageData());\n }\n\n isStorageReady(): Promise<boolean> {\n return Promise.resolve(true);\n }\n\n async save(page: string, content: string, title: string): Promise<void> {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.savePage(path, content, title);\n }\n\n async saveAttachments(page: string, files: File[]): Promise<unknown> {\n return Promise.all(files.map((file) => this.saveAttachment(page, file)));\n }\n\n async delete(page: string): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.deletePage(path);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n async move(\n page: string,\n newPage: string,\n preserveChildren: boolean,\n ): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n const newPath = await fileSystemStorage.resolvePath(newPage);\n await fileSystemStorage.movePage(path, newPath, preserveChildren);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n private async saveAttachment(page: string, file: File): Promise<unknown> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, file.name);\n await fileSystemStorage.saveAttachment(path, file);\n return;\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { FileSystemConfig } from \"./components/FileSystemConfig\";\nimport FileSystemStorage from \"./components/fileSystemStorage\";\nimport type { Logger, Storage, WikiConfig } from \"@xwiki/cristal-api\";\nimport type { Container } from \"inversify\";\n\nexport default class ComponentInit {\n logger: Logger;\n\n constructor(container: Container) {\n this.logger = container.get<Logger>(\"Logger\");\n this.logger.setModule(\"electron.storage.components.componentsInit\");\n\n this.logger?.debug(\"Init Sample Module components begin\");\n container\n .bind<WikiConfig>(\"WikiConfig\")\n .to(FileSystemConfig)\n .whenTargetNamed(\"FileSystem\");\n container\n .bind<Storage>(\"Storage\")\n .to(FileSystemStorage)\n .whenTargetNamed(\"FileSystem\");\n this.logger?.debug(\"Init Sample Module components end\");\n }\n}\n"],"names":["FileSystemConfig","DefaultWikiConfig","logger","storage","cristal","__decorateClass","injectable","__decorateParam","FileSystemStorage","AbstractStorage","page","decodedPage","path","pageData","name","DefaultPageData","content","title","files","file","error","newPage","preserveChildren","newPath","ComponentInit","container","_a","_b"],"mappings":"0oBAyBa,IAAAA,EAAN,cAA+BC,EAAAA,iBAAkB,CAGtD,YAC4BC,EACcC,EAClBC,EACtB,CACA,MAAMF,CAAM,EACZ,KAAK,QAAUC,EACf,KAAK,QAAUC,EACV,KAAA,QAAQ,cAAc,IAAI,EAC3B,KAAK,WAAa,KACpB,KAAK,SAAW,WAClB,CAGO,SAAkB,CAClB,MAAA,YAAA,CAEX,EApBaJ,EAANK,EAAA,CADNC,aAAW,EAKPC,aAAe,QAAQ,CAAA,EACvBA,aAAO,SAAS,CAAA,EAAGA,YAAM,YAAY,CAAA,EACrCA,aAAO,YAAY,CAAA,CAAA,EANXP,CAAA,2NCSb,IAAqBQ,EAArB,cAA+CC,EAAAA,eAAgB,CAC7D,YAAsCP,EAAgB,CACpD,MAAMA,EAAQ,sCAAsC,CAAA,CAGtD,cAAgC,CACvB,OAAA,QAAQ,QAAQ,EAAE,CAAA,CAG3B,aAAsB,CACb,MAAA,EAAA,CAGT,MAAM,eAAeQ,EAAiC,CAC9C,MAAAC,EAAc,UAAUD,CAAI,EAC5BE,EAAO,MAAM,kBAAkB,YAAYD,CAAW,EACtDE,EAAW,MAAM,kBAAkB,SAASD,GAAQ,EAAE,EAC5D,OAAIC,IACFA,EAAS,GAAKF,EACdE,EAAS,SAAWA,EAAS,KAC7BA,EAAS,YAAcA,EAAS,MAE3BA,CAAA,CAGT,MAAM,eAAeH,EAAoD,CACvE,MAAME,EAAO,MAAM,kBAAkB,uBAAuBF,CAAI,EACzD,MAAA,CACL,YAAa,MAAM,kBAAkB,gBAAgBE,CAAI,CAC3D,CAAA,CAGF,MAAM,cACJF,EACAI,EACqC,CACrC,MAAMF,EAAO,MAAM,kBAAkB,sBAAsBF,EAAMI,CAAI,EAC9D,OAAA,kBAAkB,eAAe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B,CAAc,CAGjC,YAAYC,EAAsB,SAC3B,KAAA,OAASA,EAAU,IAAY,QAAQ,EACvC,KAAA,OAAO,UAAU,4CAA4C,GAE7DC,EAAA,KAAA,SAAA,MAAAA,EAAQ,MAAM,uCACnBD,EACG,KAAiB,YAAY,EAC7B,GAAGzB,CAAgB,EACnB,gBAAgB,YAAY,EAC/ByB,EACG,KAAc,SAAS,EACvB,GAAGjB,CAAiB,EACpB,gBAAgB,YAAY,GAC1BmB,EAAA,KAAA,SAAA,MAAAA,EAAQ,MAAM,oCAAmC,CAE1D"}
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../../src/components/FileSystemConfig.ts","../../src/components/fileSystemStorage.ts","../../src/componentsInit.ts"],"sourcesContent":["/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport { DefaultWikiConfig } from \"@xwiki/cristal-api\";\nimport { inject, injectable, named } from \"inversify\";\nimport type { CristalApp, Logger, Storage } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport class FileSystemConfig extends DefaultWikiConfig {\n override storage: Storage;\n override cristal: CristalApp;\n constructor(\n @inject(\"Logger\") logger: Logger,\n @inject(\"Storage\") @named(\"FileSystem\") storage: Storage,\n @inject(\"CristalApp\") cristal: CristalApp,\n ) {\n super(logger);\n this.storage = storage;\n this.cristal = cristal;\n this.storage.setWikiConfig(this);\n if (this.homePage === \"\") {\n this.homePage = \"index.md\";\n }\n }\n\n override getType(): string {\n return \"FileSystem\";\n }\n\n override initialize(): void {\n super.initialize();\n // The initialization for the root directory needs to be done after a\n // configuration change, but before any storage operation.\n fileSystemStorage.initRootDirectory();\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport {\n AttachmentsData,\n DefaultPageData,\n PageAttachment,\n PageData,\n} from \"@xwiki/cristal-api\";\nimport { AbstractStorage } from \"@xwiki/cristal-backend-api\";\nimport { inject, injectable } from \"inversify\";\nimport type { Logger } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport default class FileSystemStorage extends AbstractStorage {\n constructor(@inject(\"Logger\") logger: Logger) {\n super(logger, \"storage.components.fileSystemStorage\");\n }\n\n getEditField(): Promise<string> {\n return Promise.resolve(\"\");\n }\n\n getImageURL(): string {\n return \"\";\n }\n\n async getPageContent(page: string): Promise<PageData> {\n const decodedPage = decodeURI(page);\n const path = await fileSystemStorage.resolvePath(decodedPage);\n const pageData = await fileSystemStorage.readPage(path || \"\");\n if (pageData) {\n pageData.id = decodedPage;\n pageData.headline = pageData.name;\n pageData.headlineRaw = pageData.name;\n }\n return pageData;\n }\n\n async getAttachments(page: string): Promise<AttachmentsData | undefined> {\n const path = await fileSystemStorage.resolveAttachmentsPath(page);\n return {\n attachments: await fileSystemStorage.readAttachments(path),\n };\n }\n\n async getAttachment(\n page: string,\n name: string,\n ): Promise<PageAttachment | undefined> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, name);\n return fileSystemStorage.readAttachment(path);\n }\n\n getPageFromViewURL(): string | null {\n return null;\n }\n\n getPageRestURL(): string {\n return \"\";\n }\n\n getPanelContent(): Promise<PageData> {\n return Promise.resolve(new DefaultPageData());\n }\n\n isStorageReady(): Promise<boolean> {\n return Promise.resolve(true);\n }\n\n async save(page: string, content: string, title: string): Promise<void> {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.savePage(path, content, title);\n }\n\n async saveAttachments(page: string, files: File[]): Promise<unknown> {\n return Promise.all(files.map((file) => this.saveAttachment(page, file)));\n }\n\n async delete(page: string): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.deletePage(path);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n async move(\n page: string,\n newPage: string,\n preserveChildren: boolean,\n ): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n const newPath = await fileSystemStorage.resolvePath(newPage);\n await fileSystemStorage.movePage(path, newPath, preserveChildren);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n private async saveAttachment(page: string, file: File): Promise<unknown> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, file.name);\n await fileSystemStorage.saveAttachment(path, file);\n return;\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { FileSystemConfig } from \"./components/FileSystemConfig\";\nimport FileSystemStorage from \"./components/fileSystemStorage\";\nimport type { Logger, Storage, WikiConfig } from \"@xwiki/cristal-api\";\nimport type { Container } from \"inversify\";\n\nexport default class ComponentInit {\n logger: Logger;\n\n constructor(container: Container) {\n this.logger = container.get<Logger>(\"Logger\");\n this.logger.setModule(\"electron.storage.components.componentsInit\");\n\n this.logger?.debug(\"Init Sample Module components begin\");\n container\n .bind<WikiConfig>(\"WikiConfig\")\n .to(FileSystemConfig)\n .whenNamed(\"FileSystem\");\n container\n .bind<Storage>(\"Storage\")\n .to(FileSystemStorage)\n .whenNamed(\"FileSystem\");\n this.logger?.debug(\"Init Sample Module components end\");\n }\n}\n"],"names":["FileSystemConfig","DefaultWikiConfig","logger","storage","cristal","__decorateClass","injectable","__decorateParam","FileSystemStorage","AbstractStorage","page","decodedPage","path","pageData","name","DefaultPageData","content","title","files","file","error","newPage","preserveChildren","newPath","ComponentInit","container","_a","_b"],"mappings":"0oBA4Ba,IAAAA,EAAN,cAA+BC,EAAAA,iBAAkB,CAGtD,YACoBC,EACsBC,EAClBC,EACtB,CACA,MAAMF,CAAM,EACZ,KAAK,QAAUC,EACf,KAAK,QAAUC,EACV,KAAA,QAAQ,cAAc,IAAI,EAC3B,KAAK,WAAa,KACpB,KAAK,SAAW,WAClB,CAGO,SAAkB,CAClB,MAAA,YAAA,CAGA,YAAmB,CAC1B,MAAM,WAAW,EAGjB,kBAAkB,kBAAkB,CAAA,CAExC,EA3BaJ,EAANK,EAAA,CADNC,aAAW,EAKPC,aAAO,QAAQ,CAAA,EACfA,aAAO,SAAS,CAAA,EAAGA,Y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AGzE,MAAM,OAAOT,EAA6D,CACpE,GAAA,CACF,MAAME,EAAO,MAAM,kBAAkB,YAAYF,CAAI,EAC/C,aAAA,kBAAkB,WAAWE,CAAI,EAChC,CAAE,QAAS,EAAK,QAChBQ,EAAO,CACd,MAAO,CAAE,QAAS,GAAO,MAAQA,EAAgB,OAAQ,CAAA,CAC3D,CAGF,MAAM,KACJV,EACAW,EACAC,EAC+C,CAC3C,GAAA,CACF,MAAMV,EAAO,MAAM,kBAAkB,YAAYF,CAAI,EAC/Ca,EAAU,MAAM,kBAAkB,YAAYF,CAAO,EAC3D,aAAM,kBAAkB,SAAST,EAAMW,EAASD,CAAgB,EACzD,CAAE,QAAS,EAAK,QAChBF,EAAO,CACd,MAAO,CAAE,QAAS,GAAO,MAAQA,EAAgB,OAAQ,CAAA,CAC3D,CAGF,MAAc,eAAeV,EAAcS,EAA8B,CACvE,MAAMP,EAAO,MAAM,kBAAkB,sBAAsBF,EAAMS,EAAK,IAAI,EACpE,MAAA,kBAAkB,eAAeP,EAAMO,CAAI,CACjD,CAEJ,EA/FqBX,EAArBH,EAAA,CADCC,aAAW,EAEGC,aAAO,QAAQ,CAAA,CAAA,EADTC,CAAA,ECTrB,MAAqBgB,CAAc,CAGjC,YAAYC,EAAsB,SAC3B,KAAA,OAASA,EAAU,IAAY,QAAQ,EACvC,KAAA,OAAO,UAAU,4CAA4C,GAE7DC,EAAA,KAAA,SAAA,MAAAA,EAAQ,MAAM,uCACnBD,EACG,KAAiB,YAAY,EAC7B,GAAGzB,CAAgB,EACnB,UAAU,YAAY,EACzByB,EACG,KAAc,SAAS,EACvB,GAAGjB,CAAiB,EACpB,UAAU,YAAY,GACpBmB,EAAA,KAAA,SAAA,MAAAA,EAAQ,MAAM,oCAAmC,CAE1D"}
|
|
@@ -2,6 +2,7 @@ import { PageAttachment, PageData } from '@xwiki/cristal-api';
|
|
|
2
2
|
import { LinkType } from '@xwiki/cristal-link-suggest-api';
|
|
3
3
|
import { EntityType } from '@xwiki/cristal-model-api';
|
|
4
4
|
export interface APITypes {
|
|
5
|
+
initRootDirectory(): void;
|
|
5
6
|
resolvePath(page: string): Promise<string>;
|
|
6
7
|
resolveAttachmentsPath(page: string): Promise<string>;
|
|
7
8
|
resolveAttachmentPath(page: string, filename: string): Promise<string>;
|
package/dist/preload/index.es.js
CHANGED
|
@@ -1,30 +1,33 @@
|
|
|
1
1
|
import { DefaultWikiConfig as h, DefaultPageData as S } from "@xwiki/cristal-api";
|
|
2
|
-
import { injectable as c, inject as
|
|
2
|
+
import { injectable as c, inject as l, named as u } from "inversify";
|
|
3
3
|
import { AbstractStorage as f } from "@xwiki/cristal-backend-api";
|
|
4
|
-
var p = Object.defineProperty,
|
|
5
|
-
for (var s = a > 1 ? void 0 : a ?
|
|
4
|
+
var p = Object.defineProperty, y = Object.getOwnPropertyDescriptor, P = (t, e, r, a) => {
|
|
5
|
+
for (var s = a > 1 ? void 0 : a ? y(e, r) : e, o = t.length - 1, n; o >= 0; o--)
|
|
6
6
|
(n = t[o]) && (s = (a ? n(e, r, s) : n(s)) || s);
|
|
7
7
|
return a && s && p(e, r, s), s;
|
|
8
8
|
}, i = (t, e) => (r, a) => e(r, a, t);
|
|
9
|
-
let
|
|
9
|
+
let g = class extends h {
|
|
10
10
|
constructor(t, e, r) {
|
|
11
11
|
super(t), this.storage = e, this.cristal = r, this.storage.setWikiConfig(this), this.homePage === "" && (this.homePage = "index.md");
|
|
12
12
|
}
|
|
13
13
|
getType() {
|
|
14
14
|
return "FileSystem";
|
|
15
15
|
}
|
|
16
|
+
initialize() {
|
|
17
|
+
super.initialize(), fileSystemStorage.initRootDirectory();
|
|
18
|
+
}
|
|
16
19
|
};
|
|
17
|
-
|
|
20
|
+
g = P([
|
|
18
21
|
c(),
|
|
19
|
-
i(0,
|
|
20
|
-
i(1,
|
|
22
|
+
i(0, l("Logger")),
|
|
23
|
+
i(1, l("Storage")),
|
|
21
24
|
i(1, u("FileSystem")),
|
|
22
|
-
i(2,
|
|
23
|
-
],
|
|
24
|
-
var
|
|
25
|
-
for (var s = a > 1 ? void 0 : a ?
|
|
25
|
+
i(2, l("CristalApp"))
|
|
26
|
+
], g);
|
|
27
|
+
var d = Object.defineProperty, v = Object.getOwnPropertyDescriptor, w = (t, e, r, a) => {
|
|
28
|
+
for (var s = a > 1 ? void 0 : a ? v(e, r) : e, o = t.length - 1, n; o >= 0; o--)
|
|
26
29
|
(n = t[o]) && (s = (a ? n(e, r, s) : n(s)) || s);
|
|
27
|
-
return a && s &&
|
|
30
|
+
return a && s && d(e, r, s), s;
|
|
28
31
|
}, _ = (t, e) => (r, a) => e(r, a, t);
|
|
29
32
|
let m = class extends f {
|
|
30
33
|
constructor(t) {
|
|
@@ -92,12 +95,12 @@ let m = class extends f {
|
|
|
92
95
|
};
|
|
93
96
|
m = w([
|
|
94
97
|
c(),
|
|
95
|
-
_(0,
|
|
98
|
+
_(0, l("Logger"))
|
|
96
99
|
], m);
|
|
97
100
|
class D {
|
|
98
101
|
constructor(e) {
|
|
99
102
|
var r, a;
|
|
100
|
-
this.logger = e.get("Logger"), this.logger.setModule("electron.storage.components.componentsInit"), (r = this.logger) == null || r.debug("Init Sample Module components begin"), e.bind("WikiConfig").to(
|
|
103
|
+
this.logger = e.get("Logger"), this.logger.setModule("electron.storage.components.componentsInit"), (r = this.logger) == null || r.debug("Init Sample Module components begin"), e.bind("WikiConfig").to(g).whenNamed("FileSystem"), e.bind("Storage").to(m).whenNamed("FileSystem"), (a = this.logger) == null || a.debug("Init Sample Module components end");
|
|
101
104
|
}
|
|
102
105
|
}
|
|
103
106
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../../src/components/FileSystemConfig.ts","../../src/components/fileSystemStorage.ts","../../src/componentsInit.ts"],"sourcesContent":["/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { DefaultWikiConfig } from \"@xwiki/cristal-api\";\nimport { inject, injectable, named } from \"inversify\";\nimport type { CristalApp, Logger, Storage } from \"@xwiki/cristal-api\";\n\n@injectable()\nexport class FileSystemConfig extends DefaultWikiConfig {\n override storage: Storage;\n override cristal: CristalApp;\n constructor(\n @inject<Logger>(\"Logger\") logger: Logger,\n @inject(\"Storage\") @named(\"FileSystem\") storage: Storage,\n @inject(\"CristalApp\") cristal: CristalApp,\n ) {\n super(logger);\n this.storage = storage;\n this.cristal = cristal;\n this.storage.setWikiConfig(this);\n if (this.homePage === \"\") {\n this.homePage = \"index.md\";\n }\n }\n\n override getType(): string {\n return \"FileSystem\";\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport {\n AttachmentsData,\n DefaultPageData,\n PageAttachment,\n PageData,\n} from \"@xwiki/cristal-api\";\nimport { AbstractStorage } from \"@xwiki/cristal-backend-api\";\nimport { inject, injectable } from \"inversify\";\nimport type { Logger } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport default class FileSystemStorage extends AbstractStorage {\n constructor(@inject<Logger>(\"Logger\") logger: Logger) {\n super(logger, \"storage.components.fileSystemStorage\");\n }\n\n getEditField(): Promise<string> {\n return Promise.resolve(\"\");\n }\n\n getImageURL(): string {\n return \"\";\n }\n\n async getPageContent(page: string): Promise<PageData> {\n const decodedPage = decodeURI(page);\n const path = await fileSystemStorage.resolvePath(decodedPage);\n const pageData = await fileSystemStorage.readPage(path || \"\");\n if (pageData) {\n pageData.id = decodedPage;\n pageData.headline = pageData.name;\n pageData.headlineRaw = pageData.name;\n }\n return pageData;\n }\n\n async getAttachments(page: string): Promise<AttachmentsData | undefined> {\n const path = await fileSystemStorage.resolveAttachmentsPath(page);\n return {\n attachments: await fileSystemStorage.readAttachments(path),\n };\n }\n\n async getAttachment(\n page: string,\n name: string,\n ): Promise<PageAttachment | undefined> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, name);\n return fileSystemStorage.readAttachment(path);\n }\n\n getPageFromViewURL(): string | null {\n return null;\n }\n\n getPageRestURL(): string {\n return \"\";\n }\n\n getPanelContent(): Promise<PageData> {\n return Promise.resolve(new DefaultPageData());\n }\n\n isStorageReady(): Promise<boolean> {\n return Promise.resolve(true);\n }\n\n async save(page: string, content: string, title: string): Promise<void> {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.savePage(path, content, title);\n }\n\n async saveAttachments(page: string, files: File[]): Promise<unknown> {\n return Promise.all(files.map((file) => this.saveAttachment(page, file)));\n }\n\n async delete(page: string): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.deletePage(path);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n async move(\n page: string,\n newPage: string,\n preserveChildren: boolean,\n ): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n const newPath = await fileSystemStorage.resolvePath(newPage);\n await fileSystemStorage.movePage(path, newPath, preserveChildren);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n private async saveAttachment(page: string, file: File): Promise<unknown> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, file.name);\n await fileSystemStorage.saveAttachment(path, file);\n return;\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { FileSystemConfig } from \"./components/FileSystemConfig\";\nimport FileSystemStorage from \"./components/fileSystemStorage\";\nimport type { Logger, Storage, WikiConfig } from \"@xwiki/cristal-api\";\nimport type { Container } from \"inversify\";\n\nexport default class ComponentInit {\n logger: Logger;\n\n constructor(container: Container) {\n this.logger = container.get<Logger>(\"Logger\");\n this.logger.setModule(\"electron.storage.components.componentsInit\");\n\n this.logger?.debug(\"Init Sample Module components begin\");\n container\n .bind<WikiConfig>(\"WikiConfig\")\n .to(FileSystemConfig)\n .whenTargetNamed(\"FileSystem\");\n container\n .bind<Storage>(\"Storage\")\n .to(FileSystemStorage)\n .whenTargetNamed(\"FileSystem\");\n this.logger?.debug(\"Init Sample Module components end\");\n }\n}\n"],"names":["FileSystemConfig","DefaultWikiConfig","logger","storage","cristal","__decorateClass","injectable","__decorateParam","FileSystemStorage","AbstractStorage","page","decodedPage","path","pageData","name","DefaultPageData","content","title","files","file","error","newPage","preserveChildren","newPath","ComponentInit","container","_a","_b"],"mappings":";;;;;;;;AAyBa,IAAAA,IAAN,cAA+BC,EAAkB;AAAA,EAGtD,YAC4BC,GACcC,GAClBC,GACtB;AACA,UAAMF,CAAM,GACZ,KAAK,UAAUC,GACf,KAAK,UAAUC,GACV,KAAA,QAAQ,cAAc,IAAI,GAC3B,KAAK,aAAa,OACpB,KAAK,WAAW;AAAA,EAClB;AAAA,EAGO,UAAkB;AAClB,WAAA;AAAA,EAAA;AAEX;AApBaJ,IAANK,EAAA;AAAA,EADNC,EAAW;AAAA,EAKPC,OAAe,QAAQ,CAAA;AAAA,EACvBA,OAAO,SAAS,CAAA;AAAA,EAAGA,OAAM,YAAY,CAAA;AAAA,EACrCA,OAAO,YAAY,CAAA;AAAA,GANXP,CAAA;;;;;;ACSb,IAAqBQ,IAArB,cAA+CC,EAAgB;AAAA,EAC7D,YAAsCP,GAAgB;AACpD,UAAMA,GAAQ,sCAAsC;AAAA,EAAA;AAAA,EAGtD,eAAgC;AACvB,WAAA,QAAQ,QAAQ,EAAE;AAAA,EAAA;AAAA,EAG3B,cAAsB;AACb,WAAA;AAAA,EAAA;AAAA,EAGT,MAAM,eAAeQ,GAAiC;AAC9C,UAAAC,IAAc,UAAUD,CAAI,GAC5BE,IAAO,MAAM,kBAAkB,YAAYD,CAAW,GACtDE,IAAW,MAAM,kBAAkB,SAASD,KAAQ,EAAE;AAC5D,WAAIC,MACFA,EAAS,KAAKF,GACdE,EAAS,WAAWA,EAAS,MAC7BA,EAAS,cAAcA,EAAS,OAE3BA;AAAA,EAAA;AAAA,EAGT,MAAM,eAAeH,GAAoD;AACvE,UAAME,IAAO,MAAM,kBAAkB,uBAAuBF,CAAI;AACzD,WAAA;AAAA,MACL,aAAa,MAAM,kBAAkB,gBAAgBE,CAAI;AAAA,IAC3D;AAAA,EAAA;AAAA,EAGF,MAA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c,eAAeV,GAAcS,GAA8B;AACvE,UAAMP,IAAO,MAAM,kBAAkB,sBAAsBF,GAAMS,EAAK,IAAI;AACpE,UAAA,kBAAkB,eAAeP,GAAMO,CAAI;AAAA,EACjD;AAEJ;AA/FqBX,IAArBH,EAAA;AAAA,EADCC,EAAW;AAAA,EAEGC,OAAe,QAAQ,CAAA;AAAA,GADjBC,CAAA;ACTrB,MAAqBgB,EAAc;AAAA,EAGjC,YAAYC,GAAsB;;AAC3B,SAAA,SAASA,EAAU,IAAY,QAAQ,GACvC,KAAA,OAAO,UAAU,4CAA4C,IAE7DC,IAAA,KAAA,WAAA,QAAAA,EAAQ,MAAM,wCACnBD,EACG,KAAiB,YAAY,EAC7B,GAAGzB,CAAgB,EACnB,gBAAgB,YAAY,GAC/ByB,EACG,KAAc,SAAS,EACvB,GAAGjB,CAAiB,EACpB,gBAAgB,YAAY,IAC1BmB,IAAA,KAAA,WAAA,QAAAA,EAAQ,MAAM;AAAA,EAAmC;AAE1D;"}
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../../src/components/FileSystemConfig.ts","../../src/components/fileSystemStorage.ts","../../src/componentsInit.ts"],"sourcesContent":["/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport { DefaultWikiConfig } from \"@xwiki/cristal-api\";\nimport { inject, injectable, named } from \"inversify\";\nimport type { CristalApp, Logger, Storage } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport class FileSystemConfig extends DefaultWikiConfig {\n override storage: Storage;\n override cristal: CristalApp;\n constructor(\n @inject(\"Logger\") logger: Logger,\n @inject(\"Storage\") @named(\"FileSystem\") storage: Storage,\n @inject(\"CristalApp\") cristal: CristalApp,\n ) {\n super(logger);\n this.storage = storage;\n this.cristal = cristal;\n this.storage.setWikiConfig(this);\n if (this.homePage === \"\") {\n this.homePage = \"index.md\";\n }\n }\n\n override getType(): string {\n return \"FileSystem\";\n }\n\n override initialize(): void {\n super.initialize();\n // The initialization for the root directory needs to be done after a\n // configuration change, but before any storage operation.\n fileSystemStorage.initRootDirectory();\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport {\n AttachmentsData,\n DefaultPageData,\n PageAttachment,\n PageData,\n} from \"@xwiki/cristal-api\";\nimport { AbstractStorage } from \"@xwiki/cristal-backend-api\";\nimport { inject, injectable } from \"inversify\";\nimport type { Logger } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport default class FileSystemStorage extends AbstractStorage {\n constructor(@inject(\"Logger\") logger: Logger) {\n super(logger, \"storage.components.fileSystemStorage\");\n }\n\n getEditField(): Promise<string> {\n return Promise.resolve(\"\");\n }\n\n getImageURL(): string {\n return \"\";\n }\n\n async getPageContent(page: string): Promise<PageData> {\n const decodedPage = decodeURI(page);\n const path = await fileSystemStorage.resolvePath(decodedPage);\n const pageData = await fileSystemStorage.readPage(path || \"\");\n if (pageData) {\n pageData.id = decodedPage;\n pageData.headline = pageData.name;\n pageData.headlineRaw = pageData.name;\n }\n return pageData;\n }\n\n async getAttachments(page: string): Promise<AttachmentsData | undefined> {\n const path = await fileSystemStorage.resolveAttachmentsPath(page);\n return {\n attachments: await fileSystemStorage.readAttachments(path),\n };\n }\n\n async getAttachment(\n page: string,\n name: string,\n ): Promise<PageAttachment | undefined> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, name);\n return fileSystemStorage.readAttachment(path);\n }\n\n getPageFromViewURL(): string | null {\n return null;\n }\n\n getPageRestURL(): string {\n return \"\";\n }\n\n getPanelContent(): Promise<PageData> {\n return Promise.resolve(new DefaultPageData());\n }\n\n isStorageReady(): Promise<boolean> {\n return Promise.resolve(true);\n }\n\n async save(page: string, content: string, title: string): Promise<void> {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.savePage(path, content, title);\n }\n\n async saveAttachments(page: string, files: File[]): Promise<unknown> {\n return Promise.all(files.map((file) => this.saveAttachment(page, file)));\n }\n\n async delete(page: string): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.deletePage(path);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n async move(\n page: string,\n newPage: string,\n preserveChildren: boolean,\n ): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n const newPath = await fileSystemStorage.resolvePath(newPage);\n await fileSystemStorage.movePage(path, newPath, preserveChildren);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n private async saveAttachment(page: string, file: File): Promise<unknown> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, file.name);\n await fileSystemStorage.saveAttachment(path, file);\n return;\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { FileSystemConfig } from \"./components/FileSystemConfig\";\nimport FileSystemStorage from \"./components/fileSystemStorage\";\nimport type { Logger, Storage, WikiConfig } from \"@xwiki/cristal-api\";\nimport type { Container } from \"inversify\";\n\nexport default class ComponentInit {\n logger: Logger;\n\n constructor(container: Container) {\n this.logger = container.get<Logger>(\"Logger\");\n this.logger.setModule(\"electron.storage.components.componentsInit\");\n\n this.logger?.debug(\"Init Sample Module components begin\");\n container\n .bind<WikiConfig>(\"WikiConfig\")\n .to(FileSystemConfig)\n .whenNamed(\"FileSystem\");\n container\n .bind<Storage>(\"Storage\")\n .to(FileSystemStorage)\n .whenNamed(\"FileSystem\");\n this.logger?.debug(\"Init Sample Module components end\");\n }\n}\n"],"names":["FileSystemConfig","DefaultWikiConfig","logger","storage","cristal","__decorateClass","injectable","__decorateParam","FileSystemStorage","AbstractStorage","page","decodedPage","path","pageData","name","DefaultPageData","content","title","files","file","error","newPage","preserveChildren","newPath","ComponentInit","container","_a","_b"],"mappings":";;;;;;;;AA4Ba,IAAAA,IAAN,cAA+BC,EAAkB;AAAA,EAGtD,YACoBC,GACsBC,GAClBC,GACtB;AACA,UAAMF,CAAM,GACZ,KAAK,UAAUC,GACf,KAAK,UAA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EADCC,EAAW;AAAA,EAEGC,OAAO,QAAQ,CAAA;AAAA,GADTC,CAAA;ACTrB,MAAqBgB,EAAc;AAAA,EAGjC,YAAYC,GAAsB;;AAC3B,SAAA,SAASA,EAAU,IAAY,QAAQ,GACvC,KAAA,OAAO,UAAU,4CAA4C,IAE7DC,IAAA,KAAA,WAAA,QAAAA,EAAQ,MAAM,wCACnBD,EACG,KAAiB,YAAY,EAC7B,GAAGzB,CAAgB,EACnB,UAAU,YAAY,GACzByB,EACG,KAAc,SAAS,EACvB,GAAGjB,CAAiB,EACpB,UAAU,YAAY,IACpBmB,IAAA,KAAA,WAAA,QAAAA,EAAQ,MAAM;AAAA,EAAmC;AAE1D;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(i,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("@xwiki/cristal-api"),require("inversify"),require("@xwiki/cristal-backend-api")):typeof define=="function"&&define.amd?define(["exports","@xwiki/cristal-api","inversify","@xwiki/cristal-backend-api"],l):(i=typeof globalThis<"u"?globalThis:i||self,l(i.cristal_storage={},i.cristalApi,i.inversify,i.cristalBackendApi))})(this,function(i,l,n,h){"use strict";var S=Object.defineProperty,f=Object.getOwnPropertyDescriptor,p=(t,e,r,a)=>{for(var s=a>1?void 0:a?f(e,r):e,o=t.length-1,c;o>=0;o--)(c=t[o])&&(s=(a?c(e,r,s):c(s))||s);return a&&s&&S(e,r,s),s},g=(t,e)=>(r,a)=>e(r,a,t);let m=class extends l.DefaultWikiConfig{constructor(t,e,r){super(t),this.storage=e,this.cristal=r,this.storage.setWikiConfig(this),this.homePage===""&&(this.homePage="index.md")}getType(){return"FileSystem"}initialize(){super.initialize(),fileSystemStorage.initRootDirectory()}};m=p([n.injectable(),g(0,n.inject("Logger")),g(1,n.inject("Storage")),g(1,n.named("FileSystem")),g(2,n.inject("CristalApp"))],m);var d=Object.defineProperty,y=Object.getOwnPropertyDescriptor,P=(t,e,r,a)=>{for(var s=a>1?void 0:a?y(e,r):e,o=t.length-1,c;o>=0;o--)(c=t[o])&&(s=(a?c(e,r,s):c(s))||s);return a&&s&&d(e,r,s),s},v=(t,e)=>(r,a)=>e(r,a,t);let u=class extends h.AbstractStorage{constructor(t){super(t,"storage.components.fileSystemStorage")}getEditField(){return Promise.resolve("")}getImageURL(){return""}async getPageContent(t){const e=decodeURI(t),r=await fileSystemStorage.resolvePath(e),a=await fileSystemStorage.readPage(r||"");return a&&(a.id=e,a.headline=a.name,a.headlineRaw=a.name),a}async getAttachments(t){const e=await fileSystemStorage.resolveAttachmentsPath(t);return{attachments:await fileSystemStorage.readAttachments(e)}}async getAttachment(t,e){const r=await fileSystemStorage.resolveAttachmentPath(t,e);return fileSystemStorage.readAttachment(r)}getPageFromViewURL(){return null}getPageRestURL(){return""}getPanelContent(){return Promise.resolve(new l.DefaultPageData)}isStorageReady(){return Promise.resolve(!0)}async save(t,e,r){const a=await fileSystemStorage.resolvePath(t);await fileSystemStorage.savePage(a,e,r)}async saveAttachments(t,e){return Promise.all(e.map(r=>this.saveAttachment(t,r)))}async delete(t){try{const e=await fileSystemStorage.resolvePath(t);return await fileSystemStorage.deletePage(e),{success:!0}}catch(e){return{success:!1,error:e.message}}}async move(t,e,r){try{const a=await fileSystemStorage.resolvePath(t),s=await fileSystemStorage.resolvePath(e);return await fileSystemStorage.movePage(a,s,r),{success:!0}}catch(a){return{success:!1,error:a.message}}}async saveAttachment(t,e){const r=await fileSystemStorage.resolveAttachmentPath(t,e.name);await fileSystemStorage.saveAttachment(r,e)}};u=P([n.injectable(),v(0,n.inject("Logger"))],u);class w{constructor(e){var r,a;this.logger=e.get("Logger"),this.logger.setModule("electron.storage.components.componentsInit"),(r=this.logger)==null||r.debug("Init Sample Module components begin"),e.bind("WikiConfig").to(m).whenNamed("FileSystem"),e.bind("Storage").to(u).whenNamed("FileSystem"),(a=this.logger)==null||a.debug("Init Sample Module components end")}}i.ComponentInit=w,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
|
|
2
2
|
//# sourceMappingURL=index.umd.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../../src/components/FileSystemConfig.ts","../../src/components/fileSystemStorage.ts","../../src/componentsInit.ts"],"sourcesContent":["/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { DefaultWikiConfig } from \"@xwiki/cristal-api\";\nimport { inject, injectable, named } from \"inversify\";\nimport type { CristalApp, Logger, Storage } from \"@xwiki/cristal-api\";\n\n@injectable()\nexport class FileSystemConfig extends DefaultWikiConfig {\n override storage: Storage;\n override cristal: CristalApp;\n constructor(\n @inject<Logger>(\"Logger\") logger: Logger,\n @inject(\"Storage\") @named(\"FileSystem\") storage: Storage,\n @inject(\"CristalApp\") cristal: CristalApp,\n ) {\n super(logger);\n this.storage = storage;\n this.cristal = cristal;\n this.storage.setWikiConfig(this);\n if (this.homePage === \"\") {\n this.homePage = \"index.md\";\n }\n }\n\n override getType(): string {\n return \"FileSystem\";\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport {\n AttachmentsData,\n DefaultPageData,\n PageAttachment,\n PageData,\n} from \"@xwiki/cristal-api\";\nimport { AbstractStorage } from \"@xwiki/cristal-backend-api\";\nimport { inject, injectable } from \"inversify\";\nimport type { Logger } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport default class FileSystemStorage extends AbstractStorage {\n constructor(@inject<Logger>(\"Logger\") logger: Logger) {\n super(logger, \"storage.components.fileSystemStorage\");\n }\n\n getEditField(): Promise<string> {\n return Promise.resolve(\"\");\n }\n\n getImageURL(): string {\n return \"\";\n }\n\n async getPageContent(page: string): Promise<PageData> {\n const decodedPage = decodeURI(page);\n const path = await fileSystemStorage.resolvePath(decodedPage);\n const pageData = await fileSystemStorage.readPage(path || \"\");\n if (pageData) {\n pageData.id = decodedPage;\n pageData.headline = pageData.name;\n pageData.headlineRaw = pageData.name;\n }\n return pageData;\n }\n\n async getAttachments(page: string): Promise<AttachmentsData | undefined> {\n const path = await fileSystemStorage.resolveAttachmentsPath(page);\n return {\n attachments: await fileSystemStorage.readAttachments(path),\n };\n }\n\n async getAttachment(\n page: string,\n name: string,\n ): Promise<PageAttachment | undefined> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, name);\n return fileSystemStorage.readAttachment(path);\n }\n\n getPageFromViewURL(): string | null {\n return null;\n }\n\n getPageRestURL(): string {\n return \"\";\n }\n\n getPanelContent(): Promise<PageData> {\n return Promise.resolve(new DefaultPageData());\n }\n\n isStorageReady(): Promise<boolean> {\n return Promise.resolve(true);\n }\n\n async save(page: string, content: string, title: string): Promise<void> {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.savePage(path, content, title);\n }\n\n async saveAttachments(page: string, files: File[]): Promise<unknown> {\n return Promise.all(files.map((file) => this.saveAttachment(page, file)));\n }\n\n async delete(page: string): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.deletePage(path);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n async move(\n page: string,\n newPage: string,\n preserveChildren: boolean,\n ): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n const newPath = await fileSystemStorage.resolvePath(newPage);\n await fileSystemStorage.movePage(path, newPath, preserveChildren);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n private async saveAttachment(page: string, file: File): Promise<unknown> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, file.name);\n await fileSystemStorage.saveAttachment(path, file);\n return;\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { FileSystemConfig } from \"./components/FileSystemConfig\";\nimport FileSystemStorage from \"./components/fileSystemStorage\";\nimport type { Logger, Storage, WikiConfig } from \"@xwiki/cristal-api\";\nimport type { Container } from \"inversify\";\n\nexport default class ComponentInit {\n logger: Logger;\n\n constructor(container: Container) {\n this.logger = container.get<Logger>(\"Logger\");\n this.logger.setModule(\"electron.storage.components.componentsInit\");\n\n this.logger?.debug(\"Init Sample Module components begin\");\n container\n .bind<WikiConfig>(\"WikiConfig\")\n .to(FileSystemConfig)\n .whenTargetNamed(\"FileSystem\");\n container\n .bind<Storage>(\"Storage\")\n .to(FileSystemStorage)\n .whenTargetNamed(\"FileSystem\");\n this.logger?.debug(\"Init Sample Module components end\");\n }\n}\n"],"names":["FileSystemConfig","DefaultWikiConfig","logger","storage","cristal","__decorateClass","injectable","__decorateParam","FileSystemStorage","AbstractStorage","page","decodedPage","path","pageData","name","DefaultPageData","content","title","files","file","error","newPage","preserveChildren","newPath","ComponentInit","container","_a","_b"],"mappings":"0oBAyBa,IAAAA,EAAN,cAA+BC,EAAAA,iBAAkB,CAGtD,YAC4BC,EACcC,EAClBC,EACtB,CACA,MAAMF,CAAM,EACZ,KAAK,QAAUC,EACf,KAAK,QAAUC,EACV,KAAA,QAAQ,cAAc,IAAI,EAC3B,KAAK,WAAa,KACpB,KAAK,SAAW,WAClB,CAGO,SAAkB,CAClB,MAAA,YAAA,CAEX,EApBaJ,EAANK,EAAA,CADNC,aAAW,EAKPC,aAAe,QAAQ,CAAA,EACvBA,aAAO,SAAS,CAAA,EAAGA,YAAM,YAAY,CAAA,EACrCA,aAAO,YAAY,CAAA,CAAA,EANXP,CAAA,2NCSb,IAAqBQ,EAArB,cAA+CC,EAAAA,eAAgB,CAC7D,YAAsCP,EAAgB,CACpD,MAAMA,EAAQ,sCAAsC,CAAA,CAGtD,cAAgC,CACvB,OAAA,QAAQ,QAAQ,EAAE,CAAA,CAG3B,aAAsB,CACb,MAAA,EAAA,CAGT,MAAM,eAAeQ,EAAiC,CAC9C,MAAAC,EAAc,UAAUD,CAAI,EAC5BE,EAAO,MAAM,kBAAkB,YAAYD,CAAW,EACtDE,EAAW,MAAM,kBAAkB,SAASD,GAAQ,EAAE,EAC5D,OAAIC,IACFA,EAAS,GAAKF,EACdE,EAAS,SAAWA,EAAS,KAC7BA,EAAS,YAAcA,EAAS,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B,OAAQ,CAAA,CAC3D,CAGF,MAAc,eAAeV,EAAcS,EAA8B,CACvE,MAAMP,EAAO,MAAM,kBAAkB,sBAAsBF,EAAMS,EAAK,IAAI,EACpE,MAAA,kBAAkB,eAAeP,EAAMO,CAAI,CACjD,CAEJ,EA/FqBX,EAArBH,EAAA,CADCC,aAAW,EAEGC,aAAe,QAAQ,CAAA,CAAA,EADjBC,CAAA,ECTrB,MAAqBgB,CAAc,CAGjC,YAAYC,EAAsB,SAC3B,KAAA,OAASA,EAAU,IAAY,QAAQ,EACvC,KAAA,OAAO,UAAU,4CAA4C,GAE7DC,EAAA,KAAA,SAAA,MAAAA,EAAQ,MAAM,uCACnBD,EACG,KAAiB,YAAY,EAC7B,GAAGzB,CAAgB,EACnB,gBAAgB,YAAY,EAC/ByB,EACG,KAAc,SAAS,EACvB,GAAGjB,CAAiB,EACpB,gBAAgB,YAAY,GAC1BmB,EAAA,KAAA,SAAA,MAAAA,EAAQ,MAAM,oCAAmC,CAE1D"}
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../../src/components/FileSystemConfig.ts","../../src/components/fileSystemStorage.ts","../../src/componentsInit.ts"],"sourcesContent":["/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport { DefaultWikiConfig } from \"@xwiki/cristal-api\";\nimport { inject, injectable, named } from \"inversify\";\nimport type { CristalApp, Logger, Storage } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport class FileSystemConfig extends DefaultWikiConfig {\n override storage: Storage;\n override cristal: CristalApp;\n constructor(\n @inject(\"Logger\") logger: Logger,\n @inject(\"Storage\") @named(\"FileSystem\") storage: Storage,\n @inject(\"CristalApp\") cristal: CristalApp,\n ) {\n super(logger);\n this.storage = storage;\n this.cristal = cristal;\n this.storage.setWikiConfig(this);\n if (this.homePage === \"\") {\n this.homePage = \"index.md\";\n }\n }\n\n override getType(): string {\n return \"FileSystem\";\n }\n\n override initialize(): void {\n super.initialize();\n // The initialization for the root directory needs to be done after a\n // configuration change, but before any storage operation.\n fileSystemStorage.initRootDirectory();\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport {\n AttachmentsData,\n DefaultPageData,\n PageAttachment,\n PageData,\n} from \"@xwiki/cristal-api\";\nimport { AbstractStorage } from \"@xwiki/cristal-backend-api\";\nimport { inject, injectable } from \"inversify\";\nimport type { Logger } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport default class FileSystemStorage extends AbstractStorage {\n constructor(@inject(\"Logger\") logger: Logger) {\n super(logger, \"storage.components.fileSystemStorage\");\n }\n\n getEditField(): Promise<string> {\n return Promise.resolve(\"\");\n }\n\n getImageURL(): string {\n return \"\";\n }\n\n async getPageContent(page: string): Promise<PageData> {\n const decodedPage = decodeURI(page);\n const path = await fileSystemStorage.resolvePath(decodedPage);\n const pageData = await fileSystemStorage.readPage(path || \"\");\n if (pageData) {\n pageData.id = decodedPage;\n pageData.headline = pageData.name;\n pageData.headlineRaw = pageData.name;\n }\n return pageData;\n }\n\n async getAttachments(page: string): Promise<AttachmentsData | undefined> {\n const path = await fileSystemStorage.resolveAttachmentsPath(page);\n return {\n attachments: await fileSystemStorage.readAttachments(path),\n };\n }\n\n async getAttachment(\n page: string,\n name: string,\n ): Promise<PageAttachment | undefined> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, name);\n return fileSystemStorage.readAttachment(path);\n }\n\n getPageFromViewURL(): string | null {\n return null;\n }\n\n getPageRestURL(): string {\n return \"\";\n }\n\n getPanelContent(): Promise<PageData> {\n return Promise.resolve(new DefaultPageData());\n }\n\n isStorageReady(): Promise<boolean> {\n return Promise.resolve(true);\n }\n\n async save(page: string, content: string, title: string): Promise<void> {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.savePage(path, content, title);\n }\n\n async saveAttachments(page: string, files: File[]): Promise<unknown> {\n return Promise.all(files.map((file) => this.saveAttachment(page, file)));\n }\n\n async delete(page: string): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.deletePage(path);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n async move(\n page: string,\n newPage: string,\n preserveChildren: boolean,\n ): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n const newPath = await fileSystemStorage.resolvePath(newPage);\n await fileSystemStorage.movePage(path, newPath, preserveChildren);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n private async saveAttachment(page: string, file: File): Promise<unknown> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, file.name);\n await fileSystemStorage.saveAttachment(path, file);\n return;\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { FileSystemConfig } from \"./components/FileSystemConfig\";\nimport FileSystemStorage from \"./components/fileSystemStorage\";\nimport type { Logger, Storage, WikiConfig } from \"@xwiki/cristal-api\";\nimport type { Container } from \"inversify\";\n\nexport default class ComponentInit {\n logger: Logger;\n\n constructor(container: Container) {\n this.logger = container.get<Logger>(\"Logger\");\n this.logger.setModule(\"electron.storage.components.componentsInit\");\n\n this.logger?.debug(\"Init Sample Module components begin\");\n container\n .bind<WikiConfig>(\"WikiConfig\")\n .to(FileSystemConfig)\n .whenNamed(\"FileSystem\");\n container\n .bind<Storage>(\"Storage\")\n .to(FileSystemStorage)\n .whenNamed(\"FileSystem\");\n this.logger?.debug(\"Init Sample Module components end\");\n }\n}\n"],"names":["FileSystemConfig","DefaultWikiConfig","logger","storage","cristal","__decorateClass","injectable","__decorateParam","FileSystemStorage","AbstractStorage","page","decodedPage","path","pageData","name","DefaultPageData","content","title","files","file","error","newPage","preserveChildren","newPath","ComponentInit","container","_a","_b"],"mappings":"0oBA4Ba,IAAAA,EAAN,cAA+BC,EAAAA,iBAAkB,CAGtD,YACoBC,EACsBC,EAClBC,EACtB,CACA,MAAMF,CAAM,EACZ,KAAK,QAAUC,EACf,KAAK,QAAU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AAY,EACzByB,EACG,KAAc,SAAS,EACvB,GAAGjB,CAAiB,EACpB,UAAU,YAAY,GACpBmB,EAAA,KAAA,SAAA,MAAAA,EAAQ,MAAM,oCAAmC,CAE1D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xwiki/cristal-electron-storage",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"license": "LGPL 2.1",
|
|
5
5
|
"author": "XWiki Org Community <contact@xwiki.org>",
|
|
6
6
|
"homepage": "https://cristal.xwiki.org/",
|
|
@@ -32,25 +32,26 @@
|
|
|
32
32
|
},
|
|
33
33
|
"main": "./dist/main/index.es.js",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"inversify": "
|
|
35
|
+
"inversify": "7.1.0",
|
|
36
36
|
"mime": "4.0.6",
|
|
37
|
-
"@xwiki/cristal-
|
|
38
|
-
"@xwiki/cristal-
|
|
39
|
-
"@xwiki/cristal-
|
|
40
|
-
"@xwiki/cristal-
|
|
41
|
-
"@xwiki/cristal-api": "0.
|
|
37
|
+
"@xwiki/cristal-api": "0.16.0",
|
|
38
|
+
"@xwiki/cristal-electron-state": "0.16.0",
|
|
39
|
+
"@xwiki/cristal-model-remote-url-filesystem-api": "0.16.0",
|
|
40
|
+
"@xwiki/cristal-backend-api": "0.16.0",
|
|
41
|
+
"@xwiki/cristal-link-suggest-api": "0.16.0",
|
|
42
|
+
"@xwiki/cristal-model-api": "0.16.0"
|
|
42
43
|
},
|
|
43
44
|
"peerDependencies": {
|
|
44
|
-
"electron": "
|
|
45
|
+
"electron": "35.0.1",
|
|
45
46
|
"reflect-metadata": "0.2.2"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
|
-
"@types/node": "22.10
|
|
49
|
+
"@types/node": "22.13.10",
|
|
49
50
|
"reflect-metadata": "0.2.2",
|
|
50
|
-
"typescript": "5.
|
|
51
|
-
"vite": "6.
|
|
51
|
+
"typescript": "5.8.2",
|
|
52
|
+
"vite": "6.2.2",
|
|
52
53
|
"vite-plugin-node": "4.0.0",
|
|
53
|
-
"@xwiki/cristal-dev-config": "0.
|
|
54
|
+
"@xwiki/cristal-dev-config": "0.16.0"
|
|
54
55
|
},
|
|
55
56
|
"scripts": {
|
|
56
57
|
"build": "pnpm compile",
|
|
@@ -18,16 +18,19 @@
|
|
|
18
18
|
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
+
import { APITypes } from "../electron/preload/apiTypes";
|
|
21
22
|
import { DefaultWikiConfig } from "@xwiki/cristal-api";
|
|
22
23
|
import { inject, injectable, named } from "inversify";
|
|
23
24
|
import type { CristalApp, Logger, Storage } from "@xwiki/cristal-api";
|
|
24
25
|
|
|
26
|
+
declare const fileSystemStorage: APITypes;
|
|
27
|
+
|
|
25
28
|
@injectable()
|
|
26
29
|
export class FileSystemConfig extends DefaultWikiConfig {
|
|
27
30
|
override storage: Storage;
|
|
28
31
|
override cristal: CristalApp;
|
|
29
32
|
constructor(
|
|
30
|
-
@inject
|
|
33
|
+
@inject("Logger") logger: Logger,
|
|
31
34
|
@inject("Storage") @named("FileSystem") storage: Storage,
|
|
32
35
|
@inject("CristalApp") cristal: CristalApp,
|
|
33
36
|
) {
|
|
@@ -43,4 +46,11 @@ export class FileSystemConfig extends DefaultWikiConfig {
|
|
|
43
46
|
override getType(): string {
|
|
44
47
|
return "FileSystem";
|
|
45
48
|
}
|
|
49
|
+
|
|
50
|
+
override initialize(): void {
|
|
51
|
+
super.initialize();
|
|
52
|
+
// The initialization for the root directory needs to be done after a
|
|
53
|
+
// configuration change, but before any storage operation.
|
|
54
|
+
fileSystemStorage.initRootDirectory();
|
|
55
|
+
}
|
|
46
56
|
}
|
|
@@ -33,7 +33,7 @@ declare const fileSystemStorage: APITypes;
|
|
|
33
33
|
|
|
34
34
|
@injectable()
|
|
35
35
|
export default class FileSystemStorage extends AbstractStorage {
|
|
36
|
-
constructor(@inject
|
|
36
|
+
constructor(@inject("Logger") logger: Logger) {
|
|
37
37
|
super(logger, "storage.components.fileSystemStorage");
|
|
38
38
|
}
|
|
39
39
|
|
package/src/componentsInit.ts
CHANGED
|
@@ -34,11 +34,11 @@ export default class ComponentInit {
|
|
|
34
34
|
container
|
|
35
35
|
.bind<WikiConfig>("WikiConfig")
|
|
36
36
|
.to(FileSystemConfig)
|
|
37
|
-
.
|
|
37
|
+
.whenNamed("FileSystem");
|
|
38
38
|
container
|
|
39
39
|
.bind<Storage>("Storage")
|
|
40
40
|
.to(FileSystemStorage)
|
|
41
|
-
.
|
|
41
|
+
.whenNamed("FileSystem");
|
|
42
42
|
this.logger?.debug("Init Sample Module components end");
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
import { PageAttachment, PageData } from "@xwiki/cristal-api";
|
|
22
|
+
import { getStorageRoot } from "@xwiki/cristal-electron-state";
|
|
22
23
|
import { LinkType } from "@xwiki/cristal-link-suggest-api";
|
|
23
24
|
import { EntityType } from "@xwiki/cristal-model-api";
|
|
24
25
|
import { protocol as cristalFSProtocol } from "@xwiki/cristal-model-remote-url-filesystem-api";
|
|
@@ -32,9 +33,14 @@ import { basename, dirname, join, relative } from "node:path";
|
|
|
32
33
|
const HOME_PATH = ".cristal";
|
|
33
34
|
const HOME_PATH_FULL = join(app.getPath("home"), HOME_PATH);
|
|
34
35
|
|
|
36
|
+
function getHomePathFull(): string {
|
|
37
|
+
// If no custom storage root was provided in the current configuration, we
|
|
38
|
+
// fallback to the folder `${HOME}/.cristal`.
|
|
39
|
+
return getStorageRoot() ?? HOME_PATH_FULL;
|
|
40
|
+
}
|
|
41
|
+
|
|
35
42
|
function resolvePath(page: string, ...lastSegments: string[]) {
|
|
36
|
-
|
|
37
|
-
return join(homedir, HOME_PATH, page, ...lastSegments);
|
|
43
|
+
return join(getHomePathFull(), page, ...lastSegments);
|
|
38
44
|
}
|
|
39
45
|
|
|
40
46
|
function resolvePagePath(page: string): string {
|
|
@@ -117,8 +123,9 @@ async function pathExists(path: string) {
|
|
|
117
123
|
async function readPage(
|
|
118
124
|
path: string,
|
|
119
125
|
): Promise<{ type: EntityType.DOCUMENT; value: PageData } | undefined> {
|
|
120
|
-
|
|
121
|
-
|
|
126
|
+
const homePathFull = getHomePathFull();
|
|
127
|
+
if (!(await isWithin(homePathFull, path))) {
|
|
128
|
+
throw new Error(`[${path}] is not in in [${homePathFull}]`);
|
|
122
129
|
}
|
|
123
130
|
if (await isFile(path)) {
|
|
124
131
|
const pageContent = await fs.promises.readFile(path);
|
|
@@ -130,7 +137,7 @@ async function readPage(
|
|
|
130
137
|
...parse,
|
|
131
138
|
lastAuthor: { name: os.userInfo().username },
|
|
132
139
|
lastModificationDate: new Date(pageStats.mtimeMs),
|
|
133
|
-
id: relative(
|
|
140
|
+
id: relative(homePathFull, dirname(path)),
|
|
134
141
|
canEdit: true,
|
|
135
142
|
},
|
|
136
143
|
};
|
|
@@ -142,8 +149,9 @@ async function readPage(
|
|
|
142
149
|
async function readAttachments(
|
|
143
150
|
path: string,
|
|
144
151
|
): Promise<PageAttachment[] | undefined> {
|
|
145
|
-
|
|
146
|
-
|
|
152
|
+
const homePathFull = getHomePathFull();
|
|
153
|
+
if (!(await isWithin(homePathFull, path))) {
|
|
154
|
+
throw new Error(`[${path}] is not in in [${homePathFull}]`);
|
|
147
155
|
}
|
|
148
156
|
if (await isDirectory(path)) {
|
|
149
157
|
const attachments = await fs.promises.readdir(path);
|
|
@@ -162,8 +170,9 @@ async function readAttachments(
|
|
|
162
170
|
async function readAttachment(
|
|
163
171
|
path: string,
|
|
164
172
|
): Promise<{ type: EntityType.ATTACHMENT; value: PageAttachment } | undefined> {
|
|
165
|
-
|
|
166
|
-
|
|
173
|
+
const homePathFull = getHomePathFull();
|
|
174
|
+
if (!(await isWithin(homePathFull, path))) {
|
|
175
|
+
throw new Error(`[${path}] is not in in [${homePathFull}]`);
|
|
167
176
|
}
|
|
168
177
|
|
|
169
178
|
if (await isFile(path)) {
|
|
@@ -174,8 +183,8 @@ async function readAttachment(
|
|
|
174
183
|
value: {
|
|
175
184
|
id: basename(path),
|
|
176
185
|
mimetype,
|
|
177
|
-
reference: relative(
|
|
178
|
-
href: `${cristalFSProtocol}://${relative(
|
|
186
|
+
reference: relative(homePathFull, path),
|
|
187
|
+
href: `${cristalFSProtocol}://${relative(homePathFull, path)}`,
|
|
179
188
|
date: stats.mtime,
|
|
180
189
|
size: stats.size,
|
|
181
190
|
author: undefined,
|
|
@@ -207,8 +216,9 @@ async function savePage(
|
|
|
207
216
|
content: string,
|
|
208
217
|
title: string,
|
|
209
218
|
): Promise<PageData | undefined> {
|
|
210
|
-
|
|
211
|
-
|
|
219
|
+
const homePathFull = getHomePathFull();
|
|
220
|
+
if (!(await isWithin(homePathFull, path))) {
|
|
221
|
+
throw new Error(`[${path}] is not in in [${homePathFull}]`);
|
|
212
222
|
}
|
|
213
223
|
let jsonContent: {
|
|
214
224
|
source: string;
|
|
@@ -240,8 +250,9 @@ async function savePage(
|
|
|
240
250
|
}
|
|
241
251
|
|
|
242
252
|
async function saveAttachment(path: string, filePath: string) {
|
|
243
|
-
|
|
244
|
-
|
|
253
|
+
const homePathFull = getHomePathFull();
|
|
254
|
+
if (!(await isWithin(homePathFull, path))) {
|
|
255
|
+
throw new Error(`[${path}] is not in in [${homePathFull}]`);
|
|
245
256
|
}
|
|
246
257
|
const parentDirectory = dirname(path);
|
|
247
258
|
|
|
@@ -303,8 +314,9 @@ async function search(
|
|
|
303
314
|
| { type: EntityType.DOCUMENT; value: PageData }
|
|
304
315
|
)[]
|
|
305
316
|
> {
|
|
306
|
-
const
|
|
307
|
-
|
|
317
|
+
const homePathFull = getHomePathFull();
|
|
318
|
+
const attachments = (await readdir(homePathFull, { recursive: true })).map(
|
|
319
|
+
(it) => join(homePathFull, it),
|
|
308
320
|
);
|
|
309
321
|
const allEntities = await asyncFilter(attachments, async (path: string) => {
|
|
310
322
|
if (type == LinkType.ATTACHMENT) {
|
|
@@ -345,7 +357,7 @@ async function search(
|
|
|
345
357
|
*/
|
|
346
358
|
async function createMinimalContent() {
|
|
347
359
|
await savePage(
|
|
348
|
-
join(
|
|
360
|
+
join(getHomePathFull(), "index", "page.json"),
|
|
349
361
|
"# Welcome\n" +
|
|
350
362
|
"\n" +
|
|
351
363
|
"This is a new **Cristal** wiki.\n" +
|
|
@@ -450,7 +462,7 @@ async function movePageSingle(path: string, newPath: string) {
|
|
|
450
462
|
* @since 0.14
|
|
451
463
|
*/
|
|
452
464
|
async function cleanEmptyArborescence(directory: string): Promise<void> {
|
|
453
|
-
if (await isWithin(
|
|
465
|
+
if (await isWithin(getHomePathFull(), directory)) {
|
|
454
466
|
if (!(await pathExists(directory))) {
|
|
455
467
|
await cleanEmptyArborescence(dirname(directory));
|
|
456
468
|
} else if ((await isDirectory(directory)) && (await isEmpty(directory))) {
|
|
@@ -463,22 +475,26 @@ async function cleanEmptyArborescence(directory: string): Promise<void> {
|
|
|
463
475
|
// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
|
|
464
476
|
// eslint-disable-next-line max-statements
|
|
465
477
|
export default async function load(): Promise<void> {
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
478
|
+
ipcMain.on("initRootDirectory", async () => {
|
|
479
|
+
// Check if the root directory does not exist, or exists and is empty.
|
|
480
|
+
// If that's the case, create it and populate it with a default minimal content.
|
|
481
|
+
const homePathFull = getHomePathFull();
|
|
482
|
+
if (
|
|
483
|
+
!(await pathExists(homePathFull)) ||
|
|
484
|
+
((await isDirectory(homePathFull)) && (await isEmpty(homePathFull)))
|
|
485
|
+
) {
|
|
486
|
+
await createMinimalContent();
|
|
487
|
+
}
|
|
488
|
+
});
|
|
474
489
|
|
|
475
490
|
protocol.handle(cristalFSProtocol, async (request) => {
|
|
491
|
+
const homePathFull = getHomePathFull();
|
|
476
492
|
const path = join(
|
|
477
|
-
|
|
493
|
+
homePathFull,
|
|
478
494
|
request.url.substring(`${cristalFSProtocol}://`.length),
|
|
479
495
|
);
|
|
480
|
-
if (!(await isWithin(
|
|
481
|
-
throw new Error(`[${path}] is not in in [${
|
|
496
|
+
if (!(await isWithin(homePathFull, path))) {
|
|
497
|
+
throw new Error(`[${path}] is not in in [${homePathFull}]`);
|
|
482
498
|
}
|
|
483
499
|
return net.fetch(`file://${path}`);
|
|
484
500
|
});
|
|
@@ -23,6 +23,8 @@ import { LinkType } from "@xwiki/cristal-link-suggest-api";
|
|
|
23
23
|
import { EntityType } from "@xwiki/cristal-model-api";
|
|
24
24
|
|
|
25
25
|
export interface APITypes {
|
|
26
|
+
initRootDirectory(): void;
|
|
27
|
+
|
|
26
28
|
resolvePath(page: string): Promise<string>;
|
|
27
29
|
|
|
28
30
|
resolveAttachmentsPath(page: string): Promise<string>;
|
|
@@ -25,6 +25,9 @@ import { EntityType } from "@xwiki/cristal-model-api";
|
|
|
25
25
|
import { contextBridge, ipcRenderer, webUtils } from "electron";
|
|
26
26
|
|
|
27
27
|
const api: APITypes = {
|
|
28
|
+
initRootDirectory(): void {
|
|
29
|
+
return ipcRenderer.send("initRootDirectory", {});
|
|
30
|
+
},
|
|
28
31
|
readPage: (path: string) => {
|
|
29
32
|
return ipcRenderer.invoke("readPage", { path });
|
|
30
33
|
},
|