@xwiki/cristal-electron-storage 0.13.0 → 0.14.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 +15 -0
- package/dist/default/components/fileSystemStorage.d.ts +4 -0
- package/dist/default/electron/main/index.d.ts +1 -1
- package/dist/default/electron/preload/apiTypes.d.ts +10 -0
- package/dist/default/index.es.js +37 -29
- 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/fileSystemStorage.d.ts +4 -0
- package/dist/main/electron/main/index.d.ts +1 -1
- package/dist/main/electron/preload/apiTypes.d.ts +10 -0
- package/dist/main/index.es.js +37 -29
- 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/fileSystemStorage.d.ts +4 -0
- package/dist/preload/electron/main/index.d.ts +1 -1
- package/dist/preload/electron/preload/apiTypes.d.ts +10 -0
- package/dist/preload/index.es.js +37 -29
- 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 +12 -12
- package/src/components/fileSystemStorage.ts +15 -0
- package/src/electron/main/index.ts +140 -5
- package/src/electron/preload/apiTypes.ts +15 -0
- package/src/electron/preload/index.ts +7 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @xwiki/cristal-electron-storage
|
|
2
2
|
|
|
3
|
+
## 0.14.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 3e5f853: Cristal 0.14 Release
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [3e5f853]
|
|
12
|
+
- @xwiki/cristal-api@0.14.0
|
|
13
|
+
- @xwiki/cristal-backend-api@0.14.0
|
|
14
|
+
- @xwiki/cristal-link-suggest-api@0.14.0
|
|
15
|
+
- @xwiki/cristal-model-api@0.14.0
|
|
16
|
+
- @xwiki/cristal-model-remote-url-filesystem-api@0.14.0
|
|
17
|
+
|
|
3
18
|
## 0.13.0
|
|
4
19
|
|
|
5
20
|
### Minor Changes
|
|
@@ -17,5 +17,9 @@ export default class FileSystemStorage extends AbstractStorage {
|
|
|
17
17
|
success: boolean;
|
|
18
18
|
error?: string;
|
|
19
19
|
}>;
|
|
20
|
+
move(page: string, newPage: string, preserveChildren: boolean): Promise<{
|
|
21
|
+
success: boolean;
|
|
22
|
+
error?: string;
|
|
23
|
+
}>;
|
|
20
24
|
private saveAttachment;
|
|
21
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function load(): void
|
|
1
|
+
export default function load(): Promise<void>;
|
|
@@ -26,4 +26,14 @@ export interface APITypes {
|
|
|
26
26
|
type: EntityType.DOCUMENT;
|
|
27
27
|
value: PageData;
|
|
28
28
|
})[]>;
|
|
29
|
+
/**
|
|
30
|
+
* Move a page.
|
|
31
|
+
*
|
|
32
|
+
* @param path - the path to the page to move
|
|
33
|
+
* @param newPath - the new path for the page
|
|
34
|
+
* @param preserveChildren - whether to move children
|
|
35
|
+
*
|
|
36
|
+
* @since 0.14
|
|
37
|
+
*/
|
|
38
|
+
movePage(path: string, newPath: string, preserveChildren: boolean): Promise<void>;
|
|
29
39
|
}
|
package/dist/default/index.es.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import { DefaultWikiConfig as h, DefaultPageData as S } from "@xwiki/cristal-api";
|
|
2
|
-
import { injectable as c, inject as g, named as
|
|
3
|
-
import { AbstractStorage as
|
|
4
|
-
var
|
|
5
|
-
for (var s =
|
|
6
|
-
(n = t[o]) && (s = (
|
|
7
|
-
return
|
|
8
|
-
}, i = (t, e) => (
|
|
2
|
+
import { injectable as c, inject as g, named as u } from "inversify";
|
|
3
|
+
import { AbstractStorage as f } from "@xwiki/cristal-backend-api";
|
|
4
|
+
var p = Object.defineProperty, P = Object.getOwnPropertyDescriptor, y = (t, e, r, a) => {
|
|
5
|
+
for (var s = a > 1 ? void 0 : a ? P(e, r) : e, o = t.length - 1, n; o >= 0; o--)
|
|
6
|
+
(n = t[o]) && (s = (a ? n(e, r, s) : n(s)) || s);
|
|
7
|
+
return a && s && p(e, r, s), s;
|
|
8
|
+
}, i = (t, e) => (r, a) => e(r, a, t);
|
|
9
9
|
let l = class extends h {
|
|
10
|
-
constructor(t, e,
|
|
11
|
-
super(t), this.storage = e, this.cristal =
|
|
10
|
+
constructor(t, e, r) {
|
|
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
16
|
};
|
|
17
|
-
l =
|
|
17
|
+
l = y([
|
|
18
18
|
c(),
|
|
19
19
|
i(0, g("Logger")),
|
|
20
20
|
i(1, g("Storage")),
|
|
21
|
-
i(1,
|
|
21
|
+
i(1, u("FileSystem")),
|
|
22
22
|
i(2, g("CristalApp"))
|
|
23
23
|
], l);
|
|
24
|
-
var v = Object.defineProperty,
|
|
25
|
-
for (var s =
|
|
26
|
-
(n = t[o]) && (s = (
|
|
27
|
-
return
|
|
28
|
-
}, _ = (t, e) => (
|
|
29
|
-
let m = class extends
|
|
24
|
+
var v = Object.defineProperty, d = Object.getOwnPropertyDescriptor, w = (t, e, r, a) => {
|
|
25
|
+
for (var s = a > 1 ? void 0 : a ? d(e, r) : e, o = t.length - 1, n; o >= 0; o--)
|
|
26
|
+
(n = t[o]) && (s = (a ? n(e, r, s) : n(s)) || s);
|
|
27
|
+
return a && s && v(e, r, s), s;
|
|
28
|
+
}, _ = (t, e) => (r, a) => e(r, a, t);
|
|
29
|
+
let m = class extends f {
|
|
30
30
|
constructor(t) {
|
|
31
31
|
super(t, "storage.components.fileSystemStorage");
|
|
32
32
|
}
|
|
@@ -37,8 +37,8 @@ let m = class extends u {
|
|
|
37
37
|
return "";
|
|
38
38
|
}
|
|
39
39
|
async getPageContent(t) {
|
|
40
|
-
const e = decodeURI(t),
|
|
41
|
-
return
|
|
40
|
+
const e = decodeURI(t), r = await fileSystemStorage.resolvePath(e), a = await fileSystemStorage.readPage(r || "");
|
|
41
|
+
return a && (a.id = e, a.headline = a.name, a.headlineRaw = a.name), a;
|
|
42
42
|
}
|
|
43
43
|
async getAttachments(t) {
|
|
44
44
|
const e = await fileSystemStorage.resolveAttachmentsPath(t);
|
|
@@ -47,8 +47,8 @@ let m = class extends u {
|
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
49
|
async getAttachment(t, e) {
|
|
50
|
-
const
|
|
51
|
-
return fileSystemStorage.readAttachment(
|
|
50
|
+
const r = await fileSystemStorage.resolveAttachmentPath(t, e);
|
|
51
|
+
return fileSystemStorage.readAttachment(r);
|
|
52
52
|
}
|
|
53
53
|
getPageFromViewURL() {
|
|
54
54
|
return null;
|
|
@@ -62,12 +62,12 @@ let m = class extends u {
|
|
|
62
62
|
isStorageReady() {
|
|
63
63
|
return Promise.resolve(!0);
|
|
64
64
|
}
|
|
65
|
-
async save(t, e,
|
|
66
|
-
const
|
|
67
|
-
await fileSystemStorage.savePage(
|
|
65
|
+
async save(t, e, r) {
|
|
66
|
+
const a = await fileSystemStorage.resolvePath(t);
|
|
67
|
+
await fileSystemStorage.savePage(a, e, r);
|
|
68
68
|
}
|
|
69
69
|
async saveAttachments(t, e) {
|
|
70
|
-
return Promise.all(e.map((
|
|
70
|
+
return Promise.all(e.map((r) => this.saveAttachment(t, r)));
|
|
71
71
|
}
|
|
72
72
|
async delete(t) {
|
|
73
73
|
try {
|
|
@@ -77,9 +77,17 @@ let m = class extends u {
|
|
|
77
77
|
return { success: !1, error: e.message };
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
+
async move(t, e, r) {
|
|
81
|
+
try {
|
|
82
|
+
const a = await fileSystemStorage.resolvePath(t), s = await fileSystemStorage.resolvePath(e);
|
|
83
|
+
return await fileSystemStorage.movePage(a, s, r), { success: !0 };
|
|
84
|
+
} catch (a) {
|
|
85
|
+
return { success: !1, error: a.message };
|
|
86
|
+
}
|
|
87
|
+
}
|
|
80
88
|
async saveAttachment(t, e) {
|
|
81
|
-
const
|
|
82
|
-
await fileSystemStorage.saveAttachment(
|
|
89
|
+
const r = await fileSystemStorage.resolveAttachmentPath(t, e.name);
|
|
90
|
+
await fileSystemStorage.saveAttachment(r, e);
|
|
83
91
|
}
|
|
84
92
|
};
|
|
85
93
|
m = w([
|
|
@@ -88,8 +96,8 @@ m = w([
|
|
|
88
96
|
], m);
|
|
89
97
|
class D {
|
|
90
98
|
constructor(e) {
|
|
91
|
-
var
|
|
92
|
-
this.logger = e.get("Logger"), this.logger.setModule("electron.storage.components.componentsInit"), (
|
|
99
|
+
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(l).whenTargetNamed("FileSystem"), e.bind("Storage").to(m).whenTargetNamed("FileSystem"), (a = this.logger) == null || a.debug("Init Sample Module components end");
|
|
93
101
|
}
|
|
94
102
|
}
|
|
95
103
|
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 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","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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kB,YAAYF,CAAI;AACrD,UAAM,kBAAkB,SAASE,GAAMI,GAASC,CAAK;AAAA,EAAA;AAAA,EAGvD,MAAM,gBAAgBP,GAAcQ,GAAiC;AAC5D,WAAA,QAAQ,IAAIA,EAAM,IAAI,CAACC,MAAS,KAAK,eAAeT,GAAMS,CAAI,CAAC,CAAC;AAAA,EAAA;AAAA,EAGzE,MAAM,OAAOT,GAA6D;AACpE,QAAA;AACF,YAAME,IAAO,MAAM,kBAAkB,YAAYF,CAAI;AAC/C,mBAAA,kBAAkB,WAAWE,CAAI,GAChC,EAAE,SAAS,GAAK;AAAA,aAChBQ,GAAO;AACd,aAAO,EAAE,SAAS,IAAO,OAAQA,EAAgB,QAAQ;AAAA,IAAA;AAAA,EAC3D;AAAA,EAGF,MAAc,eAAeV,GAAcS,GAA8B;AACvE,UAAMP,IAAO,MAAM,kBAAkB,sBAAsBF,GAAMS,EAAK,IAAI;AACpE,UAAA,kBAAkB,eAAeP,GAAMO,CAAI;AAAA,EACjD;AAEJ;AAhFqBX,IAArBH,EAAA;AAAA,EADCC,EAAW;AAAA,EAEGC,OAAe,QAAQ,CAAA;AAAA,GADjBC,CAAA;ACTrB,MAAqBa,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,GAAGtB,CAAgB,EACnB,gBAAgB,YAAY,GAC/BsB,EACG,KAAc,SAAS,EACvB,GAAGd,CAAiB,EACpB,gBAAgB,YAAY,IAC1BgB,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 { 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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AO;AACd,aAAO,EAAE,SAAS,IAAO,OAAQA,EAAgB,QAAQ;AAAA,IAAA;AAAA,EAC3D;AAAA,EAGF,MAAc,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,2 +1,2 @@
|
|
|
1
|
-
(function(n,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):(n=typeof globalThis<"u"?globalThis:n||self,l(n.cristal_storage={},n.cristalApi,n.inversify,n.cristalBackendApi))})(this,function(n,l,
|
|
1
|
+
(function(n,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):(n=typeof globalThis<"u"?globalThis:n||self,l(n.cristal_storage={},n.cristalApi,n.inversify,n.cristalBackendApi))})(this,function(n,l,o,u){"use strict";var S=Object.defineProperty,p=Object.getOwnPropertyDescriptor,f=(t,e,r,a)=>{for(var s=a>1?void 0:a?p(e,r):e,i=t.length-1,c;i>=0;i--)(c=t[i])&&(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"}};m=f([o.injectable(),g(0,o.inject("Logger")),g(1,o.inject("Storage")),g(1,o.named("FileSystem")),g(2,o.inject("CristalApp"))],m);var d=Object.defineProperty,P=Object.getOwnPropertyDescriptor,y=(t,e,r,a)=>{for(var s=a>1?void 0:a?P(e,r):e,i=t.length-1,c;i>=0;i--)(c=t[i])&&(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 h=class extends u.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)}};h=y([o.injectable(),v(0,o.inject("Logger"))],h);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).whenTargetNamed("FileSystem"),e.bind("Storage").to(h).whenTargetNamed("FileSystem"),(a=this.logger)==null||a.debug("Init Sample Module components end")}}n.ComponentInit=w,Object.defineProperty(n,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 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","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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eV,EAAcS,EAA8B,CACvE,MAAMP,EAAO,MAAM,kBAAkB,sBAAsBF,EAAMS,EAAK,IAAI,EACpE,MAAA,kBAAkB,eAAeP,EAAMO,CAAI,CACjD,CAEJ,EAhFqBX,EAArBH,EAAA,CADCC,aAAW,EAEGC,aAAe,QAAQ,CAAA,CAAA,EADjBC,CAAA,ECTrB,MAAqBa,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,GAAGtB,CAAgB,EACnB,gBAAgB,YAAY,EAC/BsB,EACG,KAAc,SAAS,EACvB,GAAGd,CAAiB,EACpB,gBAAgB,YAAY,GAC1BgB,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 { 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,EACv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
19
19
|
}>;
|
|
20
|
+
move(page: string, newPage: string, preserveChildren: boolean): Promise<{
|
|
21
|
+
success: boolean;
|
|
22
|
+
error?: string;
|
|
23
|
+
}>;
|
|
20
24
|
private saveAttachment;
|
|
21
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function load(): void
|
|
1
|
+
export default function load(): Promise<void>;
|
|
@@ -26,4 +26,14 @@ export interface APITypes {
|
|
|
26
26
|
type: EntityType.DOCUMENT;
|
|
27
27
|
value: PageData;
|
|
28
28
|
})[]>;
|
|
29
|
+
/**
|
|
30
|
+
* Move a page.
|
|
31
|
+
*
|
|
32
|
+
* @param path - the path to the page to move
|
|
33
|
+
* @param newPath - the new path for the page
|
|
34
|
+
* @param preserveChildren - whether to move children
|
|
35
|
+
*
|
|
36
|
+
* @since 0.14
|
|
37
|
+
*/
|
|
38
|
+
movePage(path: string, newPath: string, preserveChildren: boolean): Promise<void>;
|
|
29
39
|
}
|
package/dist/main/index.es.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import { DefaultWikiConfig as h, DefaultPageData as S } from "@xwiki/cristal-api";
|
|
2
|
-
import { injectable as c, inject as g, named as
|
|
3
|
-
import { AbstractStorage as
|
|
4
|
-
var
|
|
5
|
-
for (var s =
|
|
6
|
-
(n = t[o]) && (s = (
|
|
7
|
-
return
|
|
8
|
-
}, i = (t, e) => (
|
|
2
|
+
import { injectable as c, inject as g, named as u } from "inversify";
|
|
3
|
+
import { AbstractStorage as f } from "@xwiki/cristal-backend-api";
|
|
4
|
+
var p = Object.defineProperty, P = Object.getOwnPropertyDescriptor, y = (t, e, r, a) => {
|
|
5
|
+
for (var s = a > 1 ? void 0 : a ? P(e, r) : e, o = t.length - 1, n; o >= 0; o--)
|
|
6
|
+
(n = t[o]) && (s = (a ? n(e, r, s) : n(s)) || s);
|
|
7
|
+
return a && s && p(e, r, s), s;
|
|
8
|
+
}, i = (t, e) => (r, a) => e(r, a, t);
|
|
9
9
|
let l = class extends h {
|
|
10
|
-
constructor(t, e,
|
|
11
|
-
super(t), this.storage = e, this.cristal =
|
|
10
|
+
constructor(t, e, r) {
|
|
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
16
|
};
|
|
17
|
-
l =
|
|
17
|
+
l = y([
|
|
18
18
|
c(),
|
|
19
19
|
i(0, g("Logger")),
|
|
20
20
|
i(1, g("Storage")),
|
|
21
|
-
i(1,
|
|
21
|
+
i(1, u("FileSystem")),
|
|
22
22
|
i(2, g("CristalApp"))
|
|
23
23
|
], l);
|
|
24
|
-
var v = Object.defineProperty,
|
|
25
|
-
for (var s =
|
|
26
|
-
(n = t[o]) && (s = (
|
|
27
|
-
return
|
|
28
|
-
}, _ = (t, e) => (
|
|
29
|
-
let m = class extends
|
|
24
|
+
var v = Object.defineProperty, d = Object.getOwnPropertyDescriptor, w = (t, e, r, a) => {
|
|
25
|
+
for (var s = a > 1 ? void 0 : a ? d(e, r) : e, o = t.length - 1, n; o >= 0; o--)
|
|
26
|
+
(n = t[o]) && (s = (a ? n(e, r, s) : n(s)) || s);
|
|
27
|
+
return a && s && v(e, r, s), s;
|
|
28
|
+
}, _ = (t, e) => (r, a) => e(r, a, t);
|
|
29
|
+
let m = class extends f {
|
|
30
30
|
constructor(t) {
|
|
31
31
|
super(t, "storage.components.fileSystemStorage");
|
|
32
32
|
}
|
|
@@ -37,8 +37,8 @@ let m = class extends u {
|
|
|
37
37
|
return "";
|
|
38
38
|
}
|
|
39
39
|
async getPageContent(t) {
|
|
40
|
-
const e = decodeURI(t),
|
|
41
|
-
return
|
|
40
|
+
const e = decodeURI(t), r = await fileSystemStorage.resolvePath(e), a = await fileSystemStorage.readPage(r || "");
|
|
41
|
+
return a && (a.id = e, a.headline = a.name, a.headlineRaw = a.name), a;
|
|
42
42
|
}
|
|
43
43
|
async getAttachments(t) {
|
|
44
44
|
const e = await fileSystemStorage.resolveAttachmentsPath(t);
|
|
@@ -47,8 +47,8 @@ let m = class extends u {
|
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
49
|
async getAttachment(t, e) {
|
|
50
|
-
const
|
|
51
|
-
return fileSystemStorage.readAttachment(
|
|
50
|
+
const r = await fileSystemStorage.resolveAttachmentPath(t, e);
|
|
51
|
+
return fileSystemStorage.readAttachment(r);
|
|
52
52
|
}
|
|
53
53
|
getPageFromViewURL() {
|
|
54
54
|
return null;
|
|
@@ -62,12 +62,12 @@ let m = class extends u {
|
|
|
62
62
|
isStorageReady() {
|
|
63
63
|
return Promise.resolve(!0);
|
|
64
64
|
}
|
|
65
|
-
async save(t, e,
|
|
66
|
-
const
|
|
67
|
-
await fileSystemStorage.savePage(
|
|
65
|
+
async save(t, e, r) {
|
|
66
|
+
const a = await fileSystemStorage.resolvePath(t);
|
|
67
|
+
await fileSystemStorage.savePage(a, e, r);
|
|
68
68
|
}
|
|
69
69
|
async saveAttachments(t, e) {
|
|
70
|
-
return Promise.all(e.map((
|
|
70
|
+
return Promise.all(e.map((r) => this.saveAttachment(t, r)));
|
|
71
71
|
}
|
|
72
72
|
async delete(t) {
|
|
73
73
|
try {
|
|
@@ -77,9 +77,17 @@ let m = class extends u {
|
|
|
77
77
|
return { success: !1, error: e.message };
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
+
async move(t, e, r) {
|
|
81
|
+
try {
|
|
82
|
+
const a = await fileSystemStorage.resolvePath(t), s = await fileSystemStorage.resolvePath(e);
|
|
83
|
+
return await fileSystemStorage.movePage(a, s, r), { success: !0 };
|
|
84
|
+
} catch (a) {
|
|
85
|
+
return { success: !1, error: a.message };
|
|
86
|
+
}
|
|
87
|
+
}
|
|
80
88
|
async saveAttachment(t, e) {
|
|
81
|
-
const
|
|
82
|
-
await fileSystemStorage.saveAttachment(
|
|
89
|
+
const r = await fileSystemStorage.resolveAttachmentPath(t, e.name);
|
|
90
|
+
await fileSystemStorage.saveAttachment(r, e);
|
|
83
91
|
}
|
|
84
92
|
};
|
|
85
93
|
m = w([
|
|
@@ -88,8 +96,8 @@ m = w([
|
|
|
88
96
|
], m);
|
|
89
97
|
class D {
|
|
90
98
|
constructor(e) {
|
|
91
|
-
var
|
|
92
|
-
this.logger = e.get("Logger"), this.logger.setModule("electron.storage.components.componentsInit"), (
|
|
99
|
+
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(l).whenTargetNamed("FileSystem"), e.bind("Storage").to(m).whenTargetNamed("FileSystem"), (a = this.logger) == null || a.debug("Init Sample Module components end");
|
|
93
101
|
}
|
|
94
102
|
}
|
|
95
103
|
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 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","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,WAA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ME,IAAO,MAAM,kBAAkB,YAAYF,CAAI;AAC/C,mBAAA,kBAAkB,WAAWE,CAAI,GAChC,EAAE,SAAS,GAAK;AAAA,aAChBQ,GAAO;AACd,aAAO,EAAE,SAAS,IAAO,OAAQA,EAAgB,QAAQ;AAAA,IAAA;AAAA,EAC3D;AAAA,EAGF,MAAc,eAAeV,GAAcS,GAA8B;AACvE,UAAMP,IAAO,MAAM,kBAAkB,sBAAsBF,GAAMS,EAAK,IAAI;AACpE,UAAA,kBAAkB,eAAeP,GAAMO,CAAI;AAAA,EACjD;AAEJ;AAhFqBX,IAArBH,EAAA;AAAA,EADCC,EAAW;AAAA,EAEGC,OAAe,QAAQ,CAAA;AAAA,GADjBC,CAAA;ACTrB,MAAqBa,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,GAAGtB,CAAgB,EACnB,gBAAgB,YAAY,GAC/BsB,EACG,KAAc,SAAS,EACvB,GAAGd,CAAiB,EACpB,gBAAgB,YAAY,IAC1BgB,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 { 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,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,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;"}
|
package/dist/main/index.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(n,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):(n=typeof globalThis<"u"?globalThis:n||self,l(n.cristal_storage={},n.cristalApi,n.inversify,n.cristalBackendApi))})(this,function(n,l,
|
|
1
|
+
(function(n,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):(n=typeof globalThis<"u"?globalThis:n||self,l(n.cristal_storage={},n.cristalApi,n.inversify,n.cristalBackendApi))})(this,function(n,l,o,u){"use strict";var S=Object.defineProperty,p=Object.getOwnPropertyDescriptor,f=(t,e,r,a)=>{for(var s=a>1?void 0:a?p(e,r):e,i=t.length-1,c;i>=0;i--)(c=t[i])&&(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"}};m=f([o.injectable(),g(0,o.inject("Logger")),g(1,o.inject("Storage")),g(1,o.named("FileSystem")),g(2,o.inject("CristalApp"))],m);var d=Object.defineProperty,P=Object.getOwnPropertyDescriptor,y=(t,e,r,a)=>{for(var s=a>1?void 0:a?P(e,r):e,i=t.length-1,c;i>=0;i--)(c=t[i])&&(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 h=class extends u.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)}};h=y([o.injectable(),v(0,o.inject("Logger"))],h);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).whenTargetNamed("FileSystem"),e.bind("Storage").to(h).whenTargetNamed("FileSystem"),(a=this.logger)==null||a.debug("Init Sample Module components end")}}n.ComponentInit=w,Object.defineProperty(n,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 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","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,M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EAAsB,SAC3B,KAAA,OAASA,EAAU,IAAY,QAAQ,EACvC,KAAA,OAAO,UAAU,4CAA4C,GAE7DC,EAAA,KAAA,SAAA,MAAAA,EAAQ,MAAM,uCACnBD,EACG,KAAiB,YAAY,EAC7B,GAAGtB,CAAgB,EACnB,gBAAgB,YAAY,EAC/BsB,EACG,KAAc,SAAS,EACvB,GAAGd,CAAiB,EACpB,gBAAgB,YAAY,GAC1BgB,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 { 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,CAG3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GF,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,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"}
|
|
@@ -17,5 +17,9 @@ export default class FileSystemStorage extends AbstractStorage {
|
|
|
17
17
|
success: boolean;
|
|
18
18
|
error?: string;
|
|
19
19
|
}>;
|
|
20
|
+
move(page: string, newPage: string, preserveChildren: boolean): Promise<{
|
|
21
|
+
success: boolean;
|
|
22
|
+
error?: string;
|
|
23
|
+
}>;
|
|
20
24
|
private saveAttachment;
|
|
21
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function load(): void
|
|
1
|
+
export default function load(): Promise<void>;
|
|
@@ -26,4 +26,14 @@ export interface APITypes {
|
|
|
26
26
|
type: EntityType.DOCUMENT;
|
|
27
27
|
value: PageData;
|
|
28
28
|
})[]>;
|
|
29
|
+
/**
|
|
30
|
+
* Move a page.
|
|
31
|
+
*
|
|
32
|
+
* @param path - the path to the page to move
|
|
33
|
+
* @param newPath - the new path for the page
|
|
34
|
+
* @param preserveChildren - whether to move children
|
|
35
|
+
*
|
|
36
|
+
* @since 0.14
|
|
37
|
+
*/
|
|
38
|
+
movePage(path: string, newPath: string, preserveChildren: boolean): Promise<void>;
|
|
29
39
|
}
|
package/dist/preload/index.es.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import { DefaultWikiConfig as h, DefaultPageData as S } from "@xwiki/cristal-api";
|
|
2
|
-
import { injectable as c, inject as g, named as
|
|
3
|
-
import { AbstractStorage as
|
|
4
|
-
var
|
|
5
|
-
for (var s =
|
|
6
|
-
(n = t[o]) && (s = (
|
|
7
|
-
return
|
|
8
|
-
}, i = (t, e) => (
|
|
2
|
+
import { injectable as c, inject as g, named as u } from "inversify";
|
|
3
|
+
import { AbstractStorage as f } from "@xwiki/cristal-backend-api";
|
|
4
|
+
var p = Object.defineProperty, P = Object.getOwnPropertyDescriptor, y = (t, e, r, a) => {
|
|
5
|
+
for (var s = a > 1 ? void 0 : a ? P(e, r) : e, o = t.length - 1, n; o >= 0; o--)
|
|
6
|
+
(n = t[o]) && (s = (a ? n(e, r, s) : n(s)) || s);
|
|
7
|
+
return a && s && p(e, r, s), s;
|
|
8
|
+
}, i = (t, e) => (r, a) => e(r, a, t);
|
|
9
9
|
let l = class extends h {
|
|
10
|
-
constructor(t, e,
|
|
11
|
-
super(t), this.storage = e, this.cristal =
|
|
10
|
+
constructor(t, e, r) {
|
|
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
16
|
};
|
|
17
|
-
l =
|
|
17
|
+
l = y([
|
|
18
18
|
c(),
|
|
19
19
|
i(0, g("Logger")),
|
|
20
20
|
i(1, g("Storage")),
|
|
21
|
-
i(1,
|
|
21
|
+
i(1, u("FileSystem")),
|
|
22
22
|
i(2, g("CristalApp"))
|
|
23
23
|
], l);
|
|
24
|
-
var v = Object.defineProperty,
|
|
25
|
-
for (var s =
|
|
26
|
-
(n = t[o]) && (s = (
|
|
27
|
-
return
|
|
28
|
-
}, _ = (t, e) => (
|
|
29
|
-
let m = class extends
|
|
24
|
+
var v = Object.defineProperty, d = Object.getOwnPropertyDescriptor, w = (t, e, r, a) => {
|
|
25
|
+
for (var s = a > 1 ? void 0 : a ? d(e, r) : e, o = t.length - 1, n; o >= 0; o--)
|
|
26
|
+
(n = t[o]) && (s = (a ? n(e, r, s) : n(s)) || s);
|
|
27
|
+
return a && s && v(e, r, s), s;
|
|
28
|
+
}, _ = (t, e) => (r, a) => e(r, a, t);
|
|
29
|
+
let m = class extends f {
|
|
30
30
|
constructor(t) {
|
|
31
31
|
super(t, "storage.components.fileSystemStorage");
|
|
32
32
|
}
|
|
@@ -37,8 +37,8 @@ let m = class extends u {
|
|
|
37
37
|
return "";
|
|
38
38
|
}
|
|
39
39
|
async getPageContent(t) {
|
|
40
|
-
const e = decodeURI(t),
|
|
41
|
-
return
|
|
40
|
+
const e = decodeURI(t), r = await fileSystemStorage.resolvePath(e), a = await fileSystemStorage.readPage(r || "");
|
|
41
|
+
return a && (a.id = e, a.headline = a.name, a.headlineRaw = a.name), a;
|
|
42
42
|
}
|
|
43
43
|
async getAttachments(t) {
|
|
44
44
|
const e = await fileSystemStorage.resolveAttachmentsPath(t);
|
|
@@ -47,8 +47,8 @@ let m = class extends u {
|
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
49
|
async getAttachment(t, e) {
|
|
50
|
-
const
|
|
51
|
-
return fileSystemStorage.readAttachment(
|
|
50
|
+
const r = await fileSystemStorage.resolveAttachmentPath(t, e);
|
|
51
|
+
return fileSystemStorage.readAttachment(r);
|
|
52
52
|
}
|
|
53
53
|
getPageFromViewURL() {
|
|
54
54
|
return null;
|
|
@@ -62,12 +62,12 @@ let m = class extends u {
|
|
|
62
62
|
isStorageReady() {
|
|
63
63
|
return Promise.resolve(!0);
|
|
64
64
|
}
|
|
65
|
-
async save(t, e,
|
|
66
|
-
const
|
|
67
|
-
await fileSystemStorage.savePage(
|
|
65
|
+
async save(t, e, r) {
|
|
66
|
+
const a = await fileSystemStorage.resolvePath(t);
|
|
67
|
+
await fileSystemStorage.savePage(a, e, r);
|
|
68
68
|
}
|
|
69
69
|
async saveAttachments(t, e) {
|
|
70
|
-
return Promise.all(e.map((
|
|
70
|
+
return Promise.all(e.map((r) => this.saveAttachment(t, r)));
|
|
71
71
|
}
|
|
72
72
|
async delete(t) {
|
|
73
73
|
try {
|
|
@@ -77,9 +77,17 @@ let m = class extends u {
|
|
|
77
77
|
return { success: !1, error: e.message };
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
+
async move(t, e, r) {
|
|
81
|
+
try {
|
|
82
|
+
const a = await fileSystemStorage.resolvePath(t), s = await fileSystemStorage.resolvePath(e);
|
|
83
|
+
return await fileSystemStorage.movePage(a, s, r), { success: !0 };
|
|
84
|
+
} catch (a) {
|
|
85
|
+
return { success: !1, error: a.message };
|
|
86
|
+
}
|
|
87
|
+
}
|
|
80
88
|
async saveAttachment(t, e) {
|
|
81
|
-
const
|
|
82
|
-
await fileSystemStorage.saveAttachment(
|
|
89
|
+
const r = await fileSystemStorage.resolveAttachmentPath(t, e.name);
|
|
90
|
+
await fileSystemStorage.saveAttachment(r, e);
|
|
83
91
|
}
|
|
84
92
|
};
|
|
85
93
|
m = w([
|
|
@@ -88,8 +96,8 @@ m = w([
|
|
|
88
96
|
], m);
|
|
89
97
|
class D {
|
|
90
98
|
constructor(e) {
|
|
91
|
-
var
|
|
92
|
-
this.logger = e.get("Logger"), this.logger.setModule("electron.storage.components.componentsInit"), (
|
|
99
|
+
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(l).whenTargetNamed("FileSystem"), e.bind("Storage").to(m).whenTargetNamed("FileSystem"), (a = this.logger) == null || a.debug("Init Sample Module components end");
|
|
93
101
|
}
|
|
94
102
|
}
|
|
95
103
|
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 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","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,M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,MAAM,kBAAkB,sBAAsBF,GAAMS,EAAK,IAAI;AACpE,UAAA,kBAAkB,eAAeP,GAAMO,CAAI;AAAA,EACjD;AAEJ;AAhFqBX,IAArBH,EAAA;AAAA,EADCC,EAAW;AAAA,EAEGC,OAAe,QAAQ,CAAA;AAAA,GADjBC,CAAA;ACTrB,MAAqBa,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,GAAGtB,CAAgB,EACnB,gBAAgB,YAAY,GAC/BsB,EACG,KAAc,SAAS,EACvB,GAAGd,CAAiB,EACpB,gBAAgB,YAAY,IAC1BgB,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 { 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,EA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AAY,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,2 +1,2 @@
|
|
|
1
|
-
(function(n,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):(n=typeof globalThis<"u"?globalThis:n||self,l(n.cristal_storage={},n.cristalApi,n.inversify,n.cristalBackendApi))})(this,function(n,l,
|
|
1
|
+
(function(n,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):(n=typeof globalThis<"u"?globalThis:n||self,l(n.cristal_storage={},n.cristalApi,n.inversify,n.cristalBackendApi))})(this,function(n,l,o,u){"use strict";var S=Object.defineProperty,p=Object.getOwnPropertyDescriptor,f=(t,e,r,a)=>{for(var s=a>1?void 0:a?p(e,r):e,i=t.length-1,c;i>=0;i--)(c=t[i])&&(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"}};m=f([o.injectable(),g(0,o.inject("Logger")),g(1,o.inject("Storage")),g(1,o.named("FileSystem")),g(2,o.inject("CristalApp"))],m);var d=Object.defineProperty,P=Object.getOwnPropertyDescriptor,y=(t,e,r,a)=>{for(var s=a>1?void 0:a?P(e,r):e,i=t.length-1,c;i>=0;i--)(c=t[i])&&(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 h=class extends u.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)}};h=y([o.injectable(),v(0,o.inject("Logger"))],h);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).whenTargetNamed("FileSystem"),e.bind("Storage").to(h).whenTargetNamed("FileSystem"),(a=this.logger)==null||a.debug("Init Sample Module components end")}}n.ComponentInit=w,Object.defineProperty(n,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 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","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,eAAeF,CAAI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AA,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 { 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,CA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AAA,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xwiki/cristal-electron-storage",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.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,25 @@
|
|
|
32
32
|
},
|
|
33
33
|
"main": "./dist/main/index.es.js",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"inversify": "6.2.
|
|
35
|
+
"inversify": "6.2.1",
|
|
36
36
|
"mime": "4.0.6",
|
|
37
|
-
"@xwiki/cristal-api": "0.
|
|
38
|
-
"@xwiki/cristal-
|
|
39
|
-
"@xwiki/cristal-link-suggest-api": "0.
|
|
40
|
-
"@xwiki/cristal-model-remote-url-filesystem-api": "0.
|
|
41
|
-
"@xwiki/cristal-
|
|
37
|
+
"@xwiki/cristal-backend-api": "0.14.0",
|
|
38
|
+
"@xwiki/cristal-model-api": "0.14.0",
|
|
39
|
+
"@xwiki/cristal-link-suggest-api": "0.14.0",
|
|
40
|
+
"@xwiki/cristal-model-remote-url-filesystem-api": "0.14.0",
|
|
41
|
+
"@xwiki/cristal-api": "0.14.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"electron": "
|
|
44
|
+
"electron": "34.0.0",
|
|
45
45
|
"reflect-metadata": "0.2.2"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@types/node": "22.10.
|
|
48
|
+
"@types/node": "22.10.7",
|
|
49
49
|
"reflect-metadata": "0.2.2",
|
|
50
|
-
"typescript": "5.
|
|
51
|
-
"vite": "6.0.
|
|
50
|
+
"typescript": "5.7.3",
|
|
51
|
+
"vite": "6.0.11",
|
|
52
52
|
"vite-plugin-node": "4.0.0",
|
|
53
|
-
"@xwiki/cristal-dev-config": "0.
|
|
53
|
+
"@xwiki/cristal-dev-config": "0.14.0"
|
|
54
54
|
},
|
|
55
55
|
"scripts": {
|
|
56
56
|
"build": "pnpm compile",
|
|
@@ -107,6 +107,21 @@ export default class FileSystemStorage extends AbstractStorage {
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
async move(
|
|
111
|
+
page: string,
|
|
112
|
+
newPage: string,
|
|
113
|
+
preserveChildren: boolean,
|
|
114
|
+
): Promise<{ success: boolean; error?: string }> {
|
|
115
|
+
try {
|
|
116
|
+
const path = await fileSystemStorage.resolvePath(page);
|
|
117
|
+
const newPath = await fileSystemStorage.resolvePath(newPage);
|
|
118
|
+
await fileSystemStorage.movePage(path, newPath, preserveChildren);
|
|
119
|
+
return { success: true };
|
|
120
|
+
} catch (error) {
|
|
121
|
+
return { success: false, error: (error as Error).message };
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
110
125
|
private async saveAttachment(page: string, file: File): Promise<unknown> {
|
|
111
126
|
const path = await fileSystemStorage.resolveAttachmentPath(page, file.name);
|
|
112
127
|
await fileSystemStorage.saveAttachment(path, file);
|
|
@@ -100,6 +100,11 @@ async function isDirectory(path: string) {
|
|
|
100
100
|
return stat?.isDirectory();
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
async function isEmpty(path: string) {
|
|
104
|
+
const readdir = await fs.promises.readdir(path);
|
|
105
|
+
return readdir.length == 0;
|
|
106
|
+
}
|
|
107
|
+
|
|
103
108
|
async function pathExists(path: string) {
|
|
104
109
|
try {
|
|
105
110
|
await fs.promises.lstat(path);
|
|
@@ -119,10 +124,6 @@ async function readPage(
|
|
|
119
124
|
const pageContent = await fs.promises.readFile(path);
|
|
120
125
|
const pageStats = await fs.promises.stat(path);
|
|
121
126
|
const parse = JSON.parse(pageContent.toString("utf8"));
|
|
122
|
-
if (!parse.name) {
|
|
123
|
-
// Fallback to the current directory name if the name is not explicitly defined.
|
|
124
|
-
parse.name = basename(dirname(path));
|
|
125
|
-
}
|
|
126
127
|
return {
|
|
127
128
|
type: EntityType.DOCUMENT,
|
|
128
129
|
value: {
|
|
@@ -337,9 +338,140 @@ async function search(
|
|
|
337
338
|
).filter((it) => it !== undefined);
|
|
338
339
|
}
|
|
339
340
|
|
|
341
|
+
/**
|
|
342
|
+
* Initialize the wiki with a minimal content.
|
|
343
|
+
*
|
|
344
|
+
* @since 0.14
|
|
345
|
+
*/
|
|
346
|
+
async function createMinimalContent() {
|
|
347
|
+
await savePage(
|
|
348
|
+
join(HOME_PATH_FULL, "index", "page.json"),
|
|
349
|
+
"# Welcome\n" +
|
|
350
|
+
"\n" +
|
|
351
|
+
"This is a new **Cristal** wiki.\n" +
|
|
352
|
+
"\n" +
|
|
353
|
+
"You can use it to take your *own* notes.\n" +
|
|
354
|
+
"\n" +
|
|
355
|
+
"You can also create new [[pages|index/newpage]].\n" +
|
|
356
|
+
"\n" +
|
|
357
|
+
"Enjoy!",
|
|
358
|
+
"",
|
|
359
|
+
);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
async function movePage(
|
|
363
|
+
path: string,
|
|
364
|
+
newPath: string,
|
|
365
|
+
preserveChildren: boolean,
|
|
366
|
+
): Promise<void> {
|
|
367
|
+
if (preserveChildren) {
|
|
368
|
+
const directory = dirname(path);
|
|
369
|
+
const newDirectory = dirname(newPath);
|
|
370
|
+
|
|
371
|
+
// TODO: Fix CRISTAL-437 instead of doing this check here.
|
|
372
|
+
const success: boolean = await movePageDeep(directory, newDirectory);
|
|
373
|
+
if (!success) {
|
|
374
|
+
throw "Some child pages were not moved because they overlapped with children of the target.";
|
|
375
|
+
}
|
|
376
|
+
} else {
|
|
377
|
+
await movePageSingle(path, newPath);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
async function movePageDeep(
|
|
382
|
+
directory: string,
|
|
383
|
+
newDirectory: string,
|
|
384
|
+
): Promise<boolean> {
|
|
385
|
+
let success = true;
|
|
386
|
+
|
|
387
|
+
// We start by removing the directory from the arborescence.
|
|
388
|
+
const tempPath = resolvePath(`temp-${Math.random().toString(16).slice(2)}`);
|
|
389
|
+
await fs.promises.rename(directory, tempPath);
|
|
390
|
+
|
|
391
|
+
await fs.promises.mkdir(dirname(newDirectory), { recursive: true });
|
|
392
|
+
|
|
393
|
+
if (await pathExists(newDirectory)) {
|
|
394
|
+
// If the target directory already exists, we move the content instead.
|
|
395
|
+
success = await movePageDeepRecursive(tempPath, newDirectory);
|
|
396
|
+
// We put the (possible) unmoved content back to where it was.
|
|
397
|
+
await fs.promises.rename(tempPath, directory);
|
|
398
|
+
} else {
|
|
399
|
+
await fs.promises.rename(tempPath, newDirectory);
|
|
400
|
+
}
|
|
401
|
+
await cleanEmptyArborescence(directory);
|
|
402
|
+
|
|
403
|
+
return success;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
async function movePageDeepRecursive(
|
|
407
|
+
directory: string,
|
|
408
|
+
newDirectory: string,
|
|
409
|
+
): Promise<boolean> {
|
|
410
|
+
let success: boolean = true;
|
|
411
|
+
|
|
412
|
+
for (const file of await fs.promises.readdir(directory)) {
|
|
413
|
+
const filePath = join(directory, file);
|
|
414
|
+
const newFilePath = join(newDirectory, file);
|
|
415
|
+
if (await isDirectory(filePath)) {
|
|
416
|
+
success =
|
|
417
|
+
(await movePageDeepRecursive(filePath, join(newDirectory, file))) &&
|
|
418
|
+
success;
|
|
419
|
+
await cleanEmptyArborescence(filePath);
|
|
420
|
+
} else if (!(await pathExists(newFilePath))) {
|
|
421
|
+
await fs.promises.rename(filePath, newFilePath);
|
|
422
|
+
} else {
|
|
423
|
+
success = false;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
return success;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
async function movePageSingle(path: string, newPath: string) {
|
|
431
|
+
const directory = dirname(path);
|
|
432
|
+
const newDirectory = dirname(newPath);
|
|
433
|
+
|
|
434
|
+
await fs.promises.mkdir(newDirectory, { recursive: true });
|
|
435
|
+
await fs.promises.rename(path, newPath);
|
|
436
|
+
|
|
437
|
+
if (await isDirectory(`${directory}/attachments`)) {
|
|
438
|
+
await fs.promises.rename(
|
|
439
|
+
`${directory}/attachments`,
|
|
440
|
+
`${newDirectory}/attachments`,
|
|
441
|
+
);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
await cleanEmptyArborescence(directory);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Recursively delete empty directories, starting from the leaf.
|
|
449
|
+
* @param directory - the starting leaf directory
|
|
450
|
+
* @since 0.14
|
|
451
|
+
*/
|
|
452
|
+
async function cleanEmptyArborescence(directory: string): Promise<void> {
|
|
453
|
+
if (await isWithin(HOME_PATH_FULL, directory)) {
|
|
454
|
+
if (!(await pathExists(directory))) {
|
|
455
|
+
await cleanEmptyArborescence(dirname(directory));
|
|
456
|
+
} else if ((await isDirectory(directory)) && (await isEmpty(directory))) {
|
|
457
|
+
await fs.promises.rmdir(directory);
|
|
458
|
+
await cleanEmptyArborescence(dirname(directory));
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
340
463
|
// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
|
|
341
464
|
// eslint-disable-next-line max-statements
|
|
342
|
-
export default function load(): void {
|
|
465
|
+
export default async function load(): Promise<void> {
|
|
466
|
+
// Check if the root directory does not exist, or exists and is empty.
|
|
467
|
+
// If that's the case, create it and populate it with a default minimal content.
|
|
468
|
+
if (
|
|
469
|
+
!(await pathExists(HOME_PATH_FULL)) ||
|
|
470
|
+
((await isDirectory(HOME_PATH_FULL)) && (await isEmpty(HOME_PATH_FULL)))
|
|
471
|
+
) {
|
|
472
|
+
await createMinimalContent();
|
|
473
|
+
}
|
|
474
|
+
|
|
343
475
|
protocol.handle(cristalFSProtocol, async (request) => {
|
|
344
476
|
const path = join(
|
|
345
477
|
HOME_PATH_FULL,
|
|
@@ -384,4 +516,7 @@ export default function load(): void {
|
|
|
384
516
|
ipcMain.handle("search", (event, { query, type, mimetype }) => {
|
|
385
517
|
return search(query, type, mimetype);
|
|
386
518
|
});
|
|
519
|
+
ipcMain.handle("movePage", (event, { path, newPath, preserveChildren }) => {
|
|
520
|
+
return movePage(path, newPath, preserveChildren);
|
|
521
|
+
});
|
|
387
522
|
}
|
|
@@ -60,4 +60,19 @@ export interface APITypes {
|
|
|
60
60
|
| { type: EntityType.DOCUMENT; value: PageData }
|
|
61
61
|
)[]
|
|
62
62
|
>;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Move a page.
|
|
66
|
+
*
|
|
67
|
+
* @param path - the path to the page to move
|
|
68
|
+
* @param newPath - the new path for the page
|
|
69
|
+
* @param preserveChildren - whether to move children
|
|
70
|
+
*
|
|
71
|
+
* @since 0.14
|
|
72
|
+
*/
|
|
73
|
+
movePage(
|
|
74
|
+
path: string,
|
|
75
|
+
newPath: string,
|
|
76
|
+
preserveChildren: boolean,
|
|
77
|
+
): Promise<void>;
|
|
63
78
|
}
|
|
@@ -73,5 +73,12 @@ const api: APITypes = {
|
|
|
73
73
|
> {
|
|
74
74
|
return ipcRenderer.invoke("search", { query, type, mimetype });
|
|
75
75
|
},
|
|
76
|
+
movePage(
|
|
77
|
+
path: string,
|
|
78
|
+
newPath: string,
|
|
79
|
+
preserveChildren: boolean,
|
|
80
|
+
): Promise<void> {
|
|
81
|
+
return ipcRenderer.invoke("movePage", { path, newPath, preserveChildren });
|
|
82
|
+
},
|
|
76
83
|
};
|
|
77
84
|
contextBridge.exposeInMainWorld("fileSystemStorage", api);
|