@xwiki/cristal-electron-storage 0.9.0 → 0.11.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.
Files changed (35) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/default/components/FileSystemConfig.d.ts +0 -1
  3. package/dist/default/components/fileSystemStorage.d.ts +4 -1
  4. package/dist/default/componentsInit.d.ts +0 -1
  5. package/dist/default/electron/preload/apiTypes.d.ts +2 -1
  6. package/dist/default/index.d.ts +0 -1
  7. package/dist/default/index.es.js +45 -37
  8. package/dist/default/index.es.js.map +1 -1
  9. package/dist/default/index.umd.js +1 -1
  10. package/dist/default/index.umd.js.map +1 -1
  11. package/dist/main/components/FileSystemConfig.d.ts +0 -1
  12. package/dist/main/components/fileSystemStorage.d.ts +4 -1
  13. package/dist/main/componentsInit.d.ts +0 -1
  14. package/dist/main/electron/preload/apiTypes.d.ts +2 -1
  15. package/dist/main/index.d.ts +0 -1
  16. package/dist/main/index.es.js +45 -37
  17. package/dist/main/index.es.js.map +1 -1
  18. package/dist/main/index.umd.js +1 -1
  19. package/dist/main/index.umd.js.map +1 -1
  20. package/dist/preload/components/FileSystemConfig.d.ts +0 -1
  21. package/dist/preload/components/fileSystemStorage.d.ts +4 -1
  22. package/dist/preload/componentsInit.d.ts +0 -1
  23. package/dist/preload/electron/preload/apiTypes.d.ts +2 -1
  24. package/dist/preload/index.d.ts +0 -1
  25. package/dist/preload/index.es.js +45 -37
  26. package/dist/preload/index.es.js.map +1 -1
  27. package/dist/preload/index.umd.js +1 -1
  28. package/dist/preload/index.umd.js.map +1 -1
  29. package/package.json +6 -8
  30. package/src/components/FileSystemConfig.ts +3 -3
  31. package/src/components/fileSystemStorage.ts +11 -1
  32. package/src/electron/main/index.ts +44 -5
  33. package/src/electron/preload/apiTypes.ts +4 -0
  34. package/src/electron/preload/index.ts +9 -1
  35. package/tsdoc.json +4 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @xwiki/cristal-electron-storage
2
2
 
3
+ ## 0.11.0
4
+
5
+ ### Minor Changes
6
+
7
+ - d54422d: Cristal 0.11 Release
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [d54422d]
12
+ - @xwiki/cristal-api@0.11.0
13
+ - @xwiki/cristal-backend-api@0.11.0
14
+
15
+ ## 0.10.0
16
+
17
+ ### Minor Changes
18
+
19
+ - fa7fe9f: Cristal 0.10 Release
20
+
21
+ ### Patch Changes
22
+
23
+ - Updated dependencies [fa7fe9f]
24
+ - @xwiki/cristal-api@0.10.0
25
+ - @xwiki/cristal-backend-api@0.10.0
26
+
3
27
  ## 0.9.0
4
28
 
5
29
  ### Minor Changes
@@ -1,5 +1,4 @@
1
1
  import { CristalApp, DefaultWikiConfig, Logger, Storage } from '@xwiki/cristal-api';
