@xwiki/cristal-electron-storage 0.17.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/default/components/fileSystemStorage.d.ts +1 -1
- package/dist/default/index.es.js +24 -23
- package/dist/default/index.es.js.map +1 -1
- package/dist/default/index.umd.js +1 -1
- package/dist/default/index.umd.js.map +1 -1
- package/dist/main/components/fileSystemStorage.d.ts +1 -1
- package/dist/main/index.es.js +24 -23
- package/dist/main/index.es.js.map +1 -1
- package/dist/main/index.umd.js +1 -1
- package/dist/main/index.umd.js.map +1 -1
- package/dist/preload/components/fileSystemStorage.d.ts +1 -1
- package/dist/preload/index.es.js +24 -23
- package/dist/preload/index.es.js.map +1 -1
- package/dist/preload/index.umd.js +1 -1
- package/dist/preload/index.umd.js.map +1 -1
- package/package.json +16 -15
- package/src/components/fileSystemStorage.ts +1 -1
- package/src/componentsInit.ts +2 -1
- package/src/electron/preload/index.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @xwiki/cristal-electron-storage
|
|
2
2
|
|
|
3
|
+
## 0.18.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Cristal 0.18 Release
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @xwiki/cristal-api@0.18.0
|
|
13
|
+
- @xwiki/cristal-backend-api@0.18.0
|
|
14
|
+
- @xwiki/cristal-link-suggest-api@0.18.0
|
|
15
|
+
- @xwiki/cristal-model-api@0.18.0
|
|
16
|
+
- @xwiki/cristal-model-remote-url-filesystem-api@0.18.0
|
|
17
|
+
- @xwiki/cristal-electron-state@0.18.0
|
|
18
|
+
- @xwiki/cristal-utils-inversify@0.18.0
|
|
19
|
+
|
|
3
20
|
## 0.17.0
|
|
4
21
|
|
|
5
22
|
### Minor Changes
|
|
@@ -11,7 +11,7 @@ export default class FileSystemStorage extends AbstractStorage {
|
|
|
11
11
|
getPageRestURL(): string;
|
|
12
12
|
getPanelContent(): Promise<PageData>;
|
|
13
13
|
isStorageReady(): Promise<boolean>;
|
|
14
|
-
save(page: string,
|
|
14
|
+
save(page: string, title: string, content: string): Promise<void>;
|
|
15
15
|
saveAttachments(page: string, files: File[]): Promise<unknown>;
|
|
16
16
|
delete(page: string): Promise<{
|
|
17
17
|
success: boolean;
|
package/dist/default/index.es.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { DefaultWikiConfig as h, DefaultPageData as S } from "@xwiki/cristal-api";
|
|
2
|
-
import { injectable as c, inject as
|
|
3
|
-
import { AbstractStorage as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { injectable as c, inject as g, named as u } from "inversify";
|
|
3
|
+
import { AbstractStorage as y } from "@xwiki/cristal-backend-api";
|
|
4
|
+
import { whenNamedOrDefault as f } from "@xwiki/cristal-utils-inversify";
|
|
5
|
+
var p = Object.getOwnPropertyDescriptor, d = (t, e, r, a) => {
|
|
6
|
+
for (var s = a > 1 ? void 0 : a ? p(e, r) : e, o = t.length - 1, n; o >= 0; o--)
|
|
7
|
+
(n = t[o]) && (s = n(s) || s);
|
|
8
|
+
return s;
|
|
8
9
|
}, i = (t, e) => (r, a) => e(r, a, t);
|
|
9
|
-
let
|
|
10
|
+
let l = class extends h {
|
|
10
11
|
constructor(t, e, r) {
|
|
11
12
|
super(t), this.storage = e, this.cristal = r, this.storage.setWikiConfig(this), this.homePage === "" && (this.homePage = "index.md");
|
|
12
13
|
}
|
|
@@ -17,19 +18,19 @@ let g = class extends h {
|
|
|
17
18
|
super.initialize(), fileSystemStorage.initRootDirectory();
|
|
18
19
|
}
|
|
19
20
|
};
|
|
20
|
-
|
|
21
|
+
l = d([
|
|
21
22
|
c(),
|
|
22
|
-
i(0,
|
|
23
|
-
i(1,
|
|
23
|
+
i(0, g("Logger")),
|
|
24
|
+
i(1, g("Storage")),
|
|
24
25
|
i(1, u("FileSystem")),
|
|
25
|
-
i(2,
|
|
26
|
-
],
|
|
27
|
-
var
|
|
26
|
+
i(2, g("CristalApp"))
|
|
27
|
+
], l);
|
|
28
|
+
var v = Object.getOwnPropertyDescriptor, P = (t, e, r, a) => {
|
|
28
29
|
for (var s = a > 1 ? void 0 : a ? v(e, r) : e, o = t.length - 1, n; o >= 0; o--)
|
|
29
|
-
(n = t[o]) && (s =
|
|
30
|
-
return
|
|
31
|
-
},
|
|
32
|
-
let m = class extends
|
|
30
|
+
(n = t[o]) && (s = n(s) || s);
|
|
31
|
+
return s;
|
|
32
|
+
}, w = (t, e) => (r, a) => e(r, a, t);
|
|
33
|
+
let m = class extends y {
|
|
33
34
|
constructor(t) {
|
|
34
35
|
super(t, "storage.components.fileSystemStorage");
|
|
35
36
|
}
|
|
@@ -67,7 +68,7 @@ let m = class extends f {
|
|
|
67
68
|
}
|
|
68
69
|
async save(t, e, r) {
|
|
69
70
|
const a = await fileSystemStorage.resolvePath(t);
|
|
70
|
-
await fileSystemStorage.savePage(a,
|
|
71
|
+
await fileSystemStorage.savePage(a, r, e);
|
|
71
72
|
}
|
|
72
73
|
async saveAttachments(t, e) {
|
|
73
74
|
return Promise.all(e.map((r) => this.saveAttachment(t, r)));
|
|
@@ -93,17 +94,17 @@ let m = class extends f {
|
|
|
93
94
|
await fileSystemStorage.saveAttachment(r, e);
|
|
94
95
|
}
|
|
95
96
|
};
|
|
96
|
-
m =
|
|
97
|
+
m = P([
|
|
97
98
|
c(),
|
|
98
|
-
|
|
99
|
+
w(0, g("Logger"))
|
|
99
100
|
], m);
|
|
100
|
-
class
|
|
101
|
+
class b {
|
|
101
102
|
constructor(e) {
|
|
102
103
|
var r, a;
|
|
103
|
-
this.logger = e.get("Logger"), this.logger.setModule("electron.storage.components.componentsInit"), (r = this.logger) == null || r.debug("Init Sample Module components begin"), e.bind("WikiConfig").to(
|
|
104
|
+
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).when(f("FileSystem")), e.bind("Storage").to(m).whenNamed("FileSystem"), (a = this.logger) == null || a.debug("Init Sample Module components end");
|
|
104
105
|
}
|
|
105
106
|
}
|
|
106
107
|
export {
|
|
107
|
-
|
|
108
|
+
b as ComponentInit
|
|
108
109
|
};
|
|
109
110
|
//# sourceMappingURL=index.es.js.map
|
|
@@ -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 { APITypes } from \"../electron/preload/apiTypes\";\nimport { DefaultWikiConfig } from \"@xwiki/cristal-api\";\nimport { inject, injectable, named } from \"inversify\";\nimport type { CristalApp, Logger, Storage } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport class FileSystemConfig extends DefaultWikiConfig {\n override storage: Storage;\n override cristal: CristalApp;\n constructor(\n @inject(\"Logger\") logger: Logger,\n @inject(\"Storage\") @named(\"FileSystem\") storage: Storage,\n @inject(\"CristalApp\") cristal: CristalApp,\n ) {\n super(logger);\n this.storage = storage;\n this.cristal = cristal;\n this.storage.setWikiConfig(this);\n if (this.homePage === \"\") {\n this.homePage = \"index.md\";\n }\n }\n\n override getType(): string {\n return \"FileSystem\";\n }\n\n override initialize(): void {\n super.initialize();\n // The initialization for the root directory needs to be done after a\n // configuration change, but before any storage operation.\n fileSystemStorage.initRootDirectory();\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport {\n AttachmentsData,\n DefaultPageData,\n PageAttachment,\n PageData,\n} from \"@xwiki/cristal-api\";\nimport { AbstractStorage } from \"@xwiki/cristal-backend-api\";\nimport { inject, injectable } from \"inversify\";\nimport type { Logger } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport default class FileSystemStorage extends AbstractStorage {\n constructor(@inject(\"Logger\") logger: Logger) {\n super(logger, \"storage.components.fileSystemStorage\");\n }\n\n getEditField(): Promise<string> {\n return Promise.resolve(\"\");\n }\n\n getImageURL(): string {\n return \"\";\n }\n\n async getPageContent(page: string): Promise<PageData> {\n const decodedPage = decodeURI(page);\n const path = await fileSystemStorage.resolvePath(decodedPage);\n const pageData = await fileSystemStorage.readPage(path || \"\");\n if (pageData) {\n pageData.id = decodedPage;\n pageData.headline = pageData.name;\n pageData.headlineRaw = pageData.name;\n }\n return pageData;\n }\n\n async getAttachments(page: string): Promise<AttachmentsData | undefined> {\n const path = await fileSystemStorage.resolveAttachmentsPath(page);\n return {\n attachments: await fileSystemStorage.readAttachments(path),\n };\n }\n\n async getAttachment(\n page: string,\n name: string,\n ): Promise<PageAttachment | undefined> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, name);\n return fileSystemStorage.readAttachment(path);\n }\n\n getPageFromViewURL(): string | null {\n return null;\n }\n\n getPageRestURL(): string {\n return \"\";\n }\n\n getPanelContent(): Promise<PageData> {\n return Promise.resolve(new DefaultPageData());\n }\n\n isStorageReady(): Promise<boolean> {\n return Promise.resolve(true);\n }\n\n async save(page: string, content: string, title: string): Promise<void> {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.savePage(path, content, title);\n }\n\n async saveAttachments(page: string, files: File[]): Promise<unknown> {\n return Promise.all(files.map((file) => this.saveAttachment(page, file)));\n }\n\n async delete(page: string): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.deletePage(path);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n async move(\n page: string,\n newPage: string,\n preserveChildren: boolean,\n ): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n const newPath = await fileSystemStorage.resolvePath(newPage);\n await fileSystemStorage.movePage(path, newPath, preserveChildren);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n private async saveAttachment(page: string, file: File): Promise<unknown> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, file.name);\n await fileSystemStorage.saveAttachment(path, file);\n return;\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { FileSystemConfig } from \"./components/FileSystemConfig\";\nimport FileSystemStorage from \"./components/fileSystemStorage\";\nimport type { Logger, Storage, WikiConfig } from \"@xwiki/cristal-api\";\nimport type { Container } from \"inversify\";\n\nexport default class ComponentInit {\n logger: Logger;\n\n constructor(container: Container) {\n this.logger = container.get<Logger>(\"Logger\");\n this.logger.setModule(\"electron.storage.components.componentsInit\");\n\n this.logger?.debug(\"Init Sample Module components begin\");\n container\n .bind<WikiConfig>(\"WikiConfig\")\n .to(FileSystemConfig)\n .whenNamed(\"FileSystem\");\n container\n .bind<Storage>(\"Storage\")\n .to(FileSystemStorage)\n .whenNamed(\"FileSystem\");\n this.logger?.debug(\"Init Sample Module components end\");\n }\n}\n"],"names":["FileSystemConfig","DefaultWikiConfig","logger","storage","cristal","__decorateClass","injectable","__decorateParam","FileSystemStorage","AbstractStorage","page","decodedPage","path","pageData","name","DefaultPageData","content","title","files","file","error","newPage","preserveChildren","newPath","ComponentInit","container","_a","_b"],"mappings":";;;;;;;;AA4Ba,IAAAA,IAAN,cAA+BC,EAAkB;AAAA,EAGtD,YACoBC,GACsBC,GAClBC,GACtB;AACA,UAAMF,CAAM,GACZ,KAAK,UAAUC,GACf,KAAK,UAAUC,GACV,KAAA,QAAQ,cAAc,IAAI,GAC3B,KAAK,aAAa,OACpB,KAAK,WAAW;AAAA,EAClB;AAAA,EAGO,UAAkB;AAClB,WAAA;AAAA,EAAA;AAAA,EAGA,aAAmB;AAC1B,UAAM,WAAW,GAGjB,kBAAkB,kBAAkB;AAAA,EAAA;AAExC;AA3BaJ,IAANK,EAAA;AAAA,EADNC,EAAW;AAAA,EAKPC,OAAO,QAAQ,CAAA;AA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EACnB,UAAU,YAAY,GACzByB,EACG,KAAc,SAAS,EACvB,GAAGjB,CAAiB,EACpB,UAAU,YAAY,IACpBmB,IAAA,KAAA,WAAA,QAAAA,EAAQ,MAAM;AAAA,EAAmC;AAE1D;"}
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../../src/components/FileSystemConfig.ts","../../src/components/fileSystemStorage.ts","../../src/componentsInit.ts"],"sourcesContent":["/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport { DefaultWikiConfig } from \"@xwiki/cristal-api\";\nimport { inject, injectable, named } from \"inversify\";\nimport type { CristalApp, Logger, Storage } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport class FileSystemConfig extends DefaultWikiConfig {\n override storage: Storage;\n override cristal: CristalApp;\n constructor(\n @inject(\"Logger\") logger: Logger,\n @inject(\"Storage\") @named(\"FileSystem\") storage: Storage,\n @inject(\"CristalApp\") cristal: CristalApp,\n ) {\n super(logger);\n this.storage = storage;\n this.cristal = cristal;\n this.storage.setWikiConfig(this);\n if (this.homePage === \"\") {\n this.homePage = \"index.md\";\n }\n }\n\n override getType(): string {\n return \"FileSystem\";\n }\n\n override initialize(): void {\n super.initialize();\n // The initialization for the root directory needs to be done after a\n // configuration change, but before any storage operation.\n fileSystemStorage.initRootDirectory();\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport {\n AttachmentsData,\n DefaultPageData,\n PageAttachment,\n PageData,\n} from \"@xwiki/cristal-api\";\nimport { AbstractStorage } from \"@xwiki/cristal-backend-api\";\nimport { inject, injectable } from \"inversify\";\nimport type { Logger } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport default class FileSystemStorage extends AbstractStorage {\n constructor(@inject(\"Logger\") logger: Logger) {\n super(logger, \"storage.components.fileSystemStorage\");\n }\n\n getEditField(): Promise<string> {\n return Promise.resolve(\"\");\n }\n\n getImageURL(): string {\n return \"\";\n }\n\n async getPageContent(page: string): Promise<PageData> {\n const decodedPage = decodeURI(page);\n const path = await fileSystemStorage.resolvePath(decodedPage);\n const pageData = await fileSystemStorage.readPage(path || \"\");\n if (pageData) {\n pageData.id = decodedPage;\n pageData.headline = pageData.name;\n pageData.headlineRaw = pageData.name;\n }\n return pageData;\n }\n\n async getAttachments(page: string): Promise<AttachmentsData | undefined> {\n const path = await fileSystemStorage.resolveAttachmentsPath(page);\n return {\n attachments: await fileSystemStorage.readAttachments(path),\n };\n }\n\n async getAttachment(\n page: string,\n name: string,\n ): Promise<PageAttachment | undefined> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, name);\n return fileSystemStorage.readAttachment(path);\n }\n\n getPageFromViewURL(): string | null {\n return null;\n }\n\n getPageRestURL(): string {\n return \"\";\n }\n\n getPanelContent(): Promise<PageData> {\n return Promise.resolve(new DefaultPageData());\n }\n\n isStorageReady(): Promise<boolean> {\n return Promise.resolve(true);\n }\n\n async save(page: string, title: string, content: string): Promise<void> {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.savePage(path, content, title);\n }\n\n async saveAttachments(page: string, files: File[]): Promise<unknown> {\n return Promise.all(files.map((file) => this.saveAttachment(page, file)));\n }\n\n async delete(page: string): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.deletePage(path);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n async move(\n page: string,\n newPage: string,\n preserveChildren: boolean,\n ): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n const newPath = await fileSystemStorage.resolvePath(newPage);\n await fileSystemStorage.movePage(path, newPath, preserveChildren);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n private async saveAttachment(page: string, file: File): Promise<unknown> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, file.name);\n await fileSystemStorage.saveAttachment(path, file);\n return;\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { FileSystemConfig } from \"./components/FileSystemConfig\";\nimport FileSystemStorage from \"./components/fileSystemStorage\";\nimport { whenNamedOrDefault } from \"@xwiki/cristal-utils-inversify\";\nimport type { Logger, Storage, WikiConfig } from \"@xwiki/cristal-api\";\nimport type { Container } from \"inversify\";\n\nexport default class ComponentInit {\n logger: Logger;\n\n constructor(container: Container) {\n this.logger = container.get<Logger>(\"Logger\");\n this.logger.setModule(\"electron.storage.components.componentsInit\");\n\n this.logger?.debug(\"Init Sample Module components begin\");\n container\n .bind<WikiConfig>(\"WikiConfig\")\n .to(FileSystemConfig)\n .when(whenNamedOrDefault(\"FileSystem\"));\n container\n .bind<Storage>(\"Storage\")\n .to(FileSystemStorage)\n .whenNamed(\"FileSystem\");\n this.logger?.debug(\"Init Sample Module components end\");\n }\n}\n"],"names":["FileSystemConfig","DefaultWikiConfig","logger","storage","cristal","__decorateClass","injectable","__decorateParam","FileSystemStorage","AbstractStorage","page","decodedPage","path","pageData","name","DefaultPageData","title","content","files","file","error","newPage","preserveChildren","newPath","ComponentInit","container","_a","whenNamedOrDefault","_b"],"mappings":";;;;;;;;;AA4Ba,IAAAA,IAAN,cAA+BC,EAAkB;AAAA,EAGtD,YACoBC,GACsBC,GAClBC,GACtB;AACA,UAAMF,CAAM,GACZ,KAAK,UAAUC,GACf,KAAK,UAAUC,GACV,KAAA,QAAQ,cAAc,IAAI,GAC3B,KAAK,aAAa,OACpB,KAAK,WAAW;AAAA,EAClB;AAAA,EAGO,UAAkB;AAClB,WAAA;AAAA,EAAA;AAAA,EAGA,aAAmB;AAC1B,UAAM,WAAW,GAGjB,kBAAkB,kBAAkB;AAAA,EAAA;AAExC;AA3BaJ,IAANK,EAAA;AAAA,EADNC,EAAW;AAAA,EAKPC,OAAO,QAAQ,CAAA;AAAA,EACfA,OAAO,SAAS,CAAA;AAAA,EAAGA,OAAM,YAAY,CAAA;AAAA,EACrCA,OAAO,YAAY,CAAA;AAAA,GANXP,CAAA;;;;;;AC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A,WAAA,QAAAA,EAAQ,MAAM;AAAA,EAAmC;AAE1D;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(i,
|
|
1
|
+
(function(i,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("@xwiki/cristal-api"),require("inversify"),require("@xwiki/cristal-backend-api"),require("@xwiki/cristal-utils-inversify")):typeof define=="function"&&define.amd?define(["exports","@xwiki/cristal-api","inversify","@xwiki/cristal-backend-api","@xwiki/cristal-utils-inversify"],c):(i=typeof globalThis<"u"?globalThis:i||self,c(i.cristal_storage={},i.cristalApi,i.inversify,i.cristalBackendApi,i.cristalUtilsInversify))})(this,function(i,c,n,h,S){"use strict";var d=Object.getOwnPropertyDescriptor,f=(t,e,r,a)=>{for(var s=a>1?void 0:a?d(e,r):e,o=t.length-1,l;o>=0;o--)(l=t[o])&&(s=l(s)||s);return s},g=(t,e)=>(r,a)=>e(r,a,t);let m=class extends c.DefaultWikiConfig{constructor(t,e,r){super(t),this.storage=e,this.cristal=r,this.storage.setWikiConfig(this),this.homePage===""&&(this.homePage="index.md")}getType(){return"FileSystem"}initialize(){super.initialize(),fileSystemStorage.initRootDirectory()}};m=f([n.injectable(),g(0,n.inject("Logger")),g(1,n.inject("Storage")),g(1,n.named("FileSystem")),g(2,n.inject("CristalApp"))],m);var p=Object.getOwnPropertyDescriptor,y=(t,e,r,a)=>{for(var s=a>1?void 0:a?p(e,r):e,o=t.length-1,l;o>=0;o--)(l=t[o])&&(s=l(s)||s);return s},v=(t,e)=>(r,a)=>e(r,a,t);let u=class extends h.AbstractStorage{constructor(t){super(t,"storage.components.fileSystemStorage")}getEditField(){return Promise.resolve("")}getImageURL(){return""}async getPageContent(t){const e=decodeURI(t),r=await fileSystemStorage.resolvePath(e),a=await fileSystemStorage.readPage(r||"");return a&&(a.id=e,a.headline=a.name,a.headlineRaw=a.name),a}async getAttachments(t){const e=await fileSystemStorage.resolveAttachmentsPath(t);return{attachments:await fileSystemStorage.readAttachments(e)}}async getAttachment(t,e){const r=await fileSystemStorage.resolveAttachmentPath(t,e);return fileSystemStorage.readAttachment(r)}getPageFromViewURL(){return null}getPageRestURL(){return""}getPanelContent(){return Promise.resolve(new c.DefaultPageData)}isStorageReady(){return Promise.resolve(!0)}async save(t,e,r){const a=await fileSystemStorage.resolvePath(t);await fileSystemStorage.savePage(a,r,e)}async saveAttachments(t,e){return Promise.all(e.map(r=>this.saveAttachment(t,r)))}async delete(t){try{const e=await fileSystemStorage.resolvePath(t);return await fileSystemStorage.deletePage(e),{success:!0}}catch(e){return{success:!1,error:e.message}}}async move(t,e,r){try{const a=await fileSystemStorage.resolvePath(t),s=await fileSystemStorage.resolvePath(e);return await fileSystemStorage.movePage(a,s,r),{success:!0}}catch(a){return{success:!1,error:a.message}}}async saveAttachment(t,e){const r=await fileSystemStorage.resolveAttachmentPath(t,e.name);await fileSystemStorage.saveAttachment(r,e)}};u=y([n.injectable(),v(0,n.inject("Logger"))],u);class P{constructor(e){var r,a;this.logger=e.get("Logger"),this.logger.setModule("electron.storage.components.componentsInit"),(r=this.logger)==null||r.debug("Init Sample Module components begin"),e.bind("WikiConfig").to(m).when(S.whenNamedOrDefault("FileSystem")),e.bind("Storage").to(u).whenNamed("FileSystem"),(a=this.logger)==null||a.debug("Init Sample Module components end")}}i.ComponentInit=P,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
|
|
2
2
|
//# sourceMappingURL=index.umd.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../../src/components/FileSystemConfig.ts","../../src/components/fileSystemStorage.ts","../../src/componentsInit.ts"],"sourcesContent":["/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport { DefaultWikiConfig } from \"@xwiki/cristal-api\";\nimport { inject, injectable, named } from \"inversify\";\nimport type { CristalApp, Logger, Storage } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport class FileSystemConfig extends DefaultWikiConfig {\n override storage: Storage;\n override cristal: CristalApp;\n constructor(\n @inject(\"Logger\") logger: Logger,\n @inject(\"Storage\") @named(\"FileSystem\") storage: Storage,\n @inject(\"CristalApp\") cristal: CristalApp,\n ) {\n super(logger);\n this.storage = storage;\n this.cristal = cristal;\n this.storage.setWikiConfig(this);\n if (this.homePage === \"\") {\n this.homePage = \"index.md\";\n }\n }\n\n override getType(): string {\n return \"FileSystem\";\n }\n\n override initialize(): void {\n super.initialize();\n // The initialization for the root directory needs to be done after a\n // configuration change, but before any storage operation.\n fileSystemStorage.initRootDirectory();\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport {\n AttachmentsData,\n DefaultPageData,\n PageAttachment,\n PageData,\n} from \"@xwiki/cristal-api\";\nimport { AbstractStorage } from \"@xwiki/cristal-backend-api\";\nimport { inject, injectable } from \"inversify\";\nimport type { Logger } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport default class FileSystemStorage extends AbstractStorage {\n constructor(@inject(\"Logger\") logger: Logger) {\n super(logger, \"storage.components.fileSystemStorage\");\n }\n\n getEditField(): Promise<string> {\n return Promise.resolve(\"\");\n }\n\n getImageURL(): string {\n return \"\";\n }\n\n async getPageContent(page: string): Promise<PageData> {\n const decodedPage = decodeURI(page);\n const path = await fileSystemStorage.resolvePath(decodedPage);\n const pageData = await fileSystemStorage.readPage(path || \"\");\n if (pageData) {\n pageData.id = decodedPage;\n pageData.headline = pageData.name;\n pageData.headlineRaw = pageData.name;\n }\n return pageData;\n }\n\n async getAttachments(page: string): Promise<AttachmentsData | undefined> {\n const path = await fileSystemStorage.resolveAttachmentsPath(page);\n return {\n attachments: await fileSystemStorage.readAttachments(path),\n };\n }\n\n async getAttachment(\n page: string,\n name: string,\n ): Promise<PageAttachment | undefined> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, name);\n return fileSystemStorage.readAttachment(path);\n }\n\n getPageFromViewURL(): string | null {\n return null;\n }\n\n getPageRestURL(): string {\n return \"\";\n }\n\n getPanelContent(): Promise<PageData> {\n return Promise.resolve(new DefaultPageData());\n }\n\n isStorageReady(): Promise<boolean> {\n return Promise.resolve(true);\n }\n\n async save(page: string, content: string, title: string): Promise<void> {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.savePage(path, content, title);\n }\n\n async saveAttachments(page: string, files: File[]): Promise<unknown> {\n return Promise.all(files.map((file) => this.saveAttachment(page, file)));\n }\n\n async delete(page: string): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.deletePage(path);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n async move(\n page: string,\n newPage: string,\n preserveChildren: boolean,\n ): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n const newPath = await fileSystemStorage.resolvePath(newPage);\n await fileSystemStorage.movePage(path, newPath, preserveChildren);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n private async saveAttachment(page: string, file: File): Promise<unknown> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, file.name);\n await fileSystemStorage.saveAttachment(path, file);\n return;\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { FileSystemConfig } from \"./components/FileSystemConfig\";\nimport FileSystemStorage from \"./components/fileSystemStorage\";\nimport type { Logger, Storage, WikiConfig } from \"@xwiki/cristal-api\";\nimport type { Container } from \"inversify\";\n\nexport default class ComponentInit {\n logger: Logger;\n\n constructor(container: Container) {\n this.logger = container.get<Logger>(\"Logger\");\n this.logger.setModule(\"electron.storage.components.componentsInit\");\n\n this.logger?.debug(\"Init Sample Module components begin\");\n container\n .bind<WikiConfig>(\"WikiConfig\")\n .to(FileSystemConfig)\n .whenNamed(\"FileSystem\");\n container\n .bind<Storage>(\"Storage\")\n .to(FileSystemStorage)\n .whenNamed(\"FileSystem\");\n this.logger?.debug(\"Init Sample Module components end\");\n }\n}\n"],"names":["FileSystemConfig","DefaultWikiConfig","logger","storage","cristal","__decorateClass","injectable","__decorateParam","FileSystemStorage","AbstractStorage","page","decodedPage","path","pageData","name","DefaultPageData","content","title","files","file","error","newPage","preserveChildren","newPath","ComponentInit","container","_a","_b"],"mappings":"0oBA4Ba,IAAAA,EAAN,cAA+BC,EAAAA,iBAAkB,CAGtD,YACoBC,EACsBC,EAClBC,EACtB,CACA,MAAMF,CAAM,EACZ,KAAK,QAAUC,EACf,KAAK,QAAUC,EACV,KAAA,QAAQ,cAAc,IAAI,EAC3B,KAAK,WAAa,KACpB,KAAK,SAAW,WAClB,CAGO,SAAkB,CAClB,MAAA,YAAA,CAGA,YAAmB,CAC1B,MAAM,WAAW,EAGjB,kBAAkB,kBAAkB,CAAA,CAExC,EA3BaJ,EAANK,EAAA,CADNC,aAAW,EAKPC,aAAO,QAAQ,CAAA,EACfA,aAAO,SAAS,CAAA,EAAGA,YAAM,YAAY,CAAA,EACrCA,aAAO,YAAY,CAAA,CAAA,EANXP,CAAA,2NCMb,IAAqBQ,EAArB,cAA+CC,EAAAA,eAAgB,CAC7D,YAA8BP,EAAgB,CAC5C,MAAMA,EAAQ,sCAAsC,CAAA,CAGtD,cAAgC,CACvB,OAAA,QAAQ,QAAQ,EAAE,CAAA,CAG3B,aAAsB,CACb,MAAA,EAAA,CAGT,MAAM,eAAeQ,EAAiC,CAC9C,MAAAC,EAAc,UAAUD,CAAI,EAC5BE,EAAO,MAAM,kBAAkB,YAAYD,CAAW,EACtDE,EAAW,MAAM,kBAAkB,SAASD,GAAQ,EAAE,EAC5D,OAAIC,IACFA,EAAS,GAAKF,EACdE,EAAS,SAAWA,EAAS,KAC7BA,EAAS,YAAcA,EAAS,MAE3BA,CAAA,CAGT,MAAM,eAAeH,EAAoD,CACvE,MAAME,EAAO,MAAM,kBAAkB,uBAAuBF,CAAI,EACzD,MAAA,CACL,YAAa,MAAM,kBAAkB,gBAAgBE,CAAI,CAC3D,CAAA,CAGF,MAAM,cACJF,EACAI,EACqC,CACrC,MA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A,CADCC,aAAW,EAEGC,aAAO,QAAQ,CAAA,CAAA,EADTC,CAAA,ECTrB,MAAqBgB,CAAc,CAGjC,YAAYC,EAAsB,SAC3B,KAAA,OAASA,EAAU,IAAY,QAAQ,EACvC,KAAA,OAAO,UAAU,4CAA4C,GAE7DC,EAAA,KAAA,SAAA,MAAAA,EAAQ,MAAM,uCACnBD,EACG,KAAiB,YAAY,EAC7B,GAAGzB,CAAgB,EACnB,UAAU,YAAY,EACzByB,EACG,KAAc,SAAS,EACvB,GAAGjB,CAAiB,EACpB,UAAU,YAAY,GACpBmB,EAAA,KAAA,SAAA,MAAAA,EAAQ,MAAM,oCAAmC,CAE1D"}
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../../src/components/FileSystemConfig.ts","../../src/components/fileSystemStorage.ts","../../src/componentsInit.ts"],"sourcesContent":["/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport { DefaultWikiConfig } from \"@xwiki/cristal-api\";\nimport { inject, injectable, named } from \"inversify\";\nimport type { CristalApp, Logger, Storage } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport class FileSystemConfig extends DefaultWikiConfig {\n override storage: Storage;\n override cristal: CristalApp;\n constructor(\n @inject(\"Logger\") logger: Logger,\n @inject(\"Storage\") @named(\"FileSystem\") storage: Storage,\n @inject(\"CristalApp\") cristal: CristalApp,\n ) {\n super(logger);\n this.storage = storage;\n this.cristal = cristal;\n this.storage.setWikiConfig(this);\n if (this.homePage === \"\") {\n this.homePage = \"index.md\";\n }\n }\n\n override getType(): string {\n return \"FileSystem\";\n }\n\n override initialize(): void {\n super.initialize();\n // The initialization for the root directory needs to be done after a\n // configuration change, but before any storage operation.\n fileSystemStorage.initRootDirectory();\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport {\n AttachmentsData,\n DefaultPageData,\n PageAttachment,\n PageData,\n} from \"@xwiki/cristal-api\";\nimport { AbstractStorage } from \"@xwiki/cristal-backend-api\";\nimport { inject, injectable } from \"inversify\";\nimport type { Logger } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport default class FileSystemStorage extends AbstractStorage {\n constructor(@inject(\"Logger\") logger: Logger) {\n super(logger, \"storage.components.fileSystemStorage\");\n }\n\n getEditField(): Promise<string> {\n return Promise.resolve(\"\");\n }\n\n getImageURL(): string {\n return \"\";\n }\n\n async getPageContent(page: string): Promise<PageData> {\n const decodedPage = decodeURI(page);\n const path = await fileSystemStorage.resolvePath(decodedPage);\n const pageData = await fileSystemStorage.readPage(path || \"\");\n if (pageData) {\n pageData.id = decodedPage;\n pageData.headline = pageData.name;\n pageData.headlineRaw = pageData.name;\n }\n return pageData;\n }\n\n async getAttachments(page: string): Promise<AttachmentsData | undefined> {\n const path = await fileSystemStorage.resolveAttachmentsPath(page);\n return {\n attachments: await fileSystemStorage.readAttachments(path),\n };\n }\n\n async getAttachment(\n page: string,\n name: string,\n ): Promise<PageAttachment | undefined> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, name);\n return fileSystemStorage.readAttachment(path);\n }\n\n getPageFromViewURL(): string | null {\n return null;\n }\n\n getPageRestURL(): string {\n return \"\";\n }\n\n getPanelContent(): Promise<PageData> {\n return Promise.resolve(new DefaultPageData());\n }\n\n isStorageReady(): Promise<boolean> {\n return Promise.resolve(true);\n }\n\n async save(page: string, title: string, content: string): Promise<void> {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.savePage(path, content, title);\n }\n\n async saveAttachments(page: string, files: File[]): Promise<unknown> {\n return Promise.all(files.map((file) => this.saveAttachment(page, file)));\n }\n\n async delete(page: string): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.deletePage(path);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n async move(\n page: string,\n newPage: string,\n preserveChildren: boolean,\n ): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n const newPath = await fileSystemStorage.resolvePath(newPage);\n await fileSystemStorage.movePage(path, newPath, preserveChildren);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n private async saveAttachment(page: string, file: File): Promise<unknown> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, file.name);\n await fileSystemStorage.saveAttachment(path, file);\n return;\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { FileSystemConfig } from \"./components/FileSystemConfig\";\nimport FileSystemStorage from \"./components/fileSystemStorage\";\nimport { whenNamedOrDefault } from \"@xwiki/cristal-utils-inversify\";\nimport type { Logger, Storage, WikiConfig } from \"@xwiki/cristal-api\";\nimport type { Container } from \"inversify\";\n\nexport default class ComponentInit {\n logger: Logger;\n\n constructor(container: Container) {\n this.logger = container.get<Logger>(\"Logger\");\n this.logger.setModule(\"electron.storage.components.componentsInit\");\n\n this.logger?.debug(\"Init Sample Module components begin\");\n container\n .bind<WikiConfig>(\"WikiConfig\")\n .to(FileSystemConfig)\n .when(whenNamedOrDefault(\"FileSystem\"));\n container\n .bind<Storage>(\"Storage\")\n .to(FileSystemStorage)\n .whenNamed(\"FileSystem\");\n this.logger?.debug(\"Init Sample Module components end\");\n }\n}\n"],"names":["FileSystemConfig","DefaultWikiConfig","logger","storage","cristal","__decorateClass","injectable","__decorateParam","FileSystemStorage","AbstractStorage","page","decodedPage","path","pageData","name","DefaultPageData","title","content","files","file","error","newPage","preserveChildren","newPath","ComponentInit","container","_a","whenNamedOrDefault","_b"],"mappings":"2rBA4Ba,IAAAA,EAAN,cAA+BC,EAAAA,iBAAkB,CAGtD,YACoBC,EACsBC,EAClBC,EACtB,CACA,MAAMF,CAAM,EACZ,KAAK,QAAUC,EACf,KAAK,QAAUC,EACV,KAAA,QAAQ,cAAc,IAAI,EAC3B,KAAK,WAAa,KACpB,KAAK,SAAW,WAClB,CAGO,SAAkB,CAClB,MAAA,YAAA,CAGA,YAAmB,CAC1B,MAAM,WA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AAmC,CAE1D"}
|
|
@@ -11,7 +11,7 @@ export default class FileSystemStorage extends AbstractStorage {
|
|
|
11
11
|
getPageRestURL(): string;
|
|
12
12
|
getPanelContent(): Promise<PageData>;
|
|
13
13
|
isStorageReady(): Promise<boolean>;
|
|
14
|
-
save(page: string,
|
|
14
|
+
save(page: string, title: string, content: string): Promise<void>;
|
|
15
15
|
saveAttachments(page: string, files: File[]): Promise<unknown>;
|
|
16
16
|
delete(page: string): Promise<{
|
|
17
17
|
success: boolean;
|
package/dist/main/index.es.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { DefaultWikiConfig as h, DefaultPageData as S } from "@xwiki/cristal-api";
|
|
2
|
-
import { injectable as c, inject as
|
|
3
|
-
import { AbstractStorage as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { injectable as c, inject as g, named as u } from "inversify";
|
|
3
|
+
import { AbstractStorage as y } from "@xwiki/cristal-backend-api";
|
|
4
|
+
import { whenNamedOrDefault as f } from "@xwiki/cristal-utils-inversify";
|
|
5
|
+
var p = Object.getOwnPropertyDescriptor, d = (t, e, r, a) => {
|
|
6
|
+
for (var s = a > 1 ? void 0 : a ? p(e, r) : e, o = t.length - 1, n; o >= 0; o--)
|
|
7
|
+
(n = t[o]) && (s = n(s) || s);
|
|
8
|
+
return s;
|
|
8
9
|
}, i = (t, e) => (r, a) => e(r, a, t);
|
|
9
|
-
let
|
|
10
|
+
let l = class extends h {
|
|
10
11
|
constructor(t, e, r) {
|
|
11
12
|
super(t), this.storage = e, this.cristal = r, this.storage.setWikiConfig(this), this.homePage === "" && (this.homePage = "index.md");
|
|
12
13
|
}
|
|
@@ -17,19 +18,19 @@ let g = class extends h {
|
|
|
17
18
|
super.initialize(), fileSystemStorage.initRootDirectory();
|
|
18
19
|
}
|
|
19
20
|
};
|
|
20
|
-
|
|
21
|
+
l = d([
|
|
21
22
|
c(),
|
|
22
|
-
i(0,
|
|
23
|
-
i(1,
|
|
23
|
+
i(0, g("Logger")),
|
|
24
|
+
i(1, g("Storage")),
|
|
24
25
|
i(1, u("FileSystem")),
|
|
25
|
-
i(2,
|
|
26
|
-
],
|
|
27
|
-
var
|
|
26
|
+
i(2, g("CristalApp"))
|
|
27
|
+
], l);
|
|
28
|
+
var v = Object.getOwnPropertyDescriptor, P = (t, e, r, a) => {
|
|
28
29
|
for (var s = a > 1 ? void 0 : a ? v(e, r) : e, o = t.length - 1, n; o >= 0; o--)
|
|
29
|
-
(n = t[o]) && (s =
|
|
30
|
-
return
|
|
31
|
-
},
|
|
32
|
-
let m = class extends
|
|
30
|
+
(n = t[o]) && (s = n(s) || s);
|
|
31
|
+
return s;
|
|
32
|
+
}, w = (t, e) => (r, a) => e(r, a, t);
|
|
33
|
+
let m = class extends y {
|
|
33
34
|
constructor(t) {
|
|
34
35
|
super(t, "storage.components.fileSystemStorage");
|
|
35
36
|
}
|
|
@@ -67,7 +68,7 @@ let m = class extends f {
|
|
|
67
68
|
}
|
|
68
69
|
async save(t, e, r) {
|
|
69
70
|
const a = await fileSystemStorage.resolvePath(t);
|
|
70
|
-
await fileSystemStorage.savePage(a,
|
|
71
|
+
await fileSystemStorage.savePage(a, r, e);
|
|
71
72
|
}
|
|
72
73
|
async saveAttachments(t, e) {
|
|
73
74
|
return Promise.all(e.map((r) => this.saveAttachment(t, r)));
|
|
@@ -93,17 +94,17 @@ let m = class extends f {
|
|
|
93
94
|
await fileSystemStorage.saveAttachment(r, e);
|
|
94
95
|
}
|
|
95
96
|
};
|
|
96
|
-
m =
|
|
97
|
+
m = P([
|
|
97
98
|
c(),
|
|
98
|
-
|
|
99
|
+
w(0, g("Logger"))
|
|
99
100
|
], m);
|
|
100
|
-
class
|
|
101
|
+
class b {
|
|
101
102
|
constructor(e) {
|
|
102
103
|
var r, a;
|
|
103
|
-
this.logger = e.get("Logger"), this.logger.setModule("electron.storage.components.componentsInit"), (r = this.logger) == null || r.debug("Init Sample Module components begin"), e.bind("WikiConfig").to(
|
|
104
|
+
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).when(f("FileSystem")), e.bind("Storage").to(m).whenNamed("FileSystem"), (a = this.logger) == null || a.debug("Init Sample Module components end");
|
|
104
105
|
}
|
|
105
106
|
}
|
|
106
107
|
export {
|
|
107
|
-
|
|
108
|
+
b as ComponentInit
|
|
108
109
|
};
|
|
109
110
|
//# sourceMappingURL=index.es.js.map
|
|
@@ -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 { APITypes } from \"../electron/preload/apiTypes\";\nimport { DefaultWikiConfig } from \"@xwiki/cristal-api\";\nimport { inject, injectable, named } from \"inversify\";\nimport type { CristalApp, Logger, Storage } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport class FileSystemConfig extends DefaultWikiConfig {\n override storage: Storage;\n override cristal: CristalApp;\n constructor(\n @inject(\"Logger\") logger: Logger,\n @inject(\"Storage\") @named(\"FileSystem\") storage: Storage,\n @inject(\"CristalApp\") cristal: CristalApp,\n ) {\n super(logger);\n this.storage = storage;\n this.cristal = cristal;\n this.storage.setWikiConfig(this);\n if (this.homePage === \"\") {\n this.homePage = \"index.md\";\n }\n }\n\n override getType(): string {\n return \"FileSystem\";\n }\n\n override initialize(): void {\n super.initialize();\n // The initialization for the root directory needs to be done after a\n // configuration change, but before any storage operation.\n fileSystemStorage.initRootDirectory();\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport {\n AttachmentsData,\n DefaultPageData,\n PageAttachment,\n PageData,\n} from \"@xwiki/cristal-api\";\nimport { AbstractStorage } from \"@xwiki/cristal-backend-api\";\nimport { inject, injectable } from \"inversify\";\nimport type { Logger } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport default class FileSystemStorage extends AbstractStorage {\n constructor(@inject(\"Logger\") logger: Logger) {\n super(logger, \"storage.components.fileSystemStorage\");\n }\n\n getEditField(): Promise<string> {\n return Promise.resolve(\"\");\n }\n\n getImageURL(): string {\n return \"\";\n }\n\n async getPageContent(page: string): Promise<PageData> {\n const decodedPage = decodeURI(page);\n const path = await fileSystemStorage.resolvePath(decodedPage);\n const pageData = await fileSystemStorage.readPage(path || \"\");\n if (pageData) {\n pageData.id = decodedPage;\n pageData.headline = pageData.name;\n pageData.headlineRaw = pageData.name;\n }\n return pageData;\n }\n\n async getAttachments(page: string): Promise<AttachmentsData | undefined> {\n const path = await fileSystemStorage.resolveAttachmentsPath(page);\n return {\n attachments: await fileSystemStorage.readAttachments(path),\n };\n }\n\n async getAttachment(\n page: string,\n name: string,\n ): Promise<PageAttachment | undefined> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, name);\n return fileSystemStorage.readAttachment(path);\n }\n\n getPageFromViewURL(): string | null {\n return null;\n }\n\n getPageRestURL(): string {\n return \"\";\n }\n\n getPanelContent(): Promise<PageData> {\n return Promise.resolve(new DefaultPageData());\n }\n\n isStorageReady(): Promise<boolean> {\n return Promise.resolve(true);\n }\n\n async save(page: string, content: string, title: string): Promise<void> {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.savePage(path, content, title);\n }\n\n async saveAttachments(page: string, files: File[]): Promise<unknown> {\n return Promise.all(files.map((file) => this.saveAttachment(page, file)));\n }\n\n async delete(page: string): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.deletePage(path);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n async move(\n page: string,\n newPage: string,\n preserveChildren: boolean,\n ): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n const newPath = await fileSystemStorage.resolvePath(newPage);\n await fileSystemStorage.movePage(path, newPath, preserveChildren);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n private async saveAttachment(page: string, file: File): Promise<unknown> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, file.name);\n await fileSystemStorage.saveAttachment(path, file);\n return;\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { FileSystemConfig } from \"./components/FileSystemConfig\";\nimport FileSystemStorage from \"./components/fileSystemStorage\";\nimport type { Logger, Storage, WikiConfig } from \"@xwiki/cristal-api\";\nimport type { Container } from \"inversify\";\n\nexport default class ComponentInit {\n logger: Logger;\n\n constructor(container: Container) {\n this.logger = container.get<Logger>(\"Logger\");\n this.logger.setModule(\"electron.storage.components.componentsInit\");\n\n this.logger?.debug(\"Init Sample Module components begin\");\n container\n .bind<WikiConfig>(\"WikiConfig\")\n .to(FileSystemConfig)\n .whenNamed(\"FileSystem\");\n container\n .bind<Storage>(\"Storage\")\n .to(FileSystemStorage)\n .whenNamed(\"FileSystem\");\n this.logger?.debug(\"Init Sample Module components end\");\n }\n}\n"],"names":["FileSystemConfig","DefaultWikiConfig","logger","storage","cristal","__decorateClass","injectable","__decorateParam","FileSystemStorage","AbstractStorage","page","decodedPage","path","pageData","name","DefaultPageData","content","title","files","file","error","newPage","preserveChildren","newPath","ComponentInit","container","_a","_b"],"mappings":";;;;;;;;AA4Ba,IAAAA,IAAN,cAA+BC,EAAkB;AAAA,EAGtD,YACoBC,GACsBC,GAClBC,GACtB;AACA,UAAMF,CAAM,GACZ,KAAK,UAAUC,GACf,KAAK,UAAUC,GACV,KAAA,QAAQ,cAAc,IAAI,GAC3B,KAAK,aAAa,OACpB,KAAK,WAAW;AAAA,EAClB;AAAA,EAGO,UAAkB;AAClB,WAAA;AAAA,EAAA;AAAA,EAGA,aAAmB;AAC1B,UAAM,WAAW,GAGjB,kBAAkB,kBAAkB;AAAA,EAAA;AAExC;AA3BaJ,IAANK,EAAA;AAAA,EADNC,EAAW;AAAA,EAKPC,OAAO,QAAQ,CA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AAgB,EACnB,UAAU,YAAY,GACzByB,EACG,KAAc,SAAS,EACvB,GAAGjB,CAAiB,EACpB,UAAU,YAAY,IACpBmB,IAAA,KAAA,WAAA,QAAAA,EAAQ,MAAM;AAAA,EAAmC;AAE1D;"}
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../../src/components/FileSystemConfig.ts","../../src/components/fileSystemStorage.ts","../../src/componentsInit.ts"],"sourcesContent":["/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport { DefaultWikiConfig } from \"@xwiki/cristal-api\";\nimport { inject, injectable, named } from \"inversify\";\nimport type { CristalApp, Logger, Storage } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport class FileSystemConfig extends DefaultWikiConfig {\n override storage: Storage;\n override cristal: CristalApp;\n constructor(\n @inject(\"Logger\") logger: Logger,\n @inject(\"Storage\") @named(\"FileSystem\") storage: Storage,\n @inject(\"CristalApp\") cristal: CristalApp,\n ) {\n super(logger);\n this.storage = storage;\n this.cristal = cristal;\n this.storage.setWikiConfig(this);\n if (this.homePage === \"\") {\n this.homePage = \"index.md\";\n }\n }\n\n override getType(): string {\n return \"FileSystem\";\n }\n\n override initialize(): void {\n super.initialize();\n // The initialization for the root directory needs to be done after a\n // configuration change, but before any storage operation.\n fileSystemStorage.initRootDirectory();\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport {\n AttachmentsData,\n DefaultPageData,\n PageAttachment,\n PageData,\n} from \"@xwiki/cristal-api\";\nimport { AbstractStorage } from \"@xwiki/cristal-backend-api\";\nimport { inject, injectable } from \"inversify\";\nimport type { Logger } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport default class FileSystemStorage extends AbstractStorage {\n constructor(@inject(\"Logger\") logger: Logger) {\n super(logger, \"storage.components.fileSystemStorage\");\n }\n\n getEditField(): Promise<string> {\n return Promise.resolve(\"\");\n }\n\n getImageURL(): string {\n return \"\";\n }\n\n async getPageContent(page: string): Promise<PageData> {\n const decodedPage = decodeURI(page);\n const path = await fileSystemStorage.resolvePath(decodedPage);\n const pageData = await fileSystemStorage.readPage(path || \"\");\n if (pageData) {\n pageData.id = decodedPage;\n pageData.headline = pageData.name;\n pageData.headlineRaw = pageData.name;\n }\n return pageData;\n }\n\n async getAttachments(page: string): Promise<AttachmentsData | undefined> {\n const path = await fileSystemStorage.resolveAttachmentsPath(page);\n return {\n attachments: await fileSystemStorage.readAttachments(path),\n };\n }\n\n async getAttachment(\n page: string,\n name: string,\n ): Promise<PageAttachment | undefined> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, name);\n return fileSystemStorage.readAttachment(path);\n }\n\n getPageFromViewURL(): string | null {\n return null;\n }\n\n getPageRestURL(): string {\n return \"\";\n }\n\n getPanelContent(): Promise<PageData> {\n return Promise.resolve(new DefaultPageData());\n }\n\n isStorageReady(): Promise<boolean> {\n return Promise.resolve(true);\n }\n\n async save(page: string, title: string, content: string): Promise<void> {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.savePage(path, content, title);\n }\n\n async saveAttachments(page: string, files: File[]): Promise<unknown> {\n return Promise.all(files.map((file) => this.saveAttachment(page, file)));\n }\n\n async delete(page: string): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.deletePage(path);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n async move(\n page: string,\n newPage: string,\n preserveChildren: boolean,\n ): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n const newPath = await fileSystemStorage.resolvePath(newPage);\n await fileSystemStorage.movePage(path, newPath, preserveChildren);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n private async saveAttachment(page: string, file: File): Promise<unknown> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, file.name);\n await fileSystemStorage.saveAttachment(path, file);\n return;\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { FileSystemConfig } from \"./components/FileSystemConfig\";\nimport FileSystemStorage from \"./components/fileSystemStorage\";\nimport { whenNamedOrDefault } from \"@xwiki/cristal-utils-inversify\";\nimport type { Logger, Storage, WikiConfig } from \"@xwiki/cristal-api\";\nimport type { Container } from \"inversify\";\n\nexport default class ComponentInit {\n logger: Logger;\n\n constructor(container: Container) {\n this.logger = container.get<Logger>(\"Logger\");\n this.logger.setModule(\"electron.storage.components.componentsInit\");\n\n this.logger?.debug(\"Init Sample Module components begin\");\n container\n .bind<WikiConfig>(\"WikiConfig\")\n .to(FileSystemConfig)\n .when(whenNamedOrDefault(\"FileSystem\"));\n container\n .bind<Storage>(\"Storage\")\n .to(FileSystemStorage)\n .whenNamed(\"FileSystem\");\n this.logger?.debug(\"Init Sample Module components end\");\n }\n}\n"],"names":["FileSystemConfig","DefaultWikiConfig","logger","storage","cristal","__decorateClass","injectable","__decorateParam","FileSystemStorage","AbstractStorage","page","decodedPage","path","pageData","name","DefaultPageData","title","content","files","file","error","newPage","preserveChildren","newPath","ComponentInit","container","_a","whenNamedOrDefault","_b"],"mappings":";;;;;;;;;AA4Ba,IAAAA,IAAN,cAA+BC,EAAkB;AAAA,EAGtD,YACoBC,GACsBC,GAClBC,GACtB;AACA,UAAMF,CAAM,GACZ,KAAK,UAAUC,GACf,KAAK,UAAUC,GACV,KAAA,QAAQ,cAAc,IAAI,GAC3B,KAAK,aAAa,OACpB,KAAK,WAAW;AAAA,EAClB;AAAA,EAGO,UAAkB;AAClB,WAAA;AAAA,EAAA;AAAA,EAGA,aAAmB;AAC1B,UAAM,WAAW,GAGjB,kBAAkB,kBAAkB;AAAA,EAAA;AAExC;AA3BaJ,IAANK,EAAA;AAAA,EADNC,EAAW;AAAA,EAKPC,OAAO,QAAQ,CAAA;AAAA,EACfA,OAAO,SAAS,CAAA;AAAA,EAAGA,OAAM,YAAY,CAAA;AAAA,EACrCA,OAAO,YAAY,CAAA;AAAA,GANXP,CAAA;;;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A,KAAA,WAAA,QAAAA,EAAQ,MAAM;AAAA,EAAmC;AAE1D;"}
|
package/dist/main/index.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(i,
|
|
1
|
+
(function(i,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("@xwiki/cristal-api"),require("inversify"),require("@xwiki/cristal-backend-api"),require("@xwiki/cristal-utils-inversify")):typeof define=="function"&&define.amd?define(["exports","@xwiki/cristal-api","inversify","@xwiki/cristal-backend-api","@xwiki/cristal-utils-inversify"],c):(i=typeof globalThis<"u"?globalThis:i||self,c(i.cristal_storage={},i.cristalApi,i.inversify,i.cristalBackendApi,i.cristalUtilsInversify))})(this,function(i,c,n,h,S){"use strict";var d=Object.getOwnPropertyDescriptor,f=(t,e,r,a)=>{for(var s=a>1?void 0:a?d(e,r):e,o=t.length-1,l;o>=0;o--)(l=t[o])&&(s=l(s)||s);return s},g=(t,e)=>(r,a)=>e(r,a,t);let m=class extends c.DefaultWikiConfig{constructor(t,e,r){super(t),this.storage=e,this.cristal=r,this.storage.setWikiConfig(this),this.homePage===""&&(this.homePage="index.md")}getType(){return"FileSystem"}initialize(){super.initialize(),fileSystemStorage.initRootDirectory()}};m=f([n.injectable(),g(0,n.inject("Logger")),g(1,n.inject("Storage")),g(1,n.named("FileSystem")),g(2,n.inject("CristalApp"))],m);var p=Object.getOwnPropertyDescriptor,y=(t,e,r,a)=>{for(var s=a>1?void 0:a?p(e,r):e,o=t.length-1,l;o>=0;o--)(l=t[o])&&(s=l(s)||s);return s},v=(t,e)=>(r,a)=>e(r,a,t);let u=class extends h.AbstractStorage{constructor(t){super(t,"storage.components.fileSystemStorage")}getEditField(){return Promise.resolve("")}getImageURL(){return""}async getPageContent(t){const e=decodeURI(t),r=await fileSystemStorage.resolvePath(e),a=await fileSystemStorage.readPage(r||"");return a&&(a.id=e,a.headline=a.name,a.headlineRaw=a.name),a}async getAttachments(t){const e=await fileSystemStorage.resolveAttachmentsPath(t);return{attachments:await fileSystemStorage.readAttachments(e)}}async getAttachment(t,e){const r=await fileSystemStorage.resolveAttachmentPath(t,e);return fileSystemStorage.readAttachment(r)}getPageFromViewURL(){return null}getPageRestURL(){return""}getPanelContent(){return Promise.resolve(new c.DefaultPageData)}isStorageReady(){return Promise.resolve(!0)}async save(t,e,r){const a=await fileSystemStorage.resolvePath(t);await fileSystemStorage.savePage(a,r,e)}async saveAttachments(t,e){return Promise.all(e.map(r=>this.saveAttachment(t,r)))}async delete(t){try{const e=await fileSystemStorage.resolvePath(t);return await fileSystemStorage.deletePage(e),{success:!0}}catch(e){return{success:!1,error:e.message}}}async move(t,e,r){try{const a=await fileSystemStorage.resolvePath(t),s=await fileSystemStorage.resolvePath(e);return await fileSystemStorage.movePage(a,s,r),{success:!0}}catch(a){return{success:!1,error:a.message}}}async saveAttachment(t,e){const r=await fileSystemStorage.resolveAttachmentPath(t,e.name);await fileSystemStorage.saveAttachment(r,e)}};u=y([n.injectable(),v(0,n.inject("Logger"))],u);class P{constructor(e){var r,a;this.logger=e.get("Logger"),this.logger.setModule("electron.storage.components.componentsInit"),(r=this.logger)==null||r.debug("Init Sample Module components begin"),e.bind("WikiConfig").to(m).when(S.whenNamedOrDefault("FileSystem")),e.bind("Storage").to(u).whenNamed("FileSystem"),(a=this.logger)==null||a.debug("Init Sample Module components end")}}i.ComponentInit=P,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
|
|
2
2
|
//# sourceMappingURL=index.umd.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../../src/components/FileSystemConfig.ts","../../src/components/fileSystemStorage.ts","../../src/componentsInit.ts"],"sourcesContent":["/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport { DefaultWikiConfig } from \"@xwiki/cristal-api\";\nimport { inject, injectable, named } from \"inversify\";\nimport type { CristalApp, Logger, Storage } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport class FileSystemConfig extends DefaultWikiConfig {\n override storage: Storage;\n override cristal: CristalApp;\n constructor(\n @inject(\"Logger\") logger: Logger,\n @inject(\"Storage\") @named(\"FileSystem\") storage: Storage,\n @inject(\"CristalApp\") cristal: CristalApp,\n ) {\n super(logger);\n this.storage = storage;\n this.cristal = cristal;\n this.storage.setWikiConfig(this);\n if (this.homePage === \"\") {\n this.homePage = \"index.md\";\n }\n }\n\n override getType(): string {\n return \"FileSystem\";\n }\n\n override initialize(): void {\n super.initialize();\n // The initialization for the root directory needs to be done after a\n // configuration change, but before any storage operation.\n fileSystemStorage.initRootDirectory();\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport {\n AttachmentsData,\n DefaultPageData,\n PageAttachment,\n PageData,\n} from \"@xwiki/cristal-api\";\nimport { AbstractStorage } from \"@xwiki/cristal-backend-api\";\nimport { inject, injectable } from \"inversify\";\nimport type { Logger } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport default class FileSystemStorage extends AbstractStorage {\n constructor(@inject(\"Logger\") logger: Logger) {\n super(logger, \"storage.components.fileSystemStorage\");\n }\n\n getEditField(): Promise<string> {\n return Promise.resolve(\"\");\n }\n\n getImageURL(): string {\n return \"\";\n }\n\n async getPageContent(page: string): Promise<PageData> {\n const decodedPage = decodeURI(page);\n const path = await fileSystemStorage.resolvePath(decodedPage);\n const pageData = await fileSystemStorage.readPage(path || \"\");\n if (pageData) {\n pageData.id = decodedPage;\n pageData.headline = pageData.name;\n pageData.headlineRaw = pageData.name;\n }\n return pageData;\n }\n\n async getAttachments(page: string): Promise<AttachmentsData | undefined> {\n const path = await fileSystemStorage.resolveAttachmentsPath(page);\n return {\n attachments: await fileSystemStorage.readAttachments(path),\n };\n }\n\n async getAttachment(\n page: string,\n name: string,\n ): Promise<PageAttachment | undefined> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, name);\n return fileSystemStorage.readAttachment(path);\n }\n\n getPageFromViewURL(): string | null {\n return null;\n }\n\n getPageRestURL(): string {\n return \"\";\n }\n\n getPanelContent(): Promise<PageData> {\n return Promise.resolve(new DefaultPageData());\n }\n\n isStorageReady(): Promise<boolean> {\n return Promise.resolve(true);\n }\n\n async save(page: string, content: string, title: string): Promise<void> {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.savePage(path, content, title);\n }\n\n async saveAttachments(page: string, files: File[]): Promise<unknown> {\n return Promise.all(files.map((file) => this.saveAttachment(page, file)));\n }\n\n async delete(page: string): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.deletePage(path);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n async move(\n page: string,\n newPage: string,\n preserveChildren: boolean,\n ): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n const newPath = await fileSystemStorage.resolvePath(newPage);\n await fileSystemStorage.movePage(path, newPath, preserveChildren);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n private async saveAttachment(page: string, file: File): Promise<unknown> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, file.name);\n await fileSystemStorage.saveAttachment(path, file);\n return;\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { FileSystemConfig } from \"./components/FileSystemConfig\";\nimport FileSystemStorage from \"./components/fileSystemStorage\";\nimport type { Logger, Storage, WikiConfig } from \"@xwiki/cristal-api\";\nimport type { Container } from \"inversify\";\n\nexport default class ComponentInit {\n logger: Logger;\n\n constructor(container: Container) {\n this.logger = container.get<Logger>(\"Logger\");\n this.logger.setModule(\"electron.storage.components.componentsInit\");\n\n this.logger?.debug(\"Init Sample Module components begin\");\n container\n .bind<WikiConfig>(\"WikiConfig\")\n .to(FileSystemConfig)\n .whenNamed(\"FileSystem\");\n container\n .bind<Storage>(\"Storage\")\n .to(FileSystemStorage)\n .whenNamed(\"FileSystem\");\n this.logger?.debug(\"Init Sample Module components end\");\n }\n}\n"],"names":["FileSystemConfig","DefaultWikiConfig","logger","storage","cristal","__decorateClass","injectable","__decorateParam","FileSystemStorage","AbstractStorage","page","decodedPage","path","pageData","name","DefaultPageData","content","title","files","file","error","newPage","preserveChildren","newPath","ComponentInit","container","_a","_b"],"mappings":"0oBA4Ba,IAAAA,EAAN,cAA+BC,EAAAA,iBAAkB,CAGtD,YACoBC,EACsBC,EAClBC,EACtB,CACA,MAAMF,CAAM,EACZ,KAAK,QAAUC,EACf,KAAK,QAAUC,EACV,KAAA,QAAQ,cAAc,IAAI,EAC3B,KAAK,WAAa,KACpB,KAAK,SAAW,WAClB,CAGO,SAAkB,CAClB,MAAA,YAAA,CAGA,YAAmB,CAC1B,MAAM,WAAW,EAGjB,kBAAkB,kBAAkB,CAAA,CAExC,EA3BaJ,EAANK,EAAA,CADNC,aAAW,EAKPC,aAAO,QAAQ,CAAA,EACfA,aAAO,SAAS,CAAA,EAAGA,YAAM,YAAY,CAAA,EACrCA,aAAO,YAAY,CAAA,CAAA,EANXP,CAAA,2NCMb,IAAqBQ,EAArB,cAA+CC,EAAAA,eAAgB,CAC7D,YAA8BP,EAAgB,CAC5C,MAAMA,EAAQ,sCAAsC,CAAA,CAGtD,cAAgC,CACvB,OAAA,QAAQ,QAAQ,EAAE,CAAA,CAG3B,aAAsB,CACb,MAAA,EAAA,CAGT,MAAM,eAAeQ,EAAiC,CAC9C,MAAAC,EAAc,UAAUD,CAAI,EAC5BE,EAAO,MAAM,kBAAkB,YAAYD,CAAW,EACtDE,EAAW,MAAM,kBAAkB,SAASD,GAAQ,EAAE,EAC5D,OAAIC,IACFA,EAAS,GAAKF,EACdE,EAAS,SAAWA,EAAS,KAC7BA,EAAS,YAAcA,EAAS,MAE3BA,CAAA,CAGT,MAAM,eAAeH,EAAoD,CACvE,MAAME,EAAO,MAAM,kBAAkB,uBAAuBF,CAAI,EACzD,MAAA,CACL,YAAa,MAAM,kBAAkB,gBAAgBE,CAAI,CAC3D,CAAA,CAGF,MA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D,CAEJ,EA/FqBX,EAArBH,EAAA,CADCC,aAAW,EAEGC,aAAO,QAAQ,CAAA,CAAA,EADTC,CAAA,ECTrB,MAAqBgB,CAAc,CAGjC,YAAYC,EAAsB,SAC3B,KAAA,OAASA,EAAU,IAAY,QAAQ,EACvC,KAAA,OAAO,UAAU,4CAA4C,GAE7DC,EAAA,KAAA,SAAA,MAAAA,EAAQ,MAAM,uCACnBD,EACG,KAAiB,YAAY,EAC7B,GAAGzB,CAAgB,EACnB,UAAU,YAAY,EACzByB,EACG,KAAc,SAAS,EACvB,GAAGjB,CAAiB,EACpB,UAAU,YAAY,GACpBmB,EAAA,KAAA,SAAA,MAAAA,EAAQ,MAAM,oCAAmC,CAE1D"}
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../../src/components/FileSystemConfig.ts","../../src/components/fileSystemStorage.ts","../../src/componentsInit.ts"],"sourcesContent":["/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport { DefaultWikiConfig } from \"@xwiki/cristal-api\";\nimport { inject, injectable, named } from \"inversify\";\nimport type { CristalApp, Logger, Storage } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport class FileSystemConfig extends DefaultWikiConfig {\n override storage: Storage;\n override cristal: CristalApp;\n constructor(\n @inject(\"Logger\") logger: Logger,\n @inject(\"Storage\") @named(\"FileSystem\") storage: Storage,\n @inject(\"CristalApp\") cristal: CristalApp,\n ) {\n super(logger);\n this.storage = storage;\n this.cristal = cristal;\n this.storage.setWikiConfig(this);\n if (this.homePage === \"\") {\n this.homePage = \"index.md\";\n }\n }\n\n override getType(): string {\n return \"FileSystem\";\n }\n\n override initialize(): void {\n super.initialize();\n // The initialization for the root directory needs to be done after a\n // configuration change, but before any storage operation.\n fileSystemStorage.initRootDirectory();\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport {\n AttachmentsData,\n DefaultPageData,\n PageAttachment,\n PageData,\n} from \"@xwiki/cristal-api\";\nimport { AbstractStorage } from \"@xwiki/cristal-backend-api\";\nimport { inject, injectable } from \"inversify\";\nimport type { Logger } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport default class FileSystemStorage extends AbstractStorage {\n constructor(@inject(\"Logger\") logger: Logger) {\n super(logger, \"storage.components.fileSystemStorage\");\n }\n\n getEditField(): Promise<string> {\n return Promise.resolve(\"\");\n }\n\n getImageURL(): string {\n return \"\";\n }\n\n async getPageContent(page: string): Promise<PageData> {\n const decodedPage = decodeURI(page);\n const path = await fileSystemStorage.resolvePath(decodedPage);\n const pageData = await fileSystemStorage.readPage(path || \"\");\n if (pageData) {\n pageData.id = decodedPage;\n pageData.headline = pageData.name;\n pageData.headlineRaw = pageData.name;\n }\n return pageData;\n }\n\n async getAttachments(page: string): Promise<AttachmentsData | undefined> {\n const path = await fileSystemStorage.resolveAttachmentsPath(page);\n return {\n attachments: await fileSystemStorage.readAttachments(path),\n };\n }\n\n async getAttachment(\n page: string,\n name: string,\n ): Promise<PageAttachment | undefined> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, name);\n return fileSystemStorage.readAttachment(path);\n }\n\n getPageFromViewURL(): string | null {\n return null;\n }\n\n getPageRestURL(): string {\n return \"\";\n }\n\n getPanelContent(): Promise<PageData> {\n return Promise.resolve(new DefaultPageData());\n }\n\n isStorageReady(): Promise<boolean> {\n return Promise.resolve(true);\n }\n\n async save(page: string, title: string, content: string): Promise<void> {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.savePage(path, content, title);\n }\n\n async saveAttachments(page: string, files: File[]): Promise<unknown> {\n return Promise.all(files.map((file) => this.saveAttachment(page, file)));\n }\n\n async delete(page: string): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.deletePage(path);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n async move(\n page: string,\n newPage: string,\n preserveChildren: boolean,\n ): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n const newPath = await fileSystemStorage.resolvePath(newPage);\n await fileSystemStorage.movePage(path, newPath, preserveChildren);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n private async saveAttachment(page: string, file: File): Promise<unknown> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, file.name);\n await fileSystemStorage.saveAttachment(path, file);\n return;\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { FileSystemConfig } from \"./components/FileSystemConfig\";\nimport FileSystemStorage from \"./components/fileSystemStorage\";\nimport { whenNamedOrDefault } from \"@xwiki/cristal-utils-inversify\";\nimport type { Logger, Storage, WikiConfig } from \"@xwiki/cristal-api\";\nimport type { Container } from \"inversify\";\n\nexport default class ComponentInit {\n logger: Logger;\n\n constructor(container: Container) {\n this.logger = container.get<Logger>(\"Logger\");\n this.logger.setModule(\"electron.storage.components.componentsInit\");\n\n this.logger?.debug(\"Init Sample Module components begin\");\n container\n .bind<WikiConfig>(\"WikiConfig\")\n .to(FileSystemConfig)\n .when(whenNamedOrDefault(\"FileSystem\"));\n container\n .bind<Storage>(\"Storage\")\n .to(FileSystemStorage)\n .whenNamed(\"FileSystem\");\n this.logger?.debug(\"Init Sample Module components end\");\n }\n}\n"],"names":["FileSystemConfig","DefaultWikiConfig","logger","storage","cristal","__decorateClass","injectable","__decorateParam","FileSystemStorage","AbstractStorage","page","decodedPage","path","pageData","name","DefaultPageData","title","content","files","file","error","newPage","preserveChildren","newPath","ComponentInit","container","_a","whenNamedOrDefault","_b"],"mappings":"2rBA4Ba,IAAAA,EAAN,cAA+BC,EAAAA,iBAAkB,CAGtD,YACoBC,EACsBC,EAClBC,EACtB,CACA,MAAMF,CAAM,EACZ,KAAK,QAAUC,EACf,KAAK,QAAUC,EACV,KAAA,QAAQ,cAAc,IAAI,EAC3B,KAAK,WAAa,KACpB,KAAK,SAAW,WAClB,CAGO,SAAkB,CAClB,MAAA,YAAA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,SAAA,MAAAA,EAAQ,MAAM,oCAAmC,CAE1D"}
|
|
@@ -11,7 +11,7 @@ export default class FileSystemStorage extends AbstractStorage {
|
|
|
11
11
|
getPageRestURL(): string;
|
|
12
12
|
getPanelContent(): Promise<PageData>;
|
|
13
13
|
isStorageReady(): Promise<boolean>;
|
|
14
|
-
save(page: string,
|
|
14
|
+
save(page: string, title: string, content: string): Promise<void>;
|
|
15
15
|
saveAttachments(page: string, files: File[]): Promise<unknown>;
|
|
16
16
|
delete(page: string): Promise<{
|
|
17
17
|
success: boolean;
|
package/dist/preload/index.es.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { DefaultWikiConfig as h, DefaultPageData as S } from "@xwiki/cristal-api";
|
|
2
|
-
import { injectable as c, inject as
|
|
3
|
-
import { AbstractStorage as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { injectable as c, inject as g, named as u } from "inversify";
|
|
3
|
+
import { AbstractStorage as y } from "@xwiki/cristal-backend-api";
|
|
4
|
+
import { whenNamedOrDefault as f } from "@xwiki/cristal-utils-inversify";
|
|
5
|
+
var p = Object.getOwnPropertyDescriptor, d = (t, e, r, a) => {
|
|
6
|
+
for (var s = a > 1 ? void 0 : a ? p(e, r) : e, o = t.length - 1, n; o >= 0; o--)
|
|
7
|
+
(n = t[o]) && (s = n(s) || s);
|
|
8
|
+
return s;
|
|
8
9
|
}, i = (t, e) => (r, a) => e(r, a, t);
|
|
9
|
-
let
|
|
10
|
+
let l = class extends h {
|
|
10
11
|
constructor(t, e, r) {
|
|
11
12
|
super(t), this.storage = e, this.cristal = r, this.storage.setWikiConfig(this), this.homePage === "" && (this.homePage = "index.md");
|
|
12
13
|
}
|
|
@@ -17,19 +18,19 @@ let g = class extends h {
|
|
|
17
18
|
super.initialize(), fileSystemStorage.initRootDirectory();
|
|
18
19
|
}
|
|
19
20
|
};
|
|
20
|
-
|
|
21
|
+
l = d([
|
|
21
22
|
c(),
|
|
22
|
-
i(0,
|
|
23
|
-
i(1,
|
|
23
|
+
i(0, g("Logger")),
|
|
24
|
+
i(1, g("Storage")),
|
|
24
25
|
i(1, u("FileSystem")),
|
|
25
|
-
i(2,
|
|
26
|
-
],
|
|
27
|
-
var
|
|
26
|
+
i(2, g("CristalApp"))
|
|
27
|
+
], l);
|
|
28
|
+
var v = Object.getOwnPropertyDescriptor, P = (t, e, r, a) => {
|
|
28
29
|
for (var s = a > 1 ? void 0 : a ? v(e, r) : e, o = t.length - 1, n; o >= 0; o--)
|
|
29
|
-
(n = t[o]) && (s =
|
|
30
|
-
return
|
|
31
|
-
},
|
|
32
|
-
let m = class extends
|
|
30
|
+
(n = t[o]) && (s = n(s) || s);
|
|
31
|
+
return s;
|
|
32
|
+
}, w = (t, e) => (r, a) => e(r, a, t);
|
|
33
|
+
let m = class extends y {
|
|
33
34
|
constructor(t) {
|
|
34
35
|
super(t, "storage.components.fileSystemStorage");
|
|
35
36
|
}
|
|
@@ -67,7 +68,7 @@ let m = class extends f {
|
|
|
67
68
|
}
|
|
68
69
|
async save(t, e, r) {
|
|
69
70
|
const a = await fileSystemStorage.resolvePath(t);
|
|
70
|
-
await fileSystemStorage.savePage(a,
|
|
71
|
+
await fileSystemStorage.savePage(a, r, e);
|
|
71
72
|
}
|
|
72
73
|
async saveAttachments(t, e) {
|
|
73
74
|
return Promise.all(e.map((r) => this.saveAttachment(t, r)));
|
|
@@ -93,17 +94,17 @@ let m = class extends f {
|
|
|
93
94
|
await fileSystemStorage.saveAttachment(r, e);
|
|
94
95
|
}
|
|
95
96
|
};
|
|
96
|
-
m =
|
|
97
|
+
m = P([
|
|
97
98
|
c(),
|
|
98
|
-
|
|
99
|
+
w(0, g("Logger"))
|
|
99
100
|
], m);
|
|
100
|
-
class
|
|
101
|
+
class b {
|
|
101
102
|
constructor(e) {
|
|
102
103
|
var r, a;
|
|
103
|
-
this.logger = e.get("Logger"), this.logger.setModule("electron.storage.components.componentsInit"), (r = this.logger) == null || r.debug("Init Sample Module components begin"), e.bind("WikiConfig").to(
|
|
104
|
+
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).when(f("FileSystem")), e.bind("Storage").to(m).whenNamed("FileSystem"), (a = this.logger) == null || a.debug("Init Sample Module components end");
|
|
104
105
|
}
|
|
105
106
|
}
|
|
106
107
|
export {
|
|
107
|
-
|
|
108
|
+
b as ComponentInit
|
|
108
109
|
};
|
|
109
110
|
//# sourceMappingURL=index.es.js.map
|
|
@@ -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 { APITypes } from \"../electron/preload/apiTypes\";\nimport { DefaultWikiConfig } from \"@xwiki/cristal-api\";\nimport { inject, injectable, named } from \"inversify\";\nimport type { CristalApp, Logger, Storage } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport class FileSystemConfig extends DefaultWikiConfig {\n override storage: Storage;\n override cristal: CristalApp;\n constructor(\n @inject(\"Logger\") logger: Logger,\n @inject(\"Storage\") @named(\"FileSystem\") storage: Storage,\n @inject(\"CristalApp\") cristal: CristalApp,\n ) {\n super(logger);\n this.storage = storage;\n this.cristal = cristal;\n this.storage.setWikiConfig(this);\n if (this.homePage === \"\") {\n this.homePage = \"index.md\";\n }\n }\n\n override getType(): string {\n return \"FileSystem\";\n }\n\n override initialize(): void {\n super.initialize();\n // The initialization for the root directory needs to be done after a\n // configuration change, but before any storage operation.\n fileSystemStorage.initRootDirectory();\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport {\n AttachmentsData,\n DefaultPageData,\n PageAttachment,\n PageData,\n} from \"@xwiki/cristal-api\";\nimport { AbstractStorage } from \"@xwiki/cristal-backend-api\";\nimport { inject, injectable } from \"inversify\";\nimport type { Logger } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport default class FileSystemStorage extends AbstractStorage {\n constructor(@inject(\"Logger\") logger: Logger) {\n super(logger, \"storage.components.fileSystemStorage\");\n }\n\n getEditField(): Promise<string> {\n return Promise.resolve(\"\");\n }\n\n getImageURL(): string {\n return \"\";\n }\n\n async getPageContent(page: string): Promise<PageData> {\n const decodedPage = decodeURI(page);\n const path = await fileSystemStorage.resolvePath(decodedPage);\n const pageData = await fileSystemStorage.readPage(path || \"\");\n if (pageData) {\n pageData.id = decodedPage;\n pageData.headline = pageData.name;\n pageData.headlineRaw = pageData.name;\n }\n return pageData;\n }\n\n async getAttachments(page: string): Promise<AttachmentsData | undefined> {\n const path = await fileSystemStorage.resolveAttachmentsPath(page);\n return {\n attachments: await fileSystemStorage.readAttachments(path),\n };\n }\n\n async getAttachment(\n page: string,\n name: string,\n ): Promise<PageAttachment | undefined> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, name);\n return fileSystemStorage.readAttachment(path);\n }\n\n getPageFromViewURL(): string | null {\n return null;\n }\n\n getPageRestURL(): string {\n return \"\";\n }\n\n getPanelContent(): Promise<PageData> {\n return Promise.resolve(new DefaultPageData());\n }\n\n isStorageReady(): Promise<boolean> {\n return Promise.resolve(true);\n }\n\n async save(page: string, content: string, title: string): Promise<void> {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.savePage(path, content, title);\n }\n\n async saveAttachments(page: string, files: File[]): Promise<unknown> {\n return Promise.all(files.map((file) => this.saveAttachment(page, file)));\n }\n\n async delete(page: string): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.deletePage(path);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n async move(\n page: string,\n newPage: string,\n preserveChildren: boolean,\n ): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n const newPath = await fileSystemStorage.resolvePath(newPage);\n await fileSystemStorage.movePage(path, newPath, preserveChildren);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n private async saveAttachment(page: string, file: File): Promise<unknown> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, file.name);\n await fileSystemStorage.saveAttachment(path, file);\n return;\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { FileSystemConfig } from \"./components/FileSystemConfig\";\nimport FileSystemStorage from \"./components/fileSystemStorage\";\nimport type { Logger, Storage, WikiConfig } from \"@xwiki/cristal-api\";\nimport type { Container } from \"inversify\";\n\nexport default class ComponentInit {\n logger: Logger;\n\n constructor(container: Container) {\n this.logger = container.get<Logger>(\"Logger\");\n this.logger.setModule(\"electron.storage.components.componentsInit\");\n\n this.logger?.debug(\"Init Sample Module components begin\");\n container\n .bind<WikiConfig>(\"WikiConfig\")\n .to(FileSystemConfig)\n .whenNamed(\"FileSystem\");\n container\n .bind<Storage>(\"Storage\")\n .to(FileSystemStorage)\n .whenNamed(\"FileSystem\");\n this.logger?.debug(\"Init Sample Module components end\");\n }\n}\n"],"names":["FileSystemConfig","DefaultWikiConfig","logger","storage","cristal","__decorateClass","injectable","__decorateParam","FileSystemStorage","AbstractStorage","page","decodedPage","path","pageData","name","DefaultPageData","content","title","files","file","error","newPage","preserveChildren","newPath","ComponentInit","container","_a","_b"],"mappings":";;;;;;;;AA4Ba,IAAAA,IAAN,cAA+BC,EAAkB;AAAA,EAGtD,YACoBC,GACsBC,GAClBC,GACtB;AACA,UAAMF,CAAM,GACZ,KAAK,UAAUC,GACf,KAAK,UAAUC,GACV,KAAA,QAAQ,cAAc,IAAI,GAC3B,KAAK,aAAa,OACpB,KAAK,WAAW;AAAA,EAClB;AAAA,EAGO,UAAkB;AAClB,WAAA;AAAA,EAAA;AAAA,EAGA,aAAmB;AAC1B,UAAM,WAAW,GAGjB,kBAAkB,kBAAkB;AAAA,EAAA;AAExC;AA3BaJ,IAANK,EAAA;AAAA,EADNC,EAA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,KAAiB,YAAY,EAC7B,GAAGzB,CAAgB,EACnB,UAAU,YAAY,GACzByB,EACG,KAAc,SAAS,EACvB,GAAGjB,CAAiB,EACpB,UAAU,YAAY,IACpBmB,IAAA,KAAA,WAAA,QAAAA,EAAQ,MAAM;AAAA,EAAmC;AAE1D;"}
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../../src/components/FileSystemConfig.ts","../../src/components/fileSystemStorage.ts","../../src/componentsInit.ts"],"sourcesContent":["/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport { DefaultWikiConfig } from \"@xwiki/cristal-api\";\nimport { inject, injectable, named } from \"inversify\";\nimport type { CristalApp, Logger, Storage } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport class FileSystemConfig extends DefaultWikiConfig {\n override storage: Storage;\n override cristal: CristalApp;\n constructor(\n @inject(\"Logger\") logger: Logger,\n @inject(\"Storage\") @named(\"FileSystem\") storage: Storage,\n @inject(\"CristalApp\") cristal: CristalApp,\n ) {\n super(logger);\n this.storage = storage;\n this.cristal = cristal;\n this.storage.setWikiConfig(this);\n if (this.homePage === \"\") {\n this.homePage = \"index.md\";\n }\n }\n\n override getType(): string {\n return \"FileSystem\";\n }\n\n override initialize(): void {\n super.initialize();\n // The initialization for the root directory needs to be done after a\n // configuration change, but before any storage operation.\n fileSystemStorage.initRootDirectory();\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport {\n AttachmentsData,\n DefaultPageData,\n PageAttachment,\n PageData,\n} from \"@xwiki/cristal-api\";\nimport { AbstractStorage } from \"@xwiki/cristal-backend-api\";\nimport { inject, injectable } from \"inversify\";\nimport type { Logger } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport default class FileSystemStorage extends AbstractStorage {\n constructor(@inject(\"Logger\") logger: Logger) {\n super(logger, \"storage.components.fileSystemStorage\");\n }\n\n getEditField(): Promise<string> {\n return Promise.resolve(\"\");\n }\n\n getImageURL(): string {\n return \"\";\n }\n\n async getPageContent(page: string): Promise<PageData> {\n const decodedPage = decodeURI(page);\n const path = await fileSystemStorage.resolvePath(decodedPage);\n const pageData = await fileSystemStorage.readPage(path || \"\");\n if (pageData) {\n pageData.id = decodedPage;\n pageData.headline = pageData.name;\n pageData.headlineRaw = pageData.name;\n }\n return pageData;\n }\n\n async getAttachments(page: string): Promise<AttachmentsData | undefined> {\n const path = await fileSystemStorage.resolveAttachmentsPath(page);\n return {\n attachments: await fileSystemStorage.readAttachments(path),\n };\n }\n\n async getAttachment(\n page: string,\n name: string,\n ): Promise<PageAttachment | undefined> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, name);\n return fileSystemStorage.readAttachment(path);\n }\n\n getPageFromViewURL(): string | null {\n return null;\n }\n\n getPageRestURL(): string {\n return \"\";\n }\n\n getPanelContent(): Promise<PageData> {\n return Promise.resolve(new DefaultPageData());\n }\n\n isStorageReady(): Promise<boolean> {\n return Promise.resolve(true);\n }\n\n async save(page: string, title: string, content: string): Promise<void> {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.savePage(path, content, title);\n }\n\n async saveAttachments(page: string, files: File[]): Promise<unknown> {\n return Promise.all(files.map((file) => this.saveAttachment(page, file)));\n }\n\n async delete(page: string): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.deletePage(path);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n async move(\n page: string,\n newPage: string,\n preserveChildren: boolean,\n ): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n const newPath = await fileSystemStorage.resolvePath(newPage);\n await fileSystemStorage.movePage(path, newPath, preserveChildren);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n private async saveAttachment(page: string, file: File): Promise<unknown> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, file.name);\n await fileSystemStorage.saveAttachment(path, file);\n return;\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { FileSystemConfig } from \"./components/FileSystemConfig\";\nimport FileSystemStorage from \"./components/fileSystemStorage\";\nimport { whenNamedOrDefault } from \"@xwiki/cristal-utils-inversify\";\nimport type { Logger, Storage, WikiConfig } from \"@xwiki/cristal-api\";\nimport type { Container } from \"inversify\";\n\nexport default class ComponentInit {\n logger: Logger;\n\n constructor(container: Container) {\n this.logger = container.get<Logger>(\"Logger\");\n this.logger.setModule(\"electron.storage.components.componentsInit\");\n\n this.logger?.debug(\"Init Sample Module components begin\");\n container\n .bind<WikiConfig>(\"WikiConfig\")\n .to(FileSystemConfig)\n .when(whenNamedOrDefault(\"FileSystem\"));\n container\n .bind<Storage>(\"Storage\")\n .to(FileSystemStorage)\n .whenNamed(\"FileSystem\");\n this.logger?.debug(\"Init Sample Module components end\");\n }\n}\n"],"names":["FileSystemConfig","DefaultWikiConfig","logger","storage","cristal","__decorateClass","injectable","__decorateParam","FileSystemStorage","AbstractStorage","page","decodedPage","path","pageData","name","DefaultPageData","title","content","files","file","error","newPage","preserveChildren","newPath","ComponentInit","container","_a","whenNamedOrDefault","_b"],"mappings":";;;;;;;;;AA4Ba,IAAAA,IAAN,cAA+BC,EAAkB;AAAA,EAGtD,YACoBC,GACsBC,GAClBC,GACtB;AACA,UAAMF,CAAM,GACZ,KAAK,UAAUC,GACf,KAAK,UAAUC,GACV,KAAA,QAAQ,cAAc,IAAI,GAC3B,KAAK,aAAa,OACpB,KAAK,WAAW;AAAA,EAClB;AAAA,EAGO,UAAkB;AAClB,WAAA;AAAA,EAAA;AAAA,EAGA,aAAmB;AAC1B,UAAM,WAAW,GAGjB,kBAAkB,kBAAkB;AAAA,EAAA;AAExC;AA3BaJ,IAANK,EAAA;AAAA,EADNC,EAAW;AAAA,EAKPC,OAAO,QAAQ,CAAA;AAAA,EACfA,OAAO,SAAS,CAAA;AAAA,EAAGA,OAAM,YAAY,CAAA;AAAA,EACrCA,OAAO,Y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,EACpB,UAAU,YAAY,IACpBoB,IAAA,KAAA,WAAA,QAAAA,EAAQ,MAAM;AAAA,EAAmC;AAE1D;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(i,
|
|
1
|
+
(function(i,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("@xwiki/cristal-api"),require("inversify"),require("@xwiki/cristal-backend-api"),require("@xwiki/cristal-utils-inversify")):typeof define=="function"&&define.amd?define(["exports","@xwiki/cristal-api","inversify","@xwiki/cristal-backend-api","@xwiki/cristal-utils-inversify"],c):(i=typeof globalThis<"u"?globalThis:i||self,c(i.cristal_storage={},i.cristalApi,i.inversify,i.cristalBackendApi,i.cristalUtilsInversify))})(this,function(i,c,n,h,S){"use strict";var d=Object.getOwnPropertyDescriptor,f=(t,e,r,a)=>{for(var s=a>1?void 0:a?d(e,r):e,o=t.length-1,l;o>=0;o--)(l=t[o])&&(s=l(s)||s);return s},g=(t,e)=>(r,a)=>e(r,a,t);let m=class extends c.DefaultWikiConfig{constructor(t,e,r){super(t),this.storage=e,this.cristal=r,this.storage.setWikiConfig(this),this.homePage===""&&(this.homePage="index.md")}getType(){return"FileSystem"}initialize(){super.initialize(),fileSystemStorage.initRootDirectory()}};m=f([n.injectable(),g(0,n.inject("Logger")),g(1,n.inject("Storage")),g(1,n.named("FileSystem")),g(2,n.inject("CristalApp"))],m);var p=Object.getOwnPropertyDescriptor,y=(t,e,r,a)=>{for(var s=a>1?void 0:a?p(e,r):e,o=t.length-1,l;o>=0;o--)(l=t[o])&&(s=l(s)||s);return s},v=(t,e)=>(r,a)=>e(r,a,t);let u=class extends h.AbstractStorage{constructor(t){super(t,"storage.components.fileSystemStorage")}getEditField(){return Promise.resolve("")}getImageURL(){return""}async getPageContent(t){const e=decodeURI(t),r=await fileSystemStorage.resolvePath(e),a=await fileSystemStorage.readPage(r||"");return a&&(a.id=e,a.headline=a.name,a.headlineRaw=a.name),a}async getAttachments(t){const e=await fileSystemStorage.resolveAttachmentsPath(t);return{attachments:await fileSystemStorage.readAttachments(e)}}async getAttachment(t,e){const r=await fileSystemStorage.resolveAttachmentPath(t,e);return fileSystemStorage.readAttachment(r)}getPageFromViewURL(){return null}getPageRestURL(){return""}getPanelContent(){return Promise.resolve(new c.DefaultPageData)}isStorageReady(){return Promise.resolve(!0)}async save(t,e,r){const a=await fileSystemStorage.resolvePath(t);await fileSystemStorage.savePage(a,r,e)}async saveAttachments(t,e){return Promise.all(e.map(r=>this.saveAttachment(t,r)))}async delete(t){try{const e=await fileSystemStorage.resolvePath(t);return await fileSystemStorage.deletePage(e),{success:!0}}catch(e){return{success:!1,error:e.message}}}async move(t,e,r){try{const a=await fileSystemStorage.resolvePath(t),s=await fileSystemStorage.resolvePath(e);return await fileSystemStorage.movePage(a,s,r),{success:!0}}catch(a){return{success:!1,error:a.message}}}async saveAttachment(t,e){const r=await fileSystemStorage.resolveAttachmentPath(t,e.name);await fileSystemStorage.saveAttachment(r,e)}};u=y([n.injectable(),v(0,n.inject("Logger"))],u);class P{constructor(e){var r,a;this.logger=e.get("Logger"),this.logger.setModule("electron.storage.components.componentsInit"),(r=this.logger)==null||r.debug("Init Sample Module components begin"),e.bind("WikiConfig").to(m).when(S.whenNamedOrDefault("FileSystem")),e.bind("Storage").to(u).whenNamed("FileSystem"),(a=this.logger)==null||a.debug("Init Sample Module components end")}}i.ComponentInit=P,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
|
|
2
2
|
//# sourceMappingURL=index.umd.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../../src/components/FileSystemConfig.ts","../../src/components/fileSystemStorage.ts","../../src/componentsInit.ts"],"sourcesContent":["/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport { DefaultWikiConfig } from \"@xwiki/cristal-api\";\nimport { inject, injectable, named } from \"inversify\";\nimport type { CristalApp, Logger, Storage } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport class FileSystemConfig extends DefaultWikiConfig {\n override storage: Storage;\n override cristal: CristalApp;\n constructor(\n @inject(\"Logger\") logger: Logger,\n @inject(\"Storage\") @named(\"FileSystem\") storage: Storage,\n @inject(\"CristalApp\") cristal: CristalApp,\n ) {\n super(logger);\n this.storage = storage;\n this.cristal = cristal;\n this.storage.setWikiConfig(this);\n if (this.homePage === \"\") {\n this.homePage = \"index.md\";\n }\n }\n\n override getType(): string {\n return \"FileSystem\";\n }\n\n override initialize(): void {\n super.initialize();\n // The initialization for the root directory needs to be done after a\n // configuration change, but before any storage operation.\n fileSystemStorage.initRootDirectory();\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport {\n AttachmentsData,\n DefaultPageData,\n PageAttachment,\n PageData,\n} from \"@xwiki/cristal-api\";\nimport { AbstractStorage } from \"@xwiki/cristal-backend-api\";\nimport { inject, injectable } from \"inversify\";\nimport type { Logger } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport default class FileSystemStorage extends AbstractStorage {\n constructor(@inject(\"Logger\") logger: Logger) {\n super(logger, \"storage.components.fileSystemStorage\");\n }\n\n getEditField(): Promise<string> {\n return Promise.resolve(\"\");\n }\n\n getImageURL(): string {\n return \"\";\n }\n\n async getPageContent(page: string): Promise<PageData> {\n const decodedPage = decodeURI(page);\n const path = await fileSystemStorage.resolvePath(decodedPage);\n const pageData = await fileSystemStorage.readPage(path || \"\");\n if (pageData) {\n pageData.id = decodedPage;\n pageData.headline = pageData.name;\n pageData.headlineRaw = pageData.name;\n }\n return pageData;\n }\n\n async getAttachments(page: string): Promise<AttachmentsData | undefined> {\n const path = await fileSystemStorage.resolveAttachmentsPath(page);\n return {\n attachments: await fileSystemStorage.readAttachments(path),\n };\n }\n\n async getAttachment(\n page: string,\n name: string,\n ): Promise<PageAttachment | undefined> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, name);\n return fileSystemStorage.readAttachment(path);\n }\n\n getPageFromViewURL(): string | null {\n return null;\n }\n\n getPageRestURL(): string {\n return \"\";\n }\n\n getPanelContent(): Promise<PageData> {\n return Promise.resolve(new DefaultPageData());\n }\n\n isStorageReady(): Promise<boolean> {\n return Promise.resolve(true);\n }\n\n async save(page: string, content: string, title: string): Promise<void> {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.savePage(path, content, title);\n }\n\n async saveAttachments(page: string, files: File[]): Promise<unknown> {\n return Promise.all(files.map((file) => this.saveAttachment(page, file)));\n }\n\n async delete(page: string): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.deletePage(path);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n async move(\n page: string,\n newPage: string,\n preserveChildren: boolean,\n ): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n const newPath = await fileSystemStorage.resolvePath(newPage);\n await fileSystemStorage.movePage(path, newPath, preserveChildren);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n private async saveAttachment(page: string, file: File): Promise<unknown> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, file.name);\n await fileSystemStorage.saveAttachment(path, file);\n return;\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { FileSystemConfig } from \"./components/FileSystemConfig\";\nimport FileSystemStorage from \"./components/fileSystemStorage\";\nimport type { Logger, Storage, WikiConfig } from \"@xwiki/cristal-api\";\nimport type { Container } from \"inversify\";\n\nexport default class ComponentInit {\n logger: Logger;\n\n constructor(container: Container) {\n this.logger = container.get<Logger>(\"Logger\");\n this.logger.setModule(\"electron.storage.components.componentsInit\");\n\n this.logger?.debug(\"Init Sample Module components begin\");\n container\n .bind<WikiConfig>(\"WikiConfig\")\n .to(FileSystemConfig)\n .whenNamed(\"FileSystem\");\n container\n .bind<Storage>(\"Storage\")\n .to(FileSystemStorage)\n .whenNamed(\"FileSystem\");\n this.logger?.debug(\"Init Sample Module components end\");\n }\n}\n"],"names":["FileSystemConfig","DefaultWikiConfig","logger","storage","cristal","__decorateClass","injectable","__decorateParam","FileSystemStorage","AbstractStorage","page","decodedPage","path","pageData","name","DefaultPageData","content","title","files","file","error","newPage","preserveChildren","newPath","ComponentInit","container","_a","_b"],"mappings":"0oBA4Ba,IAAAA,EAAN,cAA+BC,EAAAA,iBAAkB,CAGtD,YACoBC,EACsBC,EAClBC,EACtB,CACA,MAAMF,CAAM,EACZ,KAAK,QAAUC,EACf,KAAK,QAAUC,EACV,KAAA,QAAQ,cAAc,IAAI,EAC3B,KAAK,WAAa,KACpB,KAAK,SAAW,WAClB,CAGO,SAAkB,CAClB,MAAA,YAAA,CAGA,YAAmB,CAC1B,MAAM,WAAW,EAGjB,kBAAkB,kBAAkB,CAAA,CAExC,EA3BaJ,EAANK,EAAA,CADNC,aAAW,EAKPC,aAAO,QAAQ,CAAA,EACfA,aAAO,SAAS,CAAA,EAAGA,YAAM,YAAY,CAAA,EACrCA,aAAO,YAAY,CAAA,CAAA,EANXP,CAAA,2NCMb,IAAqBQ,EAArB,cAA+CC,EAAAA,eAAgB,CAC7D,YAA8BP,EAAgB,CAC5C,MAAMA,EAAQ,sCAAsC,CAAA,CAGtD,cAAgC,CACvB,OAAA,QAAQ,QAAQ,EAAE,CAAA,CAG3B,aAAsB,CACb,MAAA,EAAA,CAGT,MAAM,eAAeQ,EAAiC,CAC9C,MAAAC,EAAc,UAAUD,CAAI,EAC5BE,EAAO,MAAM,kBAAkB,YAAYD,CAAW,EACtDE,EAAW,MAAM,kBAAkB,SAASD,GAAQ,EAAE,EAC5D,OAAIC,IACFA,EAAS,GAAKF,EACdE,EAAS,SAAWA,EAAS,KAC7BA,EAAS,YAAcA,EAAS,MAE3BA,CAAA,CAGT,MAAM,eAAeH,EAAoD,CACvE,MAAME,EAAO,MAAM,kBAAkB,uBAAuBF,CAAI,EACzD,MAAA,CACL,YAAa,MAAM,kBAAkB,gBAAgBE,CAAI,CAC3D,CAAA,C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AI,CACjD,CAEJ,EA/FqBX,EAArBH,EAAA,CADCC,aAAW,EAEGC,aAAO,QAAQ,CAAA,CAAA,EADTC,CAAA,ECTrB,MAAqBgB,CAAc,CAGjC,YAAYC,EAAsB,SAC3B,KAAA,OAASA,EAAU,IAAY,QAAQ,EACvC,KAAA,OAAO,UAAU,4CAA4C,GAE7DC,EAAA,KAAA,SAAA,MAAAA,EAAQ,MAAM,uCACnBD,EACG,KAAiB,YAAY,EAC7B,GAAGzB,CAAgB,EACnB,UAAU,YAAY,EACzByB,EACG,KAAc,SAAS,EACvB,GAAGjB,CAAiB,EACpB,UAAU,YAAY,GACpBmB,EAAA,KAAA,SAAA,MAAAA,EAAQ,MAAM,oCAAmC,CAE1D"}
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../../src/components/FileSystemConfig.ts","../../src/components/fileSystemStorage.ts","../../src/componentsInit.ts"],"sourcesContent":["/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport { DefaultWikiConfig } from \"@xwiki/cristal-api\";\nimport { inject, injectable, named } from \"inversify\";\nimport type { CristalApp, Logger, Storage } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport class FileSystemConfig extends DefaultWikiConfig {\n override storage: Storage;\n override cristal: CristalApp;\n constructor(\n @inject(\"Logger\") logger: Logger,\n @inject(\"Storage\") @named(\"FileSystem\") storage: Storage,\n @inject(\"CristalApp\") cristal: CristalApp,\n ) {\n super(logger);\n this.storage = storage;\n this.cristal = cristal;\n this.storage.setWikiConfig(this);\n if (this.homePage === \"\") {\n this.homePage = \"index.md\";\n }\n }\n\n override getType(): string {\n return \"FileSystem\";\n }\n\n override initialize(): void {\n super.initialize();\n // The initialization for the root directory needs to be done after a\n // configuration change, but before any storage operation.\n fileSystemStorage.initRootDirectory();\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { APITypes } from \"../electron/preload/apiTypes\";\nimport {\n AttachmentsData,\n DefaultPageData,\n PageAttachment,\n PageData,\n} from \"@xwiki/cristal-api\";\nimport { AbstractStorage } from \"@xwiki/cristal-backend-api\";\nimport { inject, injectable } from \"inversify\";\nimport type { Logger } from \"@xwiki/cristal-api\";\n\ndeclare const fileSystemStorage: APITypes;\n\n@injectable()\nexport default class FileSystemStorage extends AbstractStorage {\n constructor(@inject(\"Logger\") logger: Logger) {\n super(logger, \"storage.components.fileSystemStorage\");\n }\n\n getEditField(): Promise<string> {\n return Promise.resolve(\"\");\n }\n\n getImageURL(): string {\n return \"\";\n }\n\n async getPageContent(page: string): Promise<PageData> {\n const decodedPage = decodeURI(page);\n const path = await fileSystemStorage.resolvePath(decodedPage);\n const pageData = await fileSystemStorage.readPage(path || \"\");\n if (pageData) {\n pageData.id = decodedPage;\n pageData.headline = pageData.name;\n pageData.headlineRaw = pageData.name;\n }\n return pageData;\n }\n\n async getAttachments(page: string): Promise<AttachmentsData | undefined> {\n const path = await fileSystemStorage.resolveAttachmentsPath(page);\n return {\n attachments: await fileSystemStorage.readAttachments(path),\n };\n }\n\n async getAttachment(\n page: string,\n name: string,\n ): Promise<PageAttachment | undefined> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, name);\n return fileSystemStorage.readAttachment(path);\n }\n\n getPageFromViewURL(): string | null {\n return null;\n }\n\n getPageRestURL(): string {\n return \"\";\n }\n\n getPanelContent(): Promise<PageData> {\n return Promise.resolve(new DefaultPageData());\n }\n\n isStorageReady(): Promise<boolean> {\n return Promise.resolve(true);\n }\n\n async save(page: string, title: string, content: string): Promise<void> {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.savePage(path, content, title);\n }\n\n async saveAttachments(page: string, files: File[]): Promise<unknown> {\n return Promise.all(files.map((file) => this.saveAttachment(page, file)));\n }\n\n async delete(page: string): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n await fileSystemStorage.deletePage(path);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n async move(\n page: string,\n newPage: string,\n preserveChildren: boolean,\n ): Promise<{ success: boolean; error?: string }> {\n try {\n const path = await fileSystemStorage.resolvePath(page);\n const newPath = await fileSystemStorage.resolvePath(newPage);\n await fileSystemStorage.movePage(path, newPath, preserveChildren);\n return { success: true };\n } catch (error) {\n return { success: false, error: (error as Error).message };\n }\n }\n\n private async saveAttachment(page: string, file: File): Promise<unknown> {\n const path = await fileSystemStorage.resolveAttachmentPath(page, file.name);\n await fileSystemStorage.saveAttachment(path, file);\n return;\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { FileSystemConfig } from \"./components/FileSystemConfig\";\nimport FileSystemStorage from \"./components/fileSystemStorage\";\nimport { whenNamedOrDefault } from \"@xwiki/cristal-utils-inversify\";\nimport type { Logger, Storage, WikiConfig } from \"@xwiki/cristal-api\";\nimport type { Container } from \"inversify\";\n\nexport default class ComponentInit {\n logger: Logger;\n\n constructor(container: Container) {\n this.logger = container.get<Logger>(\"Logger\");\n this.logger.setModule(\"electron.storage.components.componentsInit\");\n\n this.logger?.debug(\"Init Sample Module components begin\");\n container\n .bind<WikiConfig>(\"WikiConfig\")\n .to(FileSystemConfig)\n .when(whenNamedOrDefault(\"FileSystem\"));\n container\n .bind<Storage>(\"Storage\")\n .to(FileSystemStorage)\n .whenNamed(\"FileSystem\");\n this.logger?.debug(\"Init Sample Module components end\");\n }\n}\n"],"names":["FileSystemConfig","DefaultWikiConfig","logger","storage","cristal","__decorateClass","injectable","__decorateParam","FileSystemStorage","AbstractStorage","page","decodedPage","path","pageData","name","DefaultPageData","title","content","files","file","error","newPage","preserveChildren","newPath","ComponentInit","container","_a","whenNamedOrDefault","_b"],"mappings":"2rBA4Ba,IAAAA,EAAN,cAA+BC,EAAAA,iBAAkB,CAGtD,YACoBC,EACsBC,EAClBC,EACtB,CACA,MAAMF,CAAM,EACZ,KAAK,QAAUC,EACf,KAAK,QAAUC,EACV,KAAA,QAAQ,cAAc,IAAI,EAC3B,KAAK,WAAa,KACpB,KAAK,SAAW,WAClB,CAGO,SAAkB,CAClB,MAA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A,KAAA,SAAA,MAAAA,EAAQ,MAAM,oCAAmC,CAE1D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xwiki/cristal-electron-storage",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"license": "LGPL 2.1",
|
|
5
5
|
"author": "XWiki Org Community <contact@xwiki.org>",
|
|
6
6
|
"homepage": "https://cristal.xwiki.org/",
|
|
@@ -32,26 +32,27 @@
|
|
|
32
32
|
},
|
|
33
33
|
"main": "./dist/main/index.es.js",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"inversify": "7.5.
|
|
36
|
-
"mime": "4.0.
|
|
37
|
-
"@xwiki/cristal-
|
|
38
|
-
"@xwiki/cristal-
|
|
39
|
-
"@xwiki/cristal-
|
|
40
|
-
"@xwiki/cristal-
|
|
41
|
-
"@xwiki/cristal-api": "0.
|
|
42
|
-
"@xwiki/cristal-
|
|
35
|
+
"inversify": "7.5.1",
|
|
36
|
+
"mime": "4.0.7",
|
|
37
|
+
"@xwiki/cristal-api": "0.18.0",
|
|
38
|
+
"@xwiki/cristal-electron-state": "0.18.0",
|
|
39
|
+
"@xwiki/cristal-model-api": "0.18.0",
|
|
40
|
+
"@xwiki/cristal-link-suggest-api": "0.18.0",
|
|
41
|
+
"@xwiki/cristal-model-remote-url-filesystem-api": "0.18.0",
|
|
42
|
+
"@xwiki/cristal-utils-inversify": "0.18.0",
|
|
43
|
+
"@xwiki/cristal-backend-api": "0.18.0"
|
|
43
44
|
},
|
|
44
45
|
"peerDependencies": {
|
|
45
|
-
"electron": "
|
|
46
|
+
"electron": "36.0.0",
|
|
46
47
|
"reflect-metadata": "0.2.2"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
|
-
"@types/node": "22.
|
|
50
|
+
"@types/node": "22.15.3",
|
|
50
51
|
"reflect-metadata": "0.2.2",
|
|
51
|
-
"typescript": "5.8.
|
|
52
|
-
"vite": "6.
|
|
53
|
-
"vite-plugin-node": "5.0.
|
|
54
|
-
"@xwiki/cristal-dev-config": "0.
|
|
52
|
+
"typescript": "5.8.3",
|
|
53
|
+
"vite": "6.3.5",
|
|
54
|
+
"vite-plugin-node": "5.0.1",
|
|
55
|
+
"@xwiki/cristal-dev-config": "0.18.0"
|
|
55
56
|
},
|
|
56
57
|
"scripts": {
|
|
57
58
|
"build": "pnpm compile",
|
|
@@ -88,7 +88,7 @@ export default class FileSystemStorage extends AbstractStorage {
|
|
|
88
88
|
return Promise.resolve(true);
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
async save(page: string,
|
|
91
|
+
async save(page: string, title: string, content: string): Promise<void> {
|
|
92
92
|
const path = await fileSystemStorage.resolvePath(page);
|
|
93
93
|
await fileSystemStorage.savePage(path, content, title);
|
|
94
94
|
}
|
package/src/componentsInit.ts
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
import { FileSystemConfig } from "./components/FileSystemConfig";
|
|
22
22
|
import FileSystemStorage from "./components/fileSystemStorage";
|
|
23
|
+
import { whenNamedOrDefault } from "@xwiki/cristal-utils-inversify";
|
|
23
24
|
import type { Logger, Storage, WikiConfig } from "@xwiki/cristal-api";
|
|
24
25
|
import type { Container } from "inversify";
|
|
25
26
|
|
|
@@ -34,7 +35,7 @@ export default class ComponentInit {
|
|
|
34
35
|
container
|
|
35
36
|
.bind<WikiConfig>("WikiConfig")
|
|
36
37
|
.to(FileSystemConfig)
|
|
37
|
-
.
|
|
38
|
+
.when(whenNamedOrDefault("FileSystem"));
|
|
38
39
|
container
|
|
39
40
|
.bind<Storage>("Storage")
|
|
40
41
|
.to(FileSystemStorage)
|
|
@@ -46,7 +46,7 @@ const api: APITypes = {
|
|
|
46
46
|
});
|
|
47
47
|
},
|
|
48
48
|
savePage(path: string, content: string, title: string): Promise<PageData> {
|
|
49
|
-
return ipcRenderer.invoke("savePage", { path,
|
|
49
|
+
return ipcRenderer.invoke("savePage", { path, title, content });
|
|
50
50
|
},
|
|
51
51
|
resolveAttachmentPath(page: string, filename: string): Promise<string> {
|
|
52
52
|
return ipcRenderer.invoke("resolveAttachmentPath", {
|