2
-
3
2
  export declare class FileSystemConfig extends DefaultWikiConfig {
4
3
  storage: Storage;
5
4
  cristal: CristalApp;
@@ -1,6 +1,5 @@
1
1
  import { AttachmentsData, Logger, PageData } from '@xwiki/cristal-api';
2
2
  import { AbstractStorage } from '@xwiki/cristal-backend-api';
3
-
4
3
  export default class FileSystemStorage extends AbstractStorage {
5
4
  constructor(logger: Logger);
6
5
  getEditField(): Promise<string>;
@@ -13,5 +12,9 @@ export default class FileSystemStorage extends AbstractStorage {
13
12
  isStorageReady(): Promise<boolean>;
14
13
  save(page: string, content: string, title: string): Promise<void>;
15
14
  saveAttachments(page: string, files: File[]): Promise<unknown>;
15
+ delete(page: string): Promise<{
16
+ success: boolean;
17
+ error?: string;
18
+ }>;
16
19
  private saveAttachment;
17
20
  }
@@ -1,6 +1,5 @@
1
1
  import { Container } from 'inversify';
2
2
  import { Logger } from '@xwiki/cristal-api';
3
-
4
3
  export default class ComponentInit {
5
4
  logger: Logger;
6
5
  constructor(container: Container);
@@ -1,5 +1,4 @@
1
1
  import { PageAttachment, PageData } from '@xwiki/cristal-api';
2
-
3
2
  export interface APITypes {
4
3
  resolvePath(page: string): Promise<string>;
5
4
  resolveAttachmentsPath(page: string): Promise<string>;
@@ -8,4 +7,6 @@ export interface APITypes {
8
7
  readAttachments(path: string): Promise<PageAttachment[]>;
9
8
  savePage(path: string, content: string, title: string): Promise<PageData>;
10
9
  saveAttachment(path: string, file: File): Promise<PageData>;
10
+ listChildren(page: string): Promise<Array<string>>;
11
+ deletePage(path: string): Promise<void>;
11
12
  }
@@ -1,3 +1,2 @@
1
1
  import { default as ComponentInit } from './componentsInit';
2
-
3
2
  export { ComponentInit };
@@ -1,34 +1,34 @@
1
1
  import { injectable as c, inject as g, named as h } from "inversify";
2
- import { DefaultWikiConfig as p, DefaultPageData as S } from "@xwiki/cristal-api";
3
- import { AbstractStorage as f } from "@xwiki/cristal-backend-api";
4
- var u = Object.defineProperty, P = Object.getOwnPropertyDescriptor, v = (a, e, r, t) => {
5
- for (var s = t > 1 ? void 0 : t ? P(e, r) : e, o = a.length - 1, n; o >= 0; o--)
6
- (n = a[o]) && (s = (t ? n(e, r, s) : n(s)) || s);
7
- return t && s && u(e, r, s), s;
8
- }, i = (a, e) => (r, t) => e(r, t, a);
9
- let m = class extends p {
10
- constructor(a, e, r) {
11
- super(a), this.storage = e, this.cristal = r, this.storage.setWikiConfig(this), this.homePage === "" && (this.homePage = "index.md");
2
+ import { DefaultWikiConfig as S, DefaultPageData as p } from "@xwiki/cristal-api";
3
+ import { AbstractStorage as u } from "@xwiki/cristal-backend-api";
4
+ var f = Object.defineProperty, P = Object.getOwnPropertyDescriptor, d = (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 && f(e, r, s), s;
8
+ }, i = (t, e) => (r, a) => e(r, a, t);
9
+ let l = class extends S {
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
- m = v([
17
+ l = d([
18
18
  c(),
19
19
  i(0, g("Logger")),
20
20
  i(1, g("Storage")),
21
21
  i(1, h("FileSystem")),
22
22
  i(2, g("CristalApp"))
23
- ], m);
24
- var d = Object.defineProperty, y = Object.getOwnPropertyDescriptor, w = (a, e, r, t) => {
25
- for (var s = t > 1 ? void 0 : t ? y(e, r) : e, o = a.length - 1, n; o >= 0; o--)
26
- (n = a[o]) && (s = (t ? n(e, r, s) : n(s)) || s);
27
- return t && s && d(e, r, s), s;
28
- }, _ = (a, e) => (r, t) => e(r, t, a);
29
- let l = class extends f {
30
- constructor(a) {
31
- super(a, "storage.components.fileSystemStorage");
23
+ ], l);
24
+ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, w = (t, e, r, a) => {
25
+ for (var s = a > 1 ? void 0 : a ? y(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 u {
30
+ constructor(t) {
31
+ super(t, "storage.components.fileSystemStorage");
32
32
  }
33
33
  getEditField() {
34
34
  return Promise.resolve("");
@@ -36,12 +36,12 @@ let l = class extends f {
36
36
  getImageURL() {
37
37
  return "";
38
38
  }
39
- async getPageContent(a) {
40
- const e = decodeURIComponent(a), r = await fileSystemStorage.resolvePath(e), t = await fileSystemStorage.readPage(r || "");
41
- return t && (t.id = e, t.headline = t.name, t.headlineRaw = t.name), t;
39
+ async getPageContent(t) {
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
- async getAttachments(a) {
44
- const e = await fileSystemStorage.resolveAttachmentsPath(a);
43
+ async getAttachments(t) {
44
+ const e = await fileSystemStorage.resolveAttachmentsPath(t);
45
45
  return {
46
46
  attachments: await fileSystemStorage.readAttachments(e)
47
47
  };
@@ -53,31 +53,39 @@ let l = class extends f {
53
53
  return "";
54
54
  }
55
55
  getPanelContent() {
56
- return Promise.resolve(new S());
56
+ return Promise.resolve(new p());
57
57
  }
58
58
  isStorageReady() {
59
59
  return Promise.resolve(!0);
60
60
  }
61
- async save(a, e, r) {
62
- const t = await fileSystemStorage.resolvePath(a);
63
- await fileSystemStorage.savePage(t, e, r);
61
+ async save(t, e, r) {
62
+ const a = await fileSystemStorage.resolvePath(t);
63
+ await fileSystemStorage.savePage(a, e, r);
64
+ }
65
+ async saveAttachments(t, e) {
66
+ return Promise.all(e.map((r) => this.saveAttachment(t, r)));
64
67
  }
65
- async saveAttachments(a, e) {
66
- return Promise.all(e.map((r) => this.saveAttachment(a, r)));
68
+ async delete(t) {
69
+ try {
70
+ const e = await fileSystemStorage.resolvePath(t);
71
+ return await fileSystemStorage.deletePage(e), { success: !0 };
72
+ } catch (e) {
73
+ return { success: !1, error: e.message };
74
+ }
67
75
  }
68
- async saveAttachment(a, e) {
69
- const r = await fileSystemStorage.resolveAttachmentPath(a, e.name);
76
+ async saveAttachment(t, e) {
77
+ const r = await fileSystemStorage.resolveAttachmentPath(t, e.name);
70
78
  await fileSystemStorage.saveAttachment(r, e);
71
79
  }
72
80
  };
73
- l = w([
81
+ m = w([
74
82
  c(),
75
83
  _(0, g("Logger"))
76
- ], l);
84
+ ], m);
77
85
  class D {
78
86
  constructor(e) {
79
- var r, t;
80
- 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(l).whenTargetNamed("FileSystem"), (t = this.logger) == null || t.debug("Init Sample Module components end");
87
+ var r, a;
88
+ 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");
81
89
  }
82
90
  }
83
91
  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 { inject, injectable, named } from \"inversify\";\nimport {\n type CristalApp,\n DefaultWikiConfig,\n type Logger,\n type Storage,\n} from \"@xwiki/cristal-api\";\n\n@injectable()\nexport class FileSystemConfig extends DefaultWikiConfig {\n storage: Storage;\n 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 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 { inject, injectable } from \"inversify\";\nimport {\n AttachmentsData,\n DefaultPageData,\n type Logger,\n PageData,\n} from \"@xwiki/cristal-api\";\nimport { AbstractStorage } from \"@xwiki/cristal-backend-api\";\nimport { APITypes } from \"../electron/preload/apiTypes\";\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 = decodeURIComponent(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 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 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 type { Container } from \"inversify\";\nimport type { Logger, Storage, WikiConfig } from \"@xwiki/cristal-api\";\nimport { FileSystemConfig } from \"./components/FileSystemConfig\";\nimport FileSystemStorage from \"./components/fileSystemStorage\";\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","DefaultPageData","content","title","files","file","ComponentInit","container","_a","_b"],"mappings":";;;;;;;;AA6Ba,IAAAA,IAAN,cAA+BC,EAAkB;AAAA,EAGtD,YAC4BC,GACc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AQ,QAAQ,EAAI;AAAA,EAC7B;AAAA,EAEA,MAAM,KAAKJ,GAAcK,GAAiBC,GAA8B;AACtE,UAAMJ,IAAO,MAAM,kBAAkB,YAAYF,CAAI;AACrD,UAAM,kBAAkB,SAASE,GAAMG,GAASC,CAAK;AAAA,EACvD;AAAA,EAEA,MAAM,gBAAgBN,GAAcO,GAAiC;AAC5D,WAAA,QAAQ,IAAIA,EAAM,IAAI,CAACC,MAAS,KAAK,eAAeR,GAAMQ,CAAI,CAAC,CAAC;AAAA,EACzE;AAAA,EAEA,MAAc,eAAeR,GAAcQ,GAA8B;AACvE,UAAMN,IAAO,MAAM,kBAAkB,sBAAsBF,GAAMQ,EAAK,IAAI;AACpE,UAAA,kBAAkB,eAAeN,GAAMM,CAAI;AAAA,EAEnD;AACF;AA9DqBV,IAArBH,EAAA;AAAA,EADCC,EAAW;AAAA,EAEGC,OAAe,QAAQ,CAAA;AAAA,GADjBC,CAAA;ACRrB,MAAqBW,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,GAAGpB,CAAgB,EACnB,gBAAgB,YAAY,GAC/BoB,EACG,KAAc,SAAS,EACvB,GAAGZ,CAAiB,EACpB,gBAAgB,YAAY,IAC1Bc,IAAA,KAAA,WAAA,QAAAA,EAAQ,MAAM;AAAA,EACrB;AACF;"}
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 { inject, injectable, named } from \"inversify\";\nimport {\n type CristalApp,\n DefaultWikiConfig,\n type Logger,\n type Storage,\n} 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 { inject, injectable } from \"inversify\";\nimport {\n AttachmentsData,\n DefaultPageData,\n type Logger,\n PageData,\n} from \"@xwiki/cristal-api\";\nimport { AbstractStorage } from \"@xwiki/cristal-backend-api\";\nimport { APITypes } from \"../electron/preload/apiTypes\";\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 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 type { Container } from \"inversify\";\nimport type { Logger, Storage, WikiConfig } from \"@xwiki/cristal-api\";\nimport { FileSystemConfig } from \"./components/FileSystemConfig\";\nimport FileSystemStorage from \"./components/fileSystemStorage\";\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","DefaultPageData","content","title","files","file","error","ComponentInit","container","_a","_b"],"mappings":";;;;;;;;AA6Ba,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,EAEpB;AAAA,EAES,UAAkB;AAClB,WAAA;AAAA,EACT;AACF;AApBaJ,IAANK,EAAA;AAAA,EADNC,EAAW;AAAA,EAKPC,OAAe,QAAQ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IAAI,CAACC,MAAS,KAAK,eAAeR,GAAMQ,CAAI,CAAC,CAAC;AAAA,EACzE;AAAA,EAEA,MAAM,OAAOR,GAA6D;AACpE,QAAA;AACF,YAAME,IAAO,MAAM,kBAAkB,YAAYF,CAAI;AAC/C,mBAAA,kBAAkB,WAAWE,CAAI,GAChC,EAAE,SAAS;aACXO,GAAO;AACd,aAAO,EAAE,SAAS,IAAO,OAAQA,EAAgB,QAAQ;AAAA,IAC3D;AAAA,EACF;AAAA,EAEA,MAAc,eAAeT,GAAcQ,GAA8B;AACvE,UAAMN,IAAO,MAAM,kBAAkB,sBAAsBF,GAAMQ,EAAK,IAAI;AACpE,UAAA,kBAAkB,eAAeN,GAAMM,CAAI;AAAA,EAEnD;AACF;AAxEqBV,IAArBH,EAAA;AAAA,EADCC,EAAW;AAAA,EAEGC,OAAe,QAAQ,CAAA;AAAA,GADjBC,CAAA;ACRrB,MAAqBY,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,GAAGrB,CAAgB,EACnB,gBAAgB,YAAY,GAC/BqB,EACG,KAAc,SAAS,EACvB,GAAGb,CAAiB,EACpB,gBAAgB,YAAY,IAC1Be,IAAA,KAAA,WAAA,QAAAA,EAAQ,MAAM;AAAA,EACrB;AACF;"}
@@ -1,2 +1,2 @@
1
- (function(i,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("inversify"),require("@xwiki/cristal-api"),require("@xwiki/cristal-backend-api")):typeof define=="function"&&define.amd?define(["exports","inversify","@xwiki/cristal-api","@xwiki/cristal-backend-api"],n):(i=typeof globalThis<"u"?globalThis:i||self,n(i.cristal_storage={},i.inversify,i.cristalApi,i.cristalBackendApi))})(this,function(i,n,p,u){"use strict";var d=Object.defineProperty,h=Object.getOwnPropertyDescriptor,f=(a,e,r,t)=>{for(var s=t>1?void 0:t?h(e,r):e,o=a.length-1,c;o>=0;o--)(c=a[o])&&(s=(t?c(e,r,s):c(s))||s);return t&&s&&d(e,r,s),s},g=(a,e)=>(r,t)=>e(r,t,a);let l=class extends p.DefaultWikiConfig{constructor(a,e,r){super(a),this.storage=e,this.cristal=r,this.storage.setWikiConfig(this),this.homePage===""&&(this.homePage="index.md")}getType(){return"FileSystem"}};l=f([n.injectable(),g(0,n.inject("Logger")),g(1,n.inject("Storage")),g(1,n.named("FileSystem")),g(2,n.inject("CristalApp"))],l);var S=Object.defineProperty,P=Object.getOwnPropertyDescriptor,v=(a,e,r,t)=>{for(var s=t>1?void 0:t?P(e,r):e,o=a.length-1,c;o>=0;o--)(c=a[o])&&(s=(t?c(e,r,s):c(s))||s);return t&&s&&S(e,r,s),s},y=(a,e)=>(r,t)=>e(r,t,a);let m=class extends u.AbstractStorage{constructor(a){super(a,"storage.components.fileSystemStorage")}getEditField(){return Promise.resolve("")}getImageURL(){return""}async getPageContent(a){const e=decodeURIComponent(a),r=await fileSystemStorage.resolvePath(e),t=await fileSystemStorage.readPage(r||"");return t&&(t.id=e,t.headline=t.name,t.headlineRaw=t.name),t}async getAttachments(a){const e=await fileSystemStorage.resolveAttachmentsPath(a);return{attachments:await fileSystemStorage.readAttachments(e)}}getPageFromViewURL(){return null}getPageRestURL(){return""}getPanelContent(){return Promise.resolve(new p.DefaultPageData)}isStorageReady(){return Promise.resolve(!0)}async save(a,e,r){const t=await fileSystemStorage.resolvePath(a);await fileSystemStorage.savePage(t,e,r)}async saveAttachments(a,e){return Promise.all(e.map(r=>this.saveAttachment(a,r)))}async saveAttachment(a,e){const r=await fileSystemStorage.resolveAttachmentPath(a,e.name);await fileSystemStorage.saveAttachment(r,e)}};m=v([n.injectable(),y(0,n.inject("Logger"))],m);class w{constructor(e){var r,t;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"),(t=this.logger)==null||t.debug("Init Sample Module components end")}}i.ComponentInit=w,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
1
+ (function(n,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("inversify"),require("@xwiki/cristal-api"),require("@xwiki/cristal-backend-api")):typeof define=="function"&&define.amd?define(["exports","inversify","@xwiki/cristal-api","@xwiki/cristal-backend-api"],i):(n=typeof globalThis<"u"?globalThis:n||self,i(n.cristal_storage={},n.inversify,n.cristalApi,n.cristalBackendApi))})(this,function(n,i,u,p){"use strict";var d=Object.defineProperty,h=Object.getOwnPropertyDescriptor,f=(t,e,r,a)=>{for(var s=a>1?void 0:a?h(e,r):e,o=t.length-1,c;o>=0;o--)(c=t[o])&&(s=(a?c(e,r,s):c(s))||s);return a&&s&&d(e,r,s),s},l=(t,e)=>(r,a)=>e(r,a,t);let g=class extends u.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"}};g=f([i.injectable(),l(0,i.inject("Logger")),l(1,i.inject("Storage")),l(1,i.named("FileSystem")),l(2,i.inject("CristalApp"))],g);var S=Object.defineProperty,P=Object.getOwnPropertyDescriptor,y=(t,e,r,a)=>{for(var s=a>1?void 0:a?P(e,r):e,o=t.length-1,c;o>=0;o--)(c=t[o])&&(s=(a?c(e,r,s):c(s))||s);return a&&s&&S(e,r,s),s},v=(t,e)=>(r,a)=>e(r,a,t);let m=class extends p.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)}}getPageFromViewURL(){return null}getPageRestURL(){return""}getPanelContent(){return Promise.resolve(new u.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 saveAttachment(t,e){const r=await fileSystemStorage.resolveAttachmentPath(t,e.name);await fileSystemStorage.saveAttachment(r,e)}};m=y([i.injectable(),v(0,i.inject("Logger"))],m);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(g).whenTargetNamed("FileSystem"),e.bind("Storage").to(m).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 { inject, injectable, named } from \"inversify\";\nimport {\n type CristalApp,\n DefaultWikiConfig,\n type Logger,\n type Storage,\n} from \"@xwiki/cristal-api\";\n\n@injectable()\nexport class FileSystemConfig extends DefaultWikiConfig {\n storage: Storage;\n 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 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 { inject, injectable } from \"inversify\";\nimport {\n AttachmentsData,\n DefaultPageData,\n type Logger,\n PageData,\n} from \"@xwiki/cristal-api\";\nimport { AbstractStorage } from \"@xwiki/cristal-backend-api\";\nimport { APITypes } from \"../electron/preload/apiTypes\";\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 = decodeURIComponent(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 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 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 type { Container } from \"inversify\";\nimport type { Logger, Storage, WikiConfig } from \"@xwiki/cristal-api\";\nimport { FileSystemConfig } from \"./components/FileSystemConfig\";\nimport FileSystemStorage from \"./components/fileSystemStorage\";\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","DefaultPageData","content","title","files","file","ComponentInit","container","_a","_b"],"mappings":"0oBA6Ba,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,WAEpB,CAEA,SAAkB,CACT,MAAA,YACT,CACF,EApBaJ,EAANK,EAAA,CADNC,aAAW,EAKPC,aAAe,QAAQ,CAAA,EACvBA,aAAO,SAAS,CAAA,EAAGA,YAAM,YAAY,CAAA,EACrCA,aAAO,YAAY,CAAA,CAAA,EANXP,CAAA,2NCIb,IAAqBQ,EAArB,cAA+CC,EAAAA,eAAgB,CAC7D,YAAsCP,EAAgB,CACpD,MAAMA,EAAQ,sCAAsC,CACtD,CAEA,cAAgC,CACvB,OAAA,QAAQ,QAAQ,EAAE,CAC3B,CAEA,aAAsB,CACb,MAAA,EACT,CAEA,MAAM,eAAeQ,EAAiC,CAC9C,MAAAC,EAAc,mBAAmBD,CAAI,EACrCE,EAAO,MAAM,kBAAkB,YAAYD,CAAW,EACtDE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EACvB,GAAGZ,CAAiB,EACpB,gBAAgB,YAAY,GAC1Bc,EAAA,KAAA,SAAA,MAAAA,EAAQ,MAAM,oCACrB,CACF"}
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 { inject, injectable, named } from \"inversify\";\nimport {\n type CristalApp,\n DefaultWikiConfig,\n type Logger,\n type Storage,\n} 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 { inject, injectable } from \"inversify\";\nimport {\n AttachmentsData,\n DefaultPageData,\n type Logger,\n PageData,\n} from \"@xwiki/cristal-api\";\nimport { AbstractStorage } from \"@xwiki/cristal-backend-api\";\nimport { APITypes } from \"../electron/preload/apiTypes\";\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 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 type { Container } from \"inversify\";\nimport type { Logger, Storage, WikiConfig } from \"@xwiki/cristal-api\";\nimport { FileSystemConfig } from \"./components/FileSystemConfig\";\nimport FileSystemStorage from \"./components/fileSystemStorage\";\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","DefaultP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K,EAAiBC,EAA8B,CACtE,MAAMJ,EAAO,MAAM,kBAAkB,YAAYF,CAAI,EACrD,MAAM,kBAAkB,SAASE,EAAMG,EAASC,CAAK,CACvD,CAEA,MAAM,gBAAgBN,EAAcO,EAAiC,CAC5D,OAAA,QAAQ,IAAIA,EAAM,IAAKC,GAAS,KAAK,eAAeR,EAAMQ,CAAI,CAAC,CAAC,CACzE,CAEA,MAAM,OAAOR,EAA6D,CACpE,GAAA,CACF,MAAME,EAAO,MAAM,kBAAkB,YAAYF,CAAI,EAC/C,aAAA,kBAAkB,WAAWE,CAAI,EAChC,CAAE,QAAS,UACXO,EAAO,CACd,MAAO,CAAE,QAAS,GAAO,MAAQA,EAAgB,OAAQ,CAC3D,CACF,CAEA,MAAc,eAAeT,EAAcQ,EAA8B,CACvE,MAAMN,EAAO,MAAM,kBAAkB,sBAAsBF,EAAMQ,EAAK,IAAI,EACpE,MAAA,kBAAkB,eAAeN,EAAMM,CAAI,CAEnD,CACF,EAxEqBV,EAArBH,EAAA,CADCC,aAAW,EAEGC,aAAe,QAAQ,CAAA,CAAA,EADjBC,CAAA,ECRrB,MAAqBY,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,GAAGrB,CAAgB,EACnB,gBAAgB,YAAY,EAC/BqB,EACG,KAAc,SAAS,EACvB,GAAGb,CAAiB,EACpB,gBAAgB,YAAY,GAC1Be,EAAA,KAAA,SAAA,MAAAA,EAAQ,MAAM,oCACrB,CACF"}
@@ -1,5 +1,4 @@
1
1
  import { CristalApp, DefaultWikiConfig, Logger, Storage } from '@xwiki/cristal-api';
2
-
3
2
  export declare class FileSystemConfig extends DefaultWikiConfig {
4
3
  storage: Storage;
5
4
  cristal: CristalApp;
@@ -1,6 +1,5 @@
1
1
  import { AttachmentsData, Logger, PageData } from '@xwiki/cristal-api';
2
2
  import { AbstractStorage } from '@xwiki/cristal-backend-api';
3
-
4
3
  export default class FileSystemStorage extends AbstractStorage {
5
4
  constructor(logger: Logger);
6
5
  getEditField(): Promise<string>;
@@ -13,5 +12,9 @@ export default class FileSystemStorage extends AbstractStorage {
13
12
  isStorageReady(): Promise<boolean>;
14
13
  save(page: string, content: string, title: string): Promise<void>;
15
14
  saveAttachments(page: string, files: File[]): Promise<unknown>;
15
+ delete(page: string): Promise<{
16
+ success: boolean;
17
+ error?: string;
18
+ }>;
16
19
  private saveAttachment;
17
20
  }
@@ -1,6 +1,5 @@
1
1
  import { Container } from 'inversify';
2
2
  import { Logger } from '@xwiki/cristal-api';
3
-
4
3
  export default class ComponentInit {
5
4
  logger: Logger;
6
5
  constructor(container: Container);
@@ -1,5 +1,4 @@
1
1
  import { PageAttachment, PageData } from '@xwiki/cristal-api';
2
-
3
2
  export interface APITypes {
4
3
  resolvePath(page: string): Promise<string>;
5
4
  resolveAttachmentsPath(page: string): Promise<string>;
@@ -8,4 +7,6 @@ export interface APITypes {
8
7
  readAttachments(path: string): Promise<PageAttachment[]>;
9
8
  savePage(path: string, content: string, title: string): Promise<PageData>;
10
9
  saveAttachment(path: string, file: File): Promise<PageData>;
10
+ listChildren(page: string): Promise<Array<string>>;
11
+ deletePage(path: string): Promise<void>;
11
12
  }
@@ -1,3 +1,2 @@
1
1
  import { default as ComponentInit } from './componentsInit';
2
-
3
2
  export { ComponentInit };
@@ -1,34 +1,34 @@
1
1
  import { injectable as c, inject as g, named as h } from "inversify";
2
- import { DefaultWikiConfig as p, DefaultPageData as S } from "@xwiki/cristal-api";
3
- import { AbstractStorage as f } from "@xwiki/cristal-backend-api";
4
- var u = Object.defineProperty, P = Object.getOwnPropertyDescriptor, v = (a, e, r, t) => {
5
- for (var s = t > 1 ? void 0 : t ? P(e, r) : e, o = a.length - 1, n; o >= 0; o--)
6
- (n = a[o]) && (s = (t ? n(e, r, s) : n(s)) || s);
7
- return t && s && u(e, r, s), s;
8
- }, i = (a, e) => (r, t) => e(r, t, a);
9
- let m = class extends p {
10
- constructor(a, e, r) {
11
- super(a), this.storage = e, this.cristal = r, this.storage.setWikiConfig(this), this.homePage === "" && (this.homePage = "index.md");
2
+ import { DefaultWikiConfig as S, DefaultPageData as p } from "@xwiki/cristal-api";
3
+ import { AbstractStorage as u } from "@xwiki/cristal-backend-api";
4
+ var f = Object.defineProperty, P = Object.getOwnPropertyDescriptor, d = (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 && f(e, r, s), s;
8
+ }, i = (t, e) => (r, a) => e(r, a, t);
9
+ let l = class extends S {
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
- m = v([
17
+ l = d([
18
18
  c(),
19
19
  i(0, g("Logger")),
20
20
  i(1, g("Storage")),
21
21
  i(1, h("FileSystem")),
22
22
  i(2, g("CristalApp"))
23
- ], m);
24
- var d = Object.defineProperty, y = Object.getOwnPropertyDescriptor, w = (a, e, r, t) => {
25
- for (var s = t > 1 ? void 0 : t ? y(e, r) : e, o = a.length - 1, n; o >= 0; o--)
26
- (n = a[o]) && (s = (t ? n(e, r, s) : n(s)) || s);
27
- return t && s && d(e, r, s), s;
28
- }, _ = (a, e) => (r, t) => e(r, t, a);
29
- let l = class extends f {
30
- constructor(a) {
31
- super(a, "storage.components.fileSystemStorage");
23
+ ], l);
24
+ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, w = (t, e, r, a) => {
25
+ for (var s = a > 1 ? void 0 : a ? y(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 u {
30
+ constructor(t) {
31
+ super(t, "storage.components.fileSystemStorage");
32
32
  }
33
33
  getEditField() {
34
34
  return Promise.resolve("");
@@ -36,12 +36,12 @@ let l = class extends f {
36
36
  getImageURL() {
37
37
  return "";
38
38
  }
39
- async getPageContent(a) {
40
- const e = decodeURIComponent(a), r = await fileSystemStorage.resolvePath(e), t = await fileSystemStorage.readPage(r || "");
41
- return t && (t.id = e, t.headline = t.name, t.headlineRaw = t.name), t;
39
+ async getPageContent(t) {
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
- async getAttachments(a) {
44
- const e = await fileSystemStorage.resolveAttachmentsPath(a);
43
+ async getAttachments(t) {
44
+ const e = await fileSystemStorage.resolveAttachmentsPath(t);
45
45
  return {
46
46
  attachments: await fileSystemStorage.readAttachments(e)
47
47
  };
@@ -53,31 +53,39 @@ let l = class extends f {
53
53
  return "";
54
54
  }
55
55
  getPanelContent() {
56
- return Promise.resolve(new S());
56
+ return Promise.resolve(new p());
57
57
  }
58
58
  isStorageReady() {
59
59
  return Promise.resolve(!0);
60
60
  }
61
- async save(a, e, r) {
62
- const t = await fileSystemStorage.resolvePath(a);
63
- await fileSystemStorage.savePage(t, e, r);
61
+ async save(t, e, r) {
62
+ const a = await fileSystemStorage.resolvePath(t);
63
+ await fileSystemStorage.savePage(a, e, r);
64
+ }
65
+ async saveAttachments(t, e) {
66
+ return Promise.all(e.map((r) => this.saveAttachment(t, r)));
64
67
  }
65
- async saveAttachments(a, e) {
66
- return Promise.all(e.map((r) => this.saveAttachment(a, r)));
68
+ async delete(t) {
69
+ try {
70
+ const e = await fileSystemStorage.resolvePath(t);
71
+ return await fileSystemStorage.deletePage(e), { success: !0 };
72
+ } catch (e) {
73
+ return { success: !1, error: e.message };
74
+ }
67
75
  }
68
- async saveAttachment(a, e) {
69
- const r = await fileSystemStorage.resolveAttachmentPath(a, e.name);
76
+ async saveAttachment(t, e) {
77
+ const r = await fileSystemStorage.resolveAttachmentPath(t, e.name);
70
78
  await fileSystemStorage.saveAttachment(r, e);
71
79
  }
72
80
  };
73
- l = w([
81
+ m = w([
74
82
  c(),
75
83
  _(0, g("Logger"))
76
- ], l);
84
+ ], m);
77
85
  class D {
78
86
  constructor(e) {
79
- var r, t;
80
- 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(l).whenTargetNamed("FileSystem"), (t = this.logger) == null || t.debug("Init Sample Module components end");
87
+ var r, a;
88
+ 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");
81
89
  }
82
90
  }
83
91
  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 { inject, injectable, named } from \"inversify\";\nimport {\n type CristalApp,\n DefaultWikiConfig,\n type Logger,\n type Storage,\n} from \"@xwiki/cristal-api\";\n\n@injectable()\nexport class FileSystemConfig extends DefaultWikiConfig {\n storage: Storage;\n 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 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 { inject, injectable } from \"inversify\";\nimport {\n AttachmentsData,\n DefaultPageData,\n type Logger,\n PageData,\n} from \"@xwiki/cristal-api\";\nimport { AbstractStorage } from \"@xwiki/cristal-backend-api\";\nimport { APITypes } from \"../electron/preload/apiTypes\";\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 = decodeURIComponent(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 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 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 type { Container } from \"inversify\";\nimport type { Logger, Storage, WikiConfig } from \"@xwiki/cristal-api\";\nimport { FileSystemConfig } from \"./components/FileSystemConfig\";\nimport FileSystemStorage from \"./components/fileSystemStorage\";\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","DefaultPageData","content","title","files","file","ComponentInit","container","_a","_b"],"mappings":";;;;;;;;AA6Ba,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,EAEpB;AAAA,EAEA,UAAkB;AACT,WAAA;AAAA,EACT;AACF;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;;;;;;ACIb,IAAqBQ,IAArB,cAA+CC,EAAgB;AAAA,EAC7D,YAAsCP,GAAgB;AACpD,UAAMA,GAAQ,sCAAsC;AAAA,EACtD;AAAA,EAEA,eAAgC;AACvB,WAAA,QAAQ,QAAQ,EAAE;AAAA,EAC3B;AAAA,EAEA,cAAsB;AACb,WAAA;AAAA,EACT;AAAA,EAEA,MAAM,eAAeQ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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,GAAGpB,CAAgB,EACnB,gBAAgB,YAAY,GAC/BoB,EACG,KAAc,SAAS,EACvB,GAAGZ,CAAiB,EACpB,gBAAgB,YAAY,IAC1Bc,IAAA,KAAA,WAAA,QAAAA,EAAQ,MAAM;AAAA,EACrB;AACF;"}
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 { inject, injectable, named } from \"inversify\";\nimport {\n type CristalApp,\n DefaultWikiConfig,\n type Logger,\n type Storage,\n} 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 { inject, injectable } from \"inversify\";\nimport {\n AttachmentsData,\n DefaultPageData,\n type Logger,\n PageData,\n} from \"@xwiki/cristal-api\";\nimport { AbstractStorage } from \"@xwiki/cristal-backend-api\";\nimport { APITypes } from \"../electron/preload/apiTypes\";\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 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 type { Container } from \"inversify\";\nimport type { Logger, Storage, WikiConfig } from \"@xwiki/cristal-api\";\nimport { FileSystemConfig } from \"./components/FileSystemConfig\";\nimport FileSystemStorage from \"./components/fileSystemStorage\";\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","DefaultPageData","content","title","files","file","error","ComponentInit","container","_a","_b"],"mappings":";;;;;;;;AA6Ba,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,EAEpB;AAAA,EAES,UAAkB;AAClB,WAAA;AAAA,EACT;AACF;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;;;;;;ACIb,IAAqBQ,IAArB,cAA+CC,EAAgB;AAAA,EAC7D,YAAsCP,GAAgB;AACpD,UAAMA,GAAQ,sCAAsC;AAAA,EACtD;AAAA,EAEA,eAAgC;AACvB,WAAA,QAAQ,QAAQ,EAAE;AAAA,EAC3B;AAAA,EAEA,cAAsB;AACb,WAAA;AAAA,EACT;AAAA,EAEA,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,EACT;AAAA,EAEA,MAAM,eAAe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A,EAAU,IAAY,QAAQ,GACvC,KAAA,OAAO,UAAU,4CAA4C,IAE7DC,IAAA,KAAA,WAAA,QAAAA,EAAQ,MAAM,wCACnBD,EACG,KAAiB,YAAY,EAC7B,GAAGrB,CAAgB,EACnB,gBAAgB,YAAY,GAC/BqB,EACG,KAAc,SAAS,EACvB,GAAGb,CAAiB,EACpB,gBAAgB,YAAY,IAC1Be,IAAA,KAAA,WAAA,QAAAA,EAAQ,MAAM;AAAA,EACrB;AACF;"}
@@ -1,2 +1,2 @@
1
- (function(i,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("inversify"),require("@xwiki/cristal-api"),require("@xwiki/cristal-backend-api")):typeof define=="function"&&define.amd?define(["exports","inversify","@xwiki/cristal-api","@xwiki/cristal-backend-api"],n):(i=typeof globalThis<"u"?globalThis:i||self,n(i.cristal_storage={},i.inversify,i.cristalApi,i.cristalBackendApi))})(this,function(i,n,p,u){"use strict";var d=Object.defineProperty,h=Object.getOwnPropertyDescriptor,f=(a,e,r,t)=>{for(var s=t>1?void 0:t?h(e,r):e,o=a.length-1,c;o>=0;o--)(c=a[o])&&(s=(t?c(e,r,s):c(s))||s);return t&&s&&d(e,r,s),s},g=(a,e)=>(r,t)=>e(r,t,a);let l=class extends p.DefaultWikiConfig{constructor(a,e,r){super(a),this.storage=e,this.cristal=r,this.storage.setWikiConfig(this),this.homePage===""&&(this.homePage="index.md")}getType(){return"FileSystem"}};l=f([n.injectable(),g(0,n.inject("Logger")),g(1,n.inject("Storage")),g(1,n.named("FileSystem")),g(2,n.inject("CristalApp"))],l);var S=Object.defineProperty,P=Object.getOwnPropertyDescriptor,v=(a,e,r,t)=>{for(var s=t>1?void 0:t?P(e,r):e,o=a.length-1,c;o>=0;o--)(c=a[o])&&(s=(t?c(e,r,s):c(s))||s);return t&&s&&S(e,r,s),s},y=(a,e)=>(r,t)=>e(r,t,a);let m=class extends u.AbstractStorage{constructor(a){super(a,"storage.components.fileSystemStorage")}getEditField(){return Promise.resolve("")}getImageURL(){return""}async getPageContent(a){const e=decodeURIComponent(a),r=await fileSystemStorage.resolvePath(e),t=await fileSystemStorage.readPage(r||"");return t&&(t.id=e,t.headline=t.name,t.headlineRaw=t.name),t}async getAttachments(a){const e=await fileSystemStorage.resolveAttachmentsPath(a);return{attachments:await fileSystemStorage.readAttachments(e)}}getPageFromViewURL(){return null}getPageRestURL(){return""}getPanelContent(){return Promise.resolve(new p.DefaultPageData)}isStorageReady(){return Promise.resolve(!0)}async save(a,e,r){const t=await fileSystemStorage.resolvePath(a);await fileSystemStorage.savePage(t,e,r)}async saveAttachments(a,e){return Promise.all(e.map(r=>this.saveAttachment(a,r)))}async saveAttachment(a,e){const r=await fileSystemStorage.resolveAttachmentPath(a,e.name);await fileSystemStorage.saveAttachment(r,e)}};m=v([n.injectable(),y(0,n.inject("Logger"))],m);class w{constructor(e){var r,t;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"),(t=this.logger)==null||t.debug("Init Sample Module components end")}}i.ComponentInit=w,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
1
+ (function(n,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("inversify"),require("@xwiki/cristal-api"),require("@xwiki/cristal-backend-api")):typeof define=="function"&&define.amd?define(["exports","inversify","@xwiki/cristal-api","@xwiki/cristal-backend-api"],i):(n=typeof globalThis<"u"?globalThis:n||self,i(n.cristal_storage={},n.inversify,n.cristalApi,n.cristalBackendApi))})(this,function(n,i,u,p){"use strict";var d=Object.defineProperty,h=Object.getOwnPropertyDescriptor,f=(t,e,r,a)=>{for(var s=a>1?void 0:a?h(e,r):e,o=t.length-1,c;o>=0;o--)(c=t[o])&&(s=(a?c(e,r,s):c(s))||s);return a&&s&&d(e,r,s),s},l=(t,e)=>(r,a)=>e(r,a,t);let g=class extends u.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"}};g=f([i.injectable(),l(0,i.inject("Logger")),l(1,i.inject("Storage")),l(1,i.named("FileSystem")),l(2,i.inject("CristalApp"))],g);var S=Object.defineProperty,P=Object.getOwnPropertyDescriptor,y=(t,e,r,a)=>{for(var s=a>1?void 0:a?P(e,r):e,o=t.length-1,c;o>=0;o--)(c=t[o])&&(s=(a?c(e,r,s):c(s))||s);return a&&s&&S(e,r,s),s},v=(t,e)=>(r,a)=>e(r,a,t);let m=class extends p.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)}}getPageFromViewURL(){return null}getPageRestURL(){return""}getPanelContent(){return Promise.resolve(new u.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 saveAttachment(t,e){const r=await fileSystemStorage.resolveAttachmentPath(t,e.name);await fileSystemStorage.saveAttachment(r,e)}};m=y([i.injectable(),v(0,i.inject("Logger"))],m);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(g).whenTargetNamed("FileSystem"),e.bind("Storage").to(m).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 { inject, injectable, named } from \"inversify\";\nimport {\n type CristalApp,\n DefaultWikiConfig,\n type Logger,\n type Storage,\n} from \"@xwiki/cristal-api\";\n\n@injectable()\nexport class FileSystemConfig extends DefaultWikiConfig {\n storage: Storage;\n 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 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 { inject, injectable } from \"inversify\";\nimport {\n AttachmentsData,\n DefaultPageData,\n type Logger,\n PageData,\n} from \"@xwiki/cristal-api\";\nimport { AbstractStorage } from \"@xwiki/cristal-backend-api\";\nimport { APITypes } from \"../electron/preload/apiTypes\";\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 = decodeURIComponent(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 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 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 type { Container } from \"inversify\";\nimport type { Logger, Storage, WikiConfig } from \"@xwiki/cristal-api\";\nimport { FileSystemConfig } from \"./components/FileSystemConfig\";\nimport FileSystemStorage from \"./components/fileSystemStorage\";\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","DefaultPageData","content","title","files","file","ComponentInit","container","_a","_b"],"mappings":"0oBA6Ba,IAAAA,EAAN,cAA+BC,EAAAA,iBAAkB,CAGtD,YAC4BC,EACcC,EAClBC,EACtB,CACA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M,gBAAgBN,EAAcO,EAAiC,CAC5D,OAAA,QAAQ,IAAIA,EAAM,IAAKC,GAAS,KAAK,eAAeR,EAAMQ,CAAI,CAAC,CAAC,CACzE,CAEA,MAAc,eAAeR,EAAcQ,EAA8B,CACvE,MAAMN,EAAO,MAAM,kBAAkB,sBAAsBF,EAAMQ,EAAK,IAAI,EACpE,MAAA,kBAAkB,eAAeN,EAAMM,CAAI,CAEnD,CACF,EA9DqBV,EAArBH,EAAA,CADCC,aAAW,EAEGC,aAAe,QAAQ,CAAA,CAAA,EADjBC,CAAA,ECRrB,MAAqBW,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,GAAGpB,CAAgB,EACnB,gBAAgB,YAAY,EAC/BoB,EACG,KAAc,SAAS,EACvB,GAAGZ,CAAiB,EACpB,gBAAgB,YAAY,GAC1Bc,EAAA,KAAA,SAAA,MAAAA,EAAQ,MAAM,oCACrB,CACF"}
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 { inject, injectable, named } from \"inversify\";\nimport {\n type CristalApp,\n DefaultWikiConfig,\n type Logger,\n type Storage,\n} 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 { inject, injectable } from \"inversify\";\nimport {\n AttachmentsData,\n DefaultPageData,\n type Logger,\n PageData,\n} from \"@xwiki/cristal-api\";\nimport { AbstractStorage } from \"@xwiki/cristal-backend-api\";\nimport { APITypes } from \"../electron/preload/apiTypes\";\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 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 type { Container } from \"inversify\";\nimport type { Logger, Storage, WikiConfig } from \"@xwiki/cristal-api\";\nimport { FileSystemConfig } from \"./components/FileSystemConfig\";\nimport FileSystemStorage from \"./components/fileSystemStorage\";\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","DefaultPageData","content","title","files","file","error","ComponentInit","container","_a","_b"],"mappings":"0oBA6Ba,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,WAEpB,CAES,SAAkB,CAClB,MAAA,YACT,CACF,EApBaJ,EAANK,EAAA,CADNC,aAAW,EAKPC,aAAe,QAAQ,CAAA,EACvBA,aAAO,SAAS,CAAA,EAAGA,YAAM,YAAY,CAAA,EACrCA,aAAO,YAAY,CAAA,CAAA,EANXP,CAAA,2NCIb,IAAqBQ,EAArB,cAA+CC,EAAAA,eAAgB,CAC7D,YAAsCP,EAAgB,CACpD,MAAMA,EAAQ,sCAAsC,CACtD,CAEA,cAAgC,CACvB,OAAA,QAAQ,QAAQ,EAAE,CAC3B,CAEA,aAAsB,CACb,MAAA,E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H,EAAA,CADCC,aAAW,EAEGC,aAAe,QAAQ,CAAA,CAAA,EADjBC,CAAA,ECRrB,MAAqBY,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,GAAGrB,CAAgB,EACnB,gBAAgB,YAAY,EAC/BqB,EACG,KAAc,SAAS,EACvB,GAAGb,CAAiB,EACpB,gBAAgB,YAAY,GAC1Be,EAAA,KAAA,SAAA,MAAAA,EAAQ,MAAM,oCACrB,CACF"}
@@ -1,5 +1,4 @@
1
1
  import { CristalApp, DefaultWikiConfig, Logger, Storage } from '@xwiki/cristal-api';
2
-
3
2
  export declare class FileSystemConfig extends DefaultWikiConfig {
4
3
  storage: Storage;
5
4
  cristal: CristalApp;
@@ -1,6 +1,5 @@
1
1
  import { AttachmentsData, Logger, PageData } from '@xwiki/cristal-api';
2
2
  import { AbstractStorage } from '@xwiki/cristal-backend-api';
3
-
4
3
  export default class FileSystemStorage extends AbstractStorage {
5
4
  constructor(logger: Logger);
6
5
  getEditField(): Promise<string>;
@@ -13,5 +12,9 @@ export default class FileSystemStorage extends AbstractStorage {
13
12
  isStorageReady(): Promise<boolean>;
14
13
  save(page: string, content: string, title: string): Promise<void>;
15
14
  saveAttachments(page: string, files: File[]): Promise<unknown>;
15
+ delete(page: string): Promise<{
16
+ success: boolean;
17
+ error?: string;
18
+ }>;
16
19
  private saveAttachment;
17
20
  }
@@ -1,6 +1,5 @@
1
1
  import { Container } from 'inversify';
2
2
  import { Logger } from '@xwiki/cristal-api';
3
-
4
3
  export default class ComponentInit {
5
4
  logger: Logger;
6
5
  constructor(container: Container);
@@ -1,5 +1,4 @@
1
1
  import { PageAttachment, PageData } from '@xwiki/cristal-api';
2
-
3
2
  export interface APITypes {
4
3
  resolvePath(page: string): Promise<string>;
5
4
  resolveAttachmentsPath(page: string): Promise<string>;
@@ -8,4 +7,6 @@ export interface APITypes {
8
7
  readAttachments(path: string): Promise<PageAttachment[]>;
9
8
  savePage(path: string, content: string, title: string): Promise<PageData>;
10
9
  saveAttachment(path: string, file: File): Promise<PageData>;
10
+ listChildren(page: string): Promise<Array<string>>;
11
+ deletePage(path: string): Promise<void>;
11
12
  }
@@ -1,3 +1,2 @@
1
1
  import { default as ComponentInit } from './componentsInit';
2
-
3
2
  export { ComponentInit };
@@ -1,34 +1,34 @@
1
1
  import { injectable as c, inject as g, named as h } from "inversify";
2
- import { DefaultWikiConfig as p, DefaultPageData as S } from "@xwiki/cristal-api";
3
- import { AbstractStorage as f } from "@xwiki/cristal-backend-api";
4
- var u = Object.defineProperty, P = Object.getOwnPropertyDescriptor, v = (a, e, r, t) => {
5
- for (var s = t > 1 ? void 0 : t ? P(e, r) : e, o = a.length - 1, n; o >= 0; o--)
6
- (n = a[o]) && (s = (t ? n(e, r, s) : n(s)) || s);
7
- return t && s && u(e, r, s), s;
8
- }, i = (a, e) => (r, t) => e(r, t, a);
9
- let m = class extends p {
10
- constructor(a, e, r) {
11
- super(a), this.storage = e, this.cristal = r, this.storage.setWikiConfig(this), this.homePage === "" && (this.homePage = "index.md");
2
+ import { DefaultWikiConfig as S, DefaultPageData as p } from "@xwiki/cristal-api";
3
+ import { AbstractStorage as u } from "@xwiki/cristal-backend-api";
4
+ var f = Object.defineProperty, P = Object.getOwnPropertyDescriptor, d = (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 && f(e, r, s), s;
8
+ }, i = (t, e) => (r, a) => e(r, a, t);
9
+ let l = class extends S {
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
- m = v([
17
+ l = d([
18
18
  c(),
19
19
  i(0, g("Logger")),
20
20
  i(1, g("Storage")),
21
21
  i(1, h("FileSystem")),
22
22
  i(2, g("CristalApp"))
23
- ], m);
24
- var d = Object.defineProperty, y = Object.getOwnPropertyDescriptor, w = (a, e, r, t) => {
25
- for (var s = t > 1 ? void 0 : t ? y(e, r) : e, o = a.length - 1, n; o >= 0; o--)
26
- (n = a[o]) && (s = (t ? n(e, r, s) : n(s)) || s);
27
- return t && s && d(e, r, s), s;
28
- }, _ = (a, e) => (r, t) => e(r, t, a);
29
- let l = class extends f {
30
- constructor(a) {
31
- super(a, "storage.components.fileSystemStorage");
23
+ ], l);
24
+ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, w = (t, e, r, a) => {
25
+ for (var s = a > 1 ? void 0 : a ? y(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 u {
30
+ constructor(t) {
31
+ super(t, "storage.components.fileSystemStorage");
32
32
  }
33
33
  getEditField() {
34
34
  return Promise.resolve("");
@@ -36,12 +36,12 @@ let l = class extends f {
36
36
  getImageURL() {
37
37
  return "";
38
38
  }
39
- async getPageContent(a) {
40
- const e = decodeURIComponent(a), r = await fileSystemStorage.resolvePath(e), t = await fileSystemStorage.readPage(r || "");
41
- return t && (t.id = e, t.headline = t.name, t.headlineRaw = t.name), t;
39
+ async getPageContent(t) {
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
- async getAttachments(a) {
44
- const e = await fileSystemStorage.resolveAttachmentsPath(a);
43
+ async getAttachments(t) {
44
+ const e = await fileSystemStorage.resolveAttachmentsPath(t);
45
45
  return {
46
46
  attachments: await fileSystemStorage.readAttachments(e)
47
47
  };
@@ -53,31 +53,39 @@ let l = class extends f {
53
53
  return "";
54
54
  }
55
55
  getPanelContent() {
56
- return Promise.resolve(new S());
56
+ return Promise.resolve(new p());
57
57
  }
58
58
  isStorageReady() {
59
59
  return Promise.resolve(!0);
60
60
  }
61
- async save(a, e, r) {
62
- const t = await fileSystemStorage.resolvePath(a);
63
- await fileSystemStorage.savePage(t, e, r);
61
+ async save(t, e, r) {
62
+ const a = await fileSystemStorage.resolvePath(t);
63
+ await fileSystemStorage.savePage(a, e, r);
64
+ }
65
+ async saveAttachments(t, e) {
66
+ return Promise.all(e.map((r) => this.saveAttachment(t, r)));
64
67
  }
65
- async saveAttachments(a, e) {
66
- return Promise.all(e.map((r) => this.saveAttachment(a, r)));
68
+ async delete(t) {
69
+ try {
70
+ const e = await fileSystemStorage.resolvePath(t);
71
+ return await fileSystemStorage.deletePage(e), { success: !0 };
72
+ } catch (e) {
73
+ return { success: !1, error: e.message };
74
+ }
67
75
  }
68
- async saveAttachment(a, e) {
69
- const r = await fileSystemStorage.resolveAttachmentPath(a, e.name);
76
+ async saveAttachment(t, e) {
77
+ const r = await fileSystemStorage.resolveAttachmentPath(t, e.name);
70
78
  await fileSystemStorage.saveAttachment(r, e);
71
79
  }
72
80
  };
73
- l = w([
81
+ m = w([
74
82
  c(),
75
83
  _(0, g("Logger"))
76
- ], l);
84
+ ], m);
77
85
  class D {
78
86
  constructor(e) {
79
- var r, t;
80
- 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(l).whenTargetNamed("FileSystem"), (t = this.logger) == null || t.debug("Init Sample Module components end");
87
+ var r, a;
88
+ 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");
81
89
  }
82
90
  }
83
91
  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 { inject, injectable, named } from \"inversify\";\nimport {\n type CristalApp,\n DefaultWikiConfig,\n type Logger,\n type Storage,\n} from \"@xwiki/cristal-api\";\n\n@injectable()\nexport class FileSystemConfig extends DefaultWikiConfig {\n storage: Storage;\n 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 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 { inject, injectable } from \"inversify\";\nimport {\n AttachmentsData,\n DefaultPageData,\n type Logger,\n PageData,\n} from \"@xwiki/cristal-api\";\nimport { AbstractStorage } from \"@xwiki/cristal-backend-api\";\nimport { APITypes } from \"../electron/preload/apiTypes\";\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 = decodeURIComponent(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 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 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 type { Container } from \"inversify\";\nimport type { Logger, Storage, WikiConfig } from \"@xwiki/cristal-api\";\nimport { FileSystemConfig } from \"./components/FileSystemConfig\";\nimport FileSystemStorage from \"./components/fileSystemStorage\";\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","DefaultPageData","content","title","files","file","ComponentInit","container","_a","_b"],"mappings":";;;;;;;;AA6Ba,IAAAA,IAAN,cAA+BC,EAAkB;AAAA,EAGtD,YAC4BC,GACcC,GAClBC,GACtB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AI;AAAA,EAC7B;AAAA,EAEA,MAAM,KAAKJ,GAAcK,GAAiBC,GAA8B;AACtE,UAAMJ,IAAO,MAAM,kBAAkB,YAAYF,CAAI;AACrD,UAAM,kBAAkB,SAASE,GAAMG,GAASC,CAAK;AAAA,EACvD;AAAA,EAEA,MAAM,gBAAgBN,GAAcO,GAAiC;AAC5D,WAAA,QAAQ,IAAIA,EAAM,IAAI,CAACC,MAAS,KAAK,eAAeR,GAAMQ,CAAI,CAAC,CAAC;AAAA,EACzE;AAAA,EAEA,MAAc,eAAeR,GAAcQ,GAA8B;AACvE,UAAMN,IAAO,MAAM,kBAAkB,sBAAsBF,GAAMQ,EAAK,IAAI;AACpE,UAAA,kBAAkB,eAAeN,GAAMM,CAAI;AAAA,EAEnD;AACF;AA9DqBV,IAArBH,EAAA;AAAA,EADCC,EAAW;AAAA,EAEGC,OAAe,QAAQ,CAAA;AAAA,GADjBC,CAAA;ACRrB,MAAqBW,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,GAAGpB,CAAgB,EACnB,gBAAgB,YAAY,GAC/BoB,EACG,KAAc,SAAS,EACvB,GAAGZ,CAAiB,EACpB,gBAAgB,YAAY,IAC1Bc,IAAA,KAAA,WAAA,QAAAA,EAAQ,MAAM;AAAA,EACrB;AACF;"}
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 { inject, injectable, named } from \"inversify\";\nimport {\n type CristalApp,\n DefaultWikiConfig,\n type Logger,\n type Storage,\n} 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 { inject, injectable } from \"inversify\";\nimport {\n AttachmentsData,\n DefaultPageData,\n type Logger,\n PageData,\n} from \"@xwiki/cristal-api\";\nimport { AbstractStorage } from \"@xwiki/cristal-backend-api\";\nimport { APITypes } from \"../electron/preload/apiTypes\";\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 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 type { Container } from \"inversify\";\nimport type { Logger, Storage, WikiConfig } from \"@xwiki/cristal-api\";\nimport { FileSystemConfig } from \"./components/FileSystemConfig\";\nimport FileSystemStorage from \"./components/fileSystemStorage\";\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","DefaultPageData","content","title","files","file","error","ComponentInit","container","_a","_b"],"mappings":";;;;;;;;AA6Ba,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,EAEpB;AAAA,EAES,UAAkB;AAClB,WAAA;AAAA,EACT;AACF;AApBaJ,IAANK,EAAA;AAAA,EADNC,EAAW;AAAA,EAKPC,OAAe,QAAQ,CAAA;AAAA,E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AS,KAAK,eAAeR,GAAMQ,CAAI,CAAC,CAAC;AAAA,EACzE;AAAA,EAEA,MAAM,OAAOR,GAA6D;AACpE,QAAA;AACF,YAAME,IAAO,MAAM,kBAAkB,YAAYF,CAAI;AAC/C,mBAAA,kBAAkB,WAAWE,CAAI,GAChC,EAAE,SAAS;aACXO,GAAO;AACd,aAAO,EAAE,SAAS,IAAO,OAAQA,EAAgB,QAAQ;AAAA,IAC3D;AAAA,EACF;AAAA,EAEA,MAAc,eAAeT,GAAcQ,GAA8B;AACvE,UAAMN,IAAO,MAAM,kBAAkB,sBAAsBF,GAAMQ,EAAK,IAAI;AACpE,UAAA,kBAAkB,eAAeN,GAAMM,CAAI;AAAA,EAEnD;AACF;AAxEqBV,IAArBH,EAAA;AAAA,EADCC,EAAW;AAAA,EAEGC,OAAe,QAAQ,CAAA;AAAA,GADjBC,CAAA;ACRrB,MAAqBY,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,GAAGrB,CAAgB,EACnB,gBAAgB,YAAY,GAC/BqB,EACG,KAAc,SAAS,EACvB,GAAGb,CAAiB,EACpB,gBAAgB,YAAY,IAC1Be,IAAA,KAAA,WAAA,QAAAA,EAAQ,MAAM;AAAA,EACrB;AACF;"}
@@ -1,2 +1,2 @@
1
- (function(i,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("inversify"),require("@xwiki/cristal-api"),require("@xwiki/cristal-backend-api")):typeof define=="function"&&define.amd?define(["exports","inversify","@xwiki/cristal-api","@xwiki/cristal-backend-api"],n):(i=typeof globalThis<"u"?globalThis:i||self,n(i.cristal_storage={},i.inversify,i.cristalApi,i.cristalBackendApi))})(this,function(i,n,p,u){"use strict";var d=Object.defineProperty,h=Object.getOwnPropertyDescriptor,f=(a,e,r,t)=>{for(var s=t>1?void 0:t?h(e,r):e,o=a.length-1,c;o>=0;o--)(c=a[o])&&(s=(t?c(e,r,s):c(s))||s);return t&&s&&d(e,r,s),s},g=(a,e)=>(r,t)=>e(r,t,a);let l=class extends p.DefaultWikiConfig{constructor(a,e,r){super(a),this.storage=e,this.cristal=r,this.storage.setWikiConfig(this),this.homePage===""&&(this.homePage="index.md")}getType(){return"FileSystem"}};l=f([n.injectable(),g(0,n.inject("Logger")),g(1,n.inject("Storage")),g(1,n.named("FileSystem")),g(2,n.inject("CristalApp"))],l);var S=Object.defineProperty,P=Object.getOwnPropertyDescriptor,v=(a,e,r,t)=>{for(var s=t>1?void 0:t?P(e,r):e,o=a.length-1,c;o>=0;o--)(c=a[o])&&(s=(t?c(e,r,s):c(s))||s);return t&&s&&S(e,r,s),s},y=(a,e)=>(r,t)=>e(r,t,a);let m=class extends u.AbstractStorage{constructor(a){super(a,"storage.components.fileSystemStorage")}getEditField(){return Promise.resolve("")}getImageURL(){return""}async getPageContent(a){const e=decodeURIComponent(a),r=await fileSystemStorage.resolvePath(e),t=await fileSystemStorage.readPage(r||"");return t&&(t.id=e,t.headline=t.name,t.headlineRaw=t.name),t}async getAttachments(a){const e=await fileSystemStorage.resolveAttachmentsPath(a);return{attachments:await fileSystemStorage.readAttachments(e)}}getPageFromViewURL(){return null}getPageRestURL(){return""}getPanelContent(){return Promise.resolve(new p.DefaultPageData)}isStorageReady(){return Promise.resolve(!0)}async save(a,e,r){const t=await fileSystemStorage.resolvePath(a);await fileSystemStorage.savePage(t,e,r)}async saveAttachments(a,e){return Promise.all(e.map(r=>this.saveAttachment(a,r)))}async saveAttachment(a,e){const r=await fileSystemStorage.resolveAttachmentPath(a,e.name);await fileSystemStorage.saveAttachment(r,e)}};m=v([n.injectable(),y(0,n.inject("Logger"))],m);class w{constructor(e){var r,t;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"),(t=this.logger)==null||t.debug("Init Sample Module components end")}}i.ComponentInit=w,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
1
+ (function(n,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("inversify"),require("@xwiki/cristal-api"),require("@xwiki/cristal-backend-api")):typeof define=="function"&&define.amd?define(["exports","inversify","@xwiki/cristal-api","@xwiki/cristal-backend-api"],i):(n=typeof globalThis<"u"?globalThis:n||self,i(n.cristal_storage={},n.inversify,n.cristalApi,n.cristalBackendApi))})(this,function(n,i,u,p){"use strict";var d=Object.defineProperty,h=Object.getOwnPropertyDescriptor,f=(t,e,r,a)=>{for(var s=a>1?void 0:a?h(e,r):e,o=t.length-1,c;o>=0;o--)(c=t[o])&&(s=(a?c(e,r,s):c(s))||s);return a&&s&&d(e,r,s),s},l=(t,e)=>(r,a)=>e(r,a,t);let g=class extends u.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"}};g=f([i.injectable(),l(0,i.inject("Logger")),l(1,i.inject("Storage")),l(1,i.named("FileSystem")),l(2,i.inject("CristalApp"))],g);var S=Object.defineProperty,P=Object.getOwnPropertyDescriptor,y=(t,e,r,a)=>{for(var s=a>1?void 0:a?P(e,r):e,o=t.length-1,c;o>=0;o--)(c=t[o])&&(s=(a?c(e,r,s):c(s))||s);return a&&s&&S(e,r,s),s},v=(t,e)=>(r,a)=>e(r,a,t);let m=class extends p.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)}}getPageFromViewURL(){return null}getPageRestURL(){return""}getPanelContent(){return Promise.resolve(new u.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 saveAttachment(t,e){const r=await fileSystemStorage.resolveAttachmentPath(t,e.name);await fileSystemStorage.saveAttachment(r,e)}};m=y([i.injectable(),v(0,i.inject("Logger"))],m);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(g).whenTargetNamed("FileSystem"),e.bind("Storage").to(m).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 { inject, injectable, named } from \"inversify\";\nimport {\n type CristalApp,\n DefaultWikiConfig,\n type Logger,\n type Storage,\n} from \"@xwiki/cristal-api\";\n\n@injectable()\nexport class FileSystemConfig extends DefaultWikiConfig {\n storage: Storage;\n 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 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 { inject, injectable } from \"inversify\";\nimport {\n AttachmentsData,\n DefaultPageData,\n type Logger,\n PageData,\n} from \"@xwiki/cristal-api\";\nimport { AbstractStorage } from \"@xwiki/cristal-backend-api\";\nimport { APITypes } from \"../electron/preload/apiTypes\";\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 = decodeURIComponent(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 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 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 type { Container } from \"inversify\";\nimport type { Logger, Storage, WikiConfig } from \"@xwiki/cristal-api\";\nimport { FileSystemConfig } from \"./components/FileSystemConfig\";\nimport FileSystemStorage from \"./components/fileSystemStorage\";\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","DefaultPageData","content","title","files","file","ComponentInit","container","_a","_b"],"mappings":"0oBA6Ba,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,WAEpB,CAEA,SAAkB,CACT,MAAA,YACT,CACF,EApBaJ,EAANK,EAAA,CADNC,aAAW,EAKPC,aAAe,QAAQ,CAAA,EACvBA,aAAO,SAAS,CAAA,EAAGA,YAAM,YAAY,CAAA,EACrCA,aAAO,YAAY,CAAA,CAAA,EANXP,CAAA,2NCIb,IAAqBQ,EAArB,cAA+CC,EAAAA,eAAgB,CAC7D,YAAsCP,EAAgB,CACpD,MAAMA,EAAQ,sCAAsC,CACtD,CAEA,cAAgC,CACvB,OAAA,QAAQ,QAAQ,EAAE,CAC3B,CAEA,aAAsB,CACb,MAAA,EACT,CAEA,MAAM,eAAeQ,EAAiC,CAC9C,MAAAC,EAAc,mBAAmBD,CAAI,EACrCE,EAAO,MAAM,kBAAkB,YAAYD,CAAW,EACtDE,EAAW,MAAM,k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CAAiB,EACpB,gBAAgB,YAAY,GAC1Bc,EAAA,KAAA,SAAA,MAAAA,EAAQ,MAAM,oCACrB,CACF"}
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 { inject, injectable, named } from \"inversify\";\nimport {\n type CristalApp,\n DefaultWikiConfig,\n type Logger,\n type Storage,\n} 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 { inject, injectable } from \"inversify\";\nimport {\n AttachmentsData,\n DefaultPageData,\n type Logger,\n PageData,\n} from \"@xwiki/cristal-api\";\nimport { AbstractStorage } from \"@xwiki/cristal-backend-api\";\nimport { APITypes } from \"../electron/preload/apiTypes\";\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 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 type { Container } from \"inversify\";\nimport type { Logger, Storage, WikiConfig } from \"@xwiki/cristal-api\";\nimport { FileSystemConfig } from \"./components/FileSystemConfig\";\nimport FileSystemStorage from \"./components/fileSystemStorage\";\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","DefaultPageData","content","title","files","file","error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8B,CACtE,MAAMJ,EAAO,MAAM,kBAAkB,YAAYF,CAAI,EACrD,MAAM,kBAAkB,SAASE,EAAMG,EAASC,CAAK,CACvD,CAEA,MAAM,gBAAgBN,EAAcO,EAAiC,CAC5D,OAAA,QAAQ,IAAIA,EAAM,IAAKC,GAAS,KAAK,eAAeR,EAAMQ,CAAI,CAAC,CAAC,CACzE,CAEA,MAAM,OAAOR,EAA6D,CACpE,GAAA,CACF,MAAME,EAAO,MAAM,kBAAkB,YAAYF,CAAI,EAC/C,aAAA,kBAAkB,WAAWE,CAAI,EAChC,CAAE,QAAS,UACXO,EAAO,CACd,MAAO,CAAE,QAAS,GAAO,MAAQA,EAAgB,OAAQ,CAC3D,CACF,CAEA,MAAc,eAAeT,EAAcQ,EAA8B,CACvE,MAAMN,EAAO,MAAM,kBAAkB,sBAAsBF,EAAMQ,EAAK,IAAI,EACpE,MAAA,kBAAkB,eAAeN,EAAMM,CAAI,CAEnD,CACF,EAxEqBV,EAArBH,EAAA,CADCC,aAAW,EAEGC,aAAe,QAAQ,CAAA,CAAA,EADjBC,CAAA,ECRrB,MAAqBY,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,GAAGrB,CAAgB,EACnB,gBAAgB,YAAY,EAC/BqB,EACG,KAAc,SAAS,EACvB,GAAGb,CAAiB,EACpB,gBAAgB,YAAY,GAC1Be,EAAA,KAAA,SAAA,MAAAA,EAAQ,MAAM,oCACrB,CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xwiki/cristal-electron-storage",
3
- "version": "0.9.0",
3
+ "version": "0.11.0",
4
4
  "license": "LGPL 2.1",
5
5
  "author": "XWiki Org Community <contact@xwiki.org>",
6
6
  "homepage": "https://cristal.xwiki.org/",
@@ -33,23 +33,21 @@
33
33
  "main": "./dist/main/index.es.js",
34
34
  "dependencies": {
35
35
  "inversify": "6.0.2",
36
- "@xwiki/cristal-api": "0.9.0",
37
- "@xwiki/cristal-backend-api": "0.9.0"
36
+ "@xwiki/cristal-api": "0.11.0",
37
+ "@xwiki/cristal-backend-api": "0.11.0"
38
38
  },
39
39
  "peerDependencies": {
40
- "electron": "31.0.2"
40
+ "electron": "31.7.1"
41
41
  },
42
42
  "devDependencies": {
43
- "@types/node": "20.14.7",
44
- "rimraf": "5.0.7",
43
+ "@types/node": "22.7.7",
45
44
  "vite-plugin-node": "3.1.0"
46
45
  },
47
46
  "scripts": {
48
47
  "build": "pnpm compile",
49
48
  "clean": "rimraf dist",
50
49
  "compile": "tsc --project tsconfig.json --noEmit && vite build && vite build -c vite.preload.config.ts && vite build -c vite.main.config.ts",
51
- "lint": "eslint \"./src/**/*.{ts,tsx}\" --max-warnings=0",
52
- "test": "echo 'no test'"
50
+ "lint": "eslint \"./src/**/*.{ts,tsx}\" --max-warnings=0"
53
51
  },
54
52
  "types": "./dist/main/index.d.ts"
55
53
  }
@@ -28,8 +28,8 @@ import {
28
28
 
29
29
  @injectable()
30
30
  export class FileSystemConfig extends DefaultWikiConfig {
31
- storage: Storage;
32
- cristal: CristalApp;
31
+ override storage: Storage;
32
+ override cristal: CristalApp;
33
33
  constructor(
34
34
  @inject<Logger>("Logger") logger: Logger,
35
35
  @inject("Storage") @named("FileSystem") storage: Storage,
@@ -44,7 +44,7 @@ export class FileSystemConfig extends DefaultWikiConfig {
44
44
  }
45
45
  }
46
46
 
47
- getType(): string {
47
+ override getType(): string {
48
48
  return "FileSystem";
49
49
  }
50
50
  }
@@ -45,7 +45,7 @@ export default class FileSystemStorage extends AbstractStorage {
45
45
  }
46
46
 
47
47
  async getPageContent(page: string): Promise<PageData> {
48
- const decodedPage = decodeURIComponent(page);
48
+ const decodedPage = decodeURI(page);
49
49
  const path = await fileSystemStorage.resolvePath(decodedPage);
50
50
  const pageData = await fileSystemStorage.readPage(path || "");
51
51
  if (pageData) {
@@ -88,6 +88,16 @@ export default class FileSystemStorage extends AbstractStorage {
88
88
  return Promise.all(files.map((file) => this.saveAttachment(page, file)));
89
89
  }
90
90
 
91
+ async delete(page: string): Promise<{ success: boolean; error?: string }> {
92
+ try {
93
+ const path = await fileSystemStorage.resolvePath(page);
94
+ await fileSystemStorage.deletePage(path);
95
+ return { success: true };
96
+ } catch (error) {
97
+ return { success: false, error: (error as Error).message };
98
+ }
99
+ }
100
+
91
101
  private async saveAttachment(page: string, file: File): Promise<unknown> {
92
102
  const path = await fileSystemStorage.resolveAttachmentPath(page, file.name);
93
103
  await fileSystemStorage.saveAttachment(path, file);
@@ -19,7 +19,7 @@
19
19
  */
20
20
 
21
21
  import { dirname, join, relative } from "node:path";
22
- import { app, ipcMain } from "electron";
22
+ import { app, ipcMain, shell } from "electron";
23
23
  import fs from "node:fs";
24
24
  import { PageAttachment, PageData } from "@xwiki/cristal-api";
25
25
 
@@ -64,7 +64,7 @@ async function isDirectory(path: string) {
64
64
  async function pathExists(path: string) {
65
65
  try {
66
66
  await fs.promises.lstat(path);
67
- } catch (e) {
67
+ } catch {
68
68
  return false;
69
69
  }
70
70
  return true;
@@ -112,9 +112,9 @@ async function isWithin(root: string, path: string) {
112
112
  * Note: currently this is more a method to update the content of a page than
113
113
  * an actual page save.
114
114
  *
115
- * @param path the path of the page on the file system
116
- * @param content the content of the page
117
- * @param title the title of the page
115
+ * @param path - the path of the page on the file system
116
+ * @param content - the content of the page
117
+ * @param title - the title of the page
118
118
  * @since 0.8
119
119
  */
120
120
  async function savePage(
@@ -165,6 +165,39 @@ async function saveAttachment(path: string, filePath: string) {
165
165
  await fs.promises.copyFile(filePath, path);
166
166
  }
167
167
 
168
+ /**
169
+ * Get the ids of the children pages for a given page.
170
+ *
171
+ * @param page - the id of the page
172
+ * @returns a list of page ids
173
+ * @since 0.10
174
+ */
175
+ async function listChildren(page: string): Promise<Array<string>> {
176
+ const folderPath = resolvePath(page).replace(/\/page.json$/, "");
177
+
178
+ const children = [];
179
+ const files = await fs.promises.readdir(folderPath);
180
+
181
+ for (const file of files) {
182
+ const path = `${folderPath}/${file}`;
183
+ if (await isDirectory(path)) {
184
+ children.push(file);
185
+ }
186
+ }
187
+
188
+ return children;
189
+ }
190
+
191
+ /**
192
+ * Delete a page.
193
+ *
194
+ * @param path - the path to the page to delete
195
+ * @since 0.11
196
+ */
197
+ async function deletePage(path: string): Promise<void> {
198
+ await shell.trashItem(path.replace(/\/page.json$/, ""));
199
+ }
200
+
168
201
  export default function load(): void {
169
202
  ipcMain.handle("resolvePath", (event, { page }) => {
170
203
  return resolvePagePath(page);
@@ -187,4 +220,10 @@ export default function load(): void {
187
220
  ipcMain.handle("saveAttachment", (event, { path, filePath }) => {
188
221
  return saveAttachment(path, filePath);
189
222
  });
223
+ ipcMain.handle("listChildren", (event, { page }) => {
224
+ return listChildren(page);
225
+ });
226
+ ipcMain.handle("deletePage", (event, { path }) => {
227
+ return deletePage(path);
228
+ });
190
229
  }
@@ -34,4 +34,8 @@ export interface APITypes {
34
34
  savePage(path: string, content: string, title: string): Promise<PageData>;
35
35
 
36
36
  saveAttachment(path: string, file: File): Promise<PageData>;
37
+
38
+ listChildren(page: string): Promise<Array<string>>;
39
+
40
+ deletePage(path: string): Promise<void>;
37
41
  }
@@ -47,7 +47,15 @@ const api: APITypes = {
47
47
  });
48
48
  },
49
49
  saveAttachment(path: string, file: File): Promise<PageData> {
50
- return ipcRenderer.invoke("saveAttachment", { path, filePath: file.path });
50
+ const filePath = file.path;
51
+ console.log("filePath", filePath);
52
+ return ipcRenderer.invoke("saveAttachment", { path, filePath: filePath });
53
+ },
54
+ listChildren(page: string): Promise<Array<string>> {
55
+ return ipcRenderer.invoke("listChildren", { page });
56
+ },
57
+ deletePage(path: string): Promise<void> {
58
+ return ipcRenderer.invoke("deletePage", { path });
51
59
  },
52
60
  };
53
61
  contextBridge.exposeInMainWorld("fileSystemStorage", api);
package/tsdoc.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
3
+ "extends": ["../../tsdoc.json"]
4
+ }