@xwiki/cristal-electron-settings-main 0.21.1 → 0.22.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 +7 -4
- package/api-extractor.json +4 -0
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.es.js +24 -30
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/storage.d.ts +4 -0
- package/etc/cristal-electron-settings-main.api.md +17 -0
- package/package.json +12 -10
- package/src/index.ts +4 -0
- package/src/storage.ts +15 -22
- package/tsdoc.json +4 -0
- package/vitest.config.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
# @xwiki/cristal-electron-settings-main
|
|
2
2
|
|
|
3
|
-
## 0.
|
|
3
|
+
## 0.22.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Cristal 0.22 Release
|
|
4
8
|
|
|
5
9
|
### Patch Changes
|
|
6
10
|
|
|
7
|
-
- Cristal 0.21.1 Release
|
|
8
11
|
- Updated dependencies
|
|
9
|
-
- @xwiki/cristal-configuration-api@0.
|
|
10
|
-
- @xwiki/cristal-settings-api@0.
|
|
12
|
+
- @xwiki/cristal-configuration-api@0.22.0
|
|
13
|
+
- @xwiki/cristal-settings-api@0.22.0
|
|
11
14
|
|
|
12
15
|
## 0.21.0
|
|
13
16
|
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.es.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ipcMain as
|
|
3
|
-
const
|
|
4
|
-
configuration:
|
|
5
|
-
},
|
|
1
|
+
import o from "electron-store";
|
|
2
|
+
import { ipcMain as t } from "electron";
|
|
3
|
+
const r = { FileSystem: { name: "FileSystem", configType: "FileSystem", serverRendering: !1, offline: !1, designSystem: "vuetify", editor: "tiptap" }, FileSystemSL: { name: "FileSystemSL", configType: "FileSystem", serverRendering: !1, offline: !1, designSystem: "shoelace", editor: "tiptap" }, XWiki: { name: "XWiki", configType: "XWiki", serverRendering: !1, offline: !1, baseURL: "https://cristal-backend.demo.xwiki.com/xwiki", baseRestURL: "/rest/cristal/page?media=json", homePage: "Main.WebHome", designSystem: "vuetify", editor: "tiptap", realtimeURL: "https://cristal.demo.xwiki.com:8093/collaboration" }, XWikiSL: { name: "XWikiSL", configType: "XWiki", serverRendering: !1, offline: !1, baseURL: "https://cristal-backend.demo.xwiki.com/xwiki", baseRestURL: "/rest/cristal/page?media=json", homePage: "Main.WebHome", designSystem: "shoelace", editor: "tiptap", realtimeURL: "https://cristal.demo.xwiki.com:8093/collaboration" } }, c = {
|
|
4
|
+
configuration: r
|
|
5
|
+
}, l = "configuration", n = "_raw", f = {
|
|
6
6
|
_raw: {
|
|
7
7
|
type: "string"
|
|
8
8
|
},
|
|
9
9
|
configuration: {
|
|
10
10
|
type: "object"
|
|
11
11
|
}
|
|
12
|
-
},
|
|
12
|
+
}, i = new o({
|
|
13
13
|
name: "settings",
|
|
14
14
|
// Here, we want to keep in the store the raw string representation of the
|
|
15
15
|
// file, since it should be parsed and serialized by the SettingsManager
|
|
@@ -17,41 +17,35 @@ const c = { FileSystem: { name: "FileSystem", configType: "FileSystem", serverRe
|
|
|
17
17
|
// some settings values on Electron's main process.
|
|
18
18
|
serialize: (e) => e._raw,
|
|
19
19
|
deserialize: (e) => ({ _raw: e, ...JSON.parse(e) }),
|
|
20
|
-
schema:
|
|
20
|
+
schema: f
|
|
21
21
|
});
|
|
22
|
-
function
|
|
23
|
-
|
|
22
|
+
function s(e) {
|
|
23
|
+
i.set(n, e);
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
return
|
|
25
|
+
function g() {
|
|
26
|
+
return i.size < 2 && s(JSON.stringify(c, null, 2)), i.get(n);
|
|
27
27
|
}
|
|
28
|
-
function
|
|
29
|
-
|
|
28
|
+
function S() {
|
|
29
|
+
return i.get(l);
|
|
30
30
|
}
|
|
31
|
-
function
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
function k() {
|
|
35
|
-
return a(f);
|
|
31
|
+
function m(e) {
|
|
32
|
+
s(e);
|
|
36
33
|
}
|
|
37
|
-
function
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
function y() {
|
|
41
|
-
return d();
|
|
34
|
+
function d() {
|
|
35
|
+
return g();
|
|
42
36
|
}
|
|
43
|
-
function
|
|
44
|
-
|
|
37
|
+
function u() {
|
|
38
|
+
t.handle(
|
|
45
39
|
"settings:save",
|
|
46
40
|
async (e, {
|
|
47
|
-
settings:
|
|
41
|
+
settings: a
|
|
48
42
|
}) => {
|
|
49
|
-
|
|
43
|
+
m(a);
|
|
50
44
|
}
|
|
51
|
-
),
|
|
45
|
+
), t.handle("settings:load", async () => d());
|
|
52
46
|
}
|
|
53
47
|
export {
|
|
54
|
-
|
|
55
|
-
|
|
48
|
+
S as getConfigurations,
|
|
49
|
+
u as load
|
|
56
50
|
};
|
|
57
51
|
//# sourceMappingURL=index.es.js.map
|
package/dist/index.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../src/storage.ts","../src/index.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 defaultSettings from \"./defaultSettings.json\";\nimport { Configurations } from \"@xwiki/cristal-configuration-api\";\
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../src/storage.ts","../src/index.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 defaultSettings from \"./defaultSettings.json\";\nimport Store from \"electron-store\";\nimport type { Configurations } from \"@xwiki/cristal-configuration-api\";\n\nconst configurationKey = \"configuration\";\nconst settingsKey = \"_raw\";\n\nconst schema = {\n _raw: {\n type: \"string\",\n },\n configuration: {\n type: \"object\",\n },\n};\n\ntype StoreType = {\n _raw: string;\n configuration: object;\n};\n\nconst storeInstance: Store<StoreType> = new Store<StoreType>({\n name: \"settings\",\n // Here, we want to keep in the store the raw string representation of the\n // file, since it should be parsed and serialized by the SettingsManager\n // service. We still include the deserialized object in case we want to check\n // some settings values on Electron's main process.\n serialize: (value: Record<string, unknown>) => value._raw as string,\n deserialize: (value: string) => ({ _raw: value, ...JSON.parse(value) }),\n schema,\n});\n\nfunction setSettings(value: string): void {\n storeInstance.set(settingsKey, value);\n}\n\nfunction getSettings(): string {\n if (storeInstance.size < 2) {\n setSettings(JSON.stringify(defaultSettings, null, 2));\n }\n return storeInstance.get(settingsKey);\n}\n\nfunction deleteSettings(): void {\n storeInstance.delete(settingsKey);\n}\n\n/**\n * @since 0.18\n * @beta\n */\nfunction getConfigurations(): Configurations {\n return storeInstance.get(configurationKey) as Configurations;\n}\n\nexport { deleteSettings, getConfigurations, getSettings, setSettings };\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 { getConfigurations, getSettings, setSettings } from \"./storage\";\nimport { ipcMain } from \"electron\";\n\nfunction saveSettings(settings: string): void {\n setSettings(settings);\n}\n\nfunction loadSettings(): string {\n return getSettings();\n}\n\n/**\n * @since 0.18\n * @beta\n */\nfunction load(): void {\n ipcMain.handle(\n \"settings:save\",\n async (\n _event,\n {\n settings,\n }: {\n settings: string;\n },\n ): Promise<void> => {\n saveSettings(settings);\n },\n );\n\n ipcMain.handle(\"settings:load\", async (): Promise<string> => {\n return loadSettings();\n });\n}\n\nexport { getConfigurations, load };\n"],"names":["configurationKey","settingsKey","schema","storeInstance","Store","value","setSettings","getSettings","defaultSettings","getConfigurations","saveSettings","settings","loadSettings","load","ipcMain","_event"],"mappings":";;;;GAwBMA,IAAmB,iBACnBC,IAAc,QAEdC,IAAS;AAAA,EACb,MAAM;AAAA,IACJ,MAAM;AAAA,EAAA;AAAA,EAER,eAAe;AAAA,IACb,MAAM;AAAA,EAAA;AAEV,GAOMC,IAAkC,IAAIC,EAAiB;AAAA,EAC3D,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,EAKN,WAAW,CAACC,MAAmCA,EAAM;AAAA,EACrD,aAAa,CAACA,OAAmB,EAAE,MAAMA,GAAO,GAAG,KAAK,MAAMA,CAAK;EACnE,QAAAH;AACF,CAAC;AAED,SAASI,EAAYD,GAAqB;AACxC,EAAAF,EAAc,IAAIF,GAAaI,CAAK;AACtC;AAEA,SAASE,IAAsB;AAC7B,SAAIJ,EAAc,OAAO,KACvBG,EAAY,KAAK,UAAUE,GAAiB,MAAM,CAAC,CAAC,GAE/CL,EAAc,IAAIF,CAAW;AACtC;AAUA,SAASQ,IAAoC;AAC3C,SAAON,EAAc,IAAIH,CAAgB;AAC3C;AClDA,SAASU,EAAaC,GAAwB;AAC5C,EAAAL,EAAYK,CAAQ;AACtB;AAEA,SAASC,IAAuB;AAC9B,SAAOL,EAAA;AACT;AAMA,SAASM,IAAa;AACpB,EAAAC,EAAQ;AAAA,IACN;AAAA,IACA,OACEC,GACA;AAAA,MACE,UAAAJ;AAAA,IAAA,MAIgB;AAClB,MAAAD,EAAaC,CAAQ;AAAA,IACvB;AAAA,EAAA,GAGFG,EAAQ,OAAO,iBAAiB,YACvBF,EAAA,CACR;AACH;"}
|
package/dist/index.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(e,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("electron-store"),require("electron")):typeof define=="function"&&define.amd?define(["exports","electron-store","electron"],t):(e=typeof globalThis<"u"?globalThis:e||self,t(e["cristal_settings-main"]={},e.Store,e.electron))})(this,(function(e,t,s){"use strict";const r={configuration:{FileSystem:{name:"FileSystem",configType:"FileSystem",serverRendering:!1,offline:!1,designSystem:"vuetify",editor:"tiptap"},FileSystemSL:{name:"FileSystemSL",configType:"FileSystem",serverRendering:!1,offline:!1,designSystem:"shoelace",editor:"tiptap"},XWiki:{name:"XWiki",configType:"XWiki",serverRendering:!1,offline:!1,baseURL:"https://cristal-backend.demo.xwiki.com/xwiki",baseRestURL:"/rest/cristal/page?media=json",homePage:"Main.WebHome",designSystem:"vuetify",editor:"tiptap",realtimeURL:"https://cristal.demo.xwiki.com:8093/collaboration"},XWikiSL:{name:"XWikiSL",configType:"XWiki",serverRendering:!1,offline:!1,baseURL:"https://cristal-backend.demo.xwiki.com/xwiki",baseRestURL:"/rest/cristal/page?media=json",homePage:"Main.WebHome",designSystem:"shoelace",editor:"tiptap",realtimeURL:"https://cristal.demo.xwiki.com:8093/collaboration"}}},c="configuration",o="_raw",f={_raw:{type:"string"},configuration:{type:"object"}},n=new t({name:"settings",serialize:i=>i._raw,deserialize:i=>({_raw:i,...JSON.parse(i)}),schema:f});function a(i){n.set(o,i)}function l(){return n.size<2&&a(JSON.stringify(r,null,2)),n.get(o)}function g(){return n.get(c)}function d(i){a(i)}function m(){return l()}function u(){s.ipcMain.handle("settings:save",async(i,{settings:p})=>{d(p)}),s.ipcMain.handle("settings:load",async()=>m())}e.getConfigurations=g,e.load=u,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
|
|
2
2
|
//# sourceMappingURL=index.umd.js.map
|
package/dist/index.umd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../src/storage.ts","../src/index.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 defaultSettings from \"./defaultSettings.json\";\nimport { Configurations } from \"@xwiki/cristal-configuration-api\";\
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../src/storage.ts","../src/index.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 defaultSettings from \"./defaultSettings.json\";\nimport Store from \"electron-store\";\nimport type { Configurations } from \"@xwiki/cristal-configuration-api\";\n\nconst configurationKey = \"configuration\";\nconst settingsKey = \"_raw\";\n\nconst schema = {\n _raw: {\n type: \"string\",\n },\n configuration: {\n type: \"object\",\n },\n};\n\ntype StoreType = {\n _raw: string;\n configuration: object;\n};\n\nconst storeInstance: Store<StoreType> = new Store<StoreType>({\n name: \"settings\",\n // Here, we want to keep in the store the raw string representation of the\n // file, since it should be parsed and serialized by the SettingsManager\n // service. We still include the deserialized object in case we want to check\n // some settings values on Electron's main process.\n serialize: (value: Record<string, unknown>) => value._raw as string,\n deserialize: (value: string) => ({ _raw: value, ...JSON.parse(value) }),\n schema,\n});\n\nfunction setSettings(value: string): void {\n storeInstance.set(settingsKey, value);\n}\n\nfunction getSettings(): string {\n if (storeInstance.size < 2) {\n setSettings(JSON.stringify(defaultSettings, null, 2));\n }\n return storeInstance.get(settingsKey);\n}\n\nfunction deleteSettings(): void {\n storeInstance.delete(settingsKey);\n}\n\n/**\n * @since 0.18\n * @beta\n */\nfunction getConfigurations(): Configurations {\n return storeInstance.get(configurationKey) as Configurations;\n}\n\nexport { deleteSettings, getConfigurations, getSettings, setSettings };\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 { getConfigurations, getSettings, setSettings } from \"./storage\";\nimport { ipcMain } from \"electron\";\n\nfunction saveSettings(settings: string): void {\n setSettings(settings);\n}\n\nfunction loadSettings(): string {\n return getSettings();\n}\n\n/**\n * @since 0.18\n * @beta\n */\nfunction load(): void {\n ipcMain.handle(\n \"settings:save\",\n async (\n _event,\n {\n settings,\n }: {\n settings: string;\n },\n ): Promise<void> => {\n saveSettings(settings);\n },\n );\n\n ipcMain.handle(\"settings:load\", async (): Promise<string> => {\n return loadSettings();\n });\n}\n\nexport { getConfigurations, load };\n"],"names":["configurationKey","settingsKey","schema","storeInstance","Store","value","setSettings","getSettings","defaultSettings","getConfigurations","saveSettings","settings","loadSettings","load","ipcMain","_event"],"mappings":"8rCAwBMA,EAAmB,gBACnBC,EAAc,OAEdC,EAAS,CACb,KAAM,CACJ,KAAM,QAAA,EAER,cAAe,CACb,KAAM,QAAA,CAEV,EAOMC,EAAkC,IAAIC,EAAiB,CAC3D,KAAM,WAKN,UAAYC,GAAmCA,EAAM,KACrD,YAAcA,IAAmB,CAAE,KAAMA,EAAO,GAAG,KAAK,MAAMA,CAAK,IACnE,OAAAH,CACF,CAAC,EAED,SAASI,EAAYD,EAAqB,CACxCF,EAAc,IAAIF,EAAaI,CAAK,CACtC,CAEA,SAASE,GAAsB,CAC7B,OAAIJ,EAAc,KAAO,GACvBG,EAAY,KAAK,UAAUE,EAAiB,KAAM,CAAC,CAAC,EAE/CL,EAAc,IAAIF,CAAW,CACtC,CAUA,SAASQ,GAAoC,CAC3C,OAAON,EAAc,IAAIH,CAAgB,CAC3C,CClDA,SAASU,EAAaC,EAAwB,CAC5CL,EAAYK,CAAQ,CACtB,CAEA,SAASC,GAAuB,CAC9B,OAAOL,EAAA,CACT,CAMA,SAASM,GAAa,CACpBC,EAAAA,QAAQ,OACN,gBACA,MACEC,EACA,CACE,SAAAJ,CAAA,IAIgB,CAClBD,EAAaC,CAAQ,CACvB,CAAA,EAGFG,UAAQ,OAAO,gBAAiB,SACvBF,EAAA,CACR,CACH"}
|
package/dist/storage.d.ts
CHANGED
|
@@ -2,5 +2,9 @@ import { Configurations } from '@xwiki/cristal-configuration-api';
|
|
|
2
2
|
declare function setSettings(value: string): void;
|
|
3
3
|
declare function getSettings(): string;
|
|
4
4
|
declare function deleteSettings(): void;
|
|
5
|
+
/**
|
|
6
|
+
* @since 0.18
|
|
7
|
+
* @beta
|
|
8
|
+
*/
|
|
5
9
|
declare function getConfigurations(): Configurations;
|
|
6
10
|
export { deleteSettings, getConfigurations, getSettings, setSettings };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
## API Report File for "@xwiki/cristal-electron-settings-main"
|
|
2
|
+
|
|
3
|
+
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
|
|
7
|
+
import { Configurations } from '@xwiki/cristal-configuration-api';
|
|
8
|
+
|
|
9
|
+
// @beta (undocumented)
|
|
10
|
+
export function getConfigurations(): Configurations;
|
|
11
|
+
|
|
12
|
+
// @beta (undocumented)
|
|
13
|
+
export function load(): void;
|
|
14
|
+
|
|
15
|
+
// (No @packageDocumentation comment for this package)
|
|
16
|
+
|
|
17
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xwiki/cristal-electron-settings-main",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"license": "LGPL 2.1",
|
|
5
5
|
"author": "XWiki Org Community <contact@xwiki.org>",
|
|
6
6
|
"homepage": "https://cristal.xwiki.org/",
|
|
@@ -26,24 +26,26 @@
|
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
"main": "./dist/index.es.js",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
29
30
|
"dependencies": {
|
|
30
31
|
"electron-store": "10.1.0",
|
|
31
|
-
"@xwiki/cristal-configuration-api": "0.
|
|
32
|
-
"@xwiki/cristal-settings-api": "0.
|
|
32
|
+
"@xwiki/cristal-configuration-api": "0.22.0",
|
|
33
|
+
"@xwiki/cristal-settings-api": "0.22.0"
|
|
33
34
|
},
|
|
34
35
|
"peerDependencies": {
|
|
35
|
-
"electron": "37.
|
|
36
|
+
"electron": "37.4.0"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
39
|
"typescript": "5.9.2",
|
|
39
|
-
"vite": "7.
|
|
40
|
-
"@xwiki/cristal-dev-config": "0.
|
|
40
|
+
"vite": "7.1.5",
|
|
41
|
+
"@xwiki/cristal-dev-config": "0.22.0"
|
|
41
42
|
},
|
|
42
43
|
"scripts": {
|
|
43
|
-
"
|
|
44
|
+
"api-extractor:local": "api-extractor run --local",
|
|
45
|
+
"build": "vite build",
|
|
44
46
|
"clean": "rimraf dist",
|
|
45
47
|
"lint": "eslint \"./src/**/*.{ts,tsx,vue}\" --max-warnings=0",
|
|
46
|
-
"test": "vitest --run"
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
"test": "vitest --run",
|
|
49
|
+
"typecheck": "tsc"
|
|
50
|
+
}
|
|
49
51
|
}
|
package/src/index.ts
CHANGED
package/src/storage.ts
CHANGED
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
import defaultSettings from "./defaultSettings.json";
|
|
22
|
-
import { Configurations } from "@xwiki/cristal-configuration-api";
|
|
23
22
|
import Store from "electron-store";
|
|
23
|
+
import type { Configurations } from "@xwiki/cristal-configuration-api";
|
|
24
24
|
|
|
25
25
|
const configurationKey = "configuration";
|
|
26
26
|
const settingsKey = "_raw";
|
|
@@ -34,7 +34,12 @@ const schema = {
|
|
|
34
34
|
},
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
type StoreType = {
|
|
38
|
+
_raw: string;
|
|
39
|
+
configuration: object;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const storeInstance: Store<StoreType> = new Store<StoreType>({
|
|
38
43
|
name: "settings",
|
|
39
44
|
// Here, we want to keep in the store the raw string representation of the
|
|
40
45
|
// file, since it should be parsed and serialized by the SettingsManager
|
|
@@ -45,39 +50,27 @@ const storeInstance: Store = new Store({
|
|
|
45
50
|
schema,
|
|
46
51
|
});
|
|
47
52
|
|
|
48
|
-
function set<T>(key: string, value: T) {
|
|
49
|
-
// @ts-expect-error type resolution failing because of electron-store library bug
|
|
50
|
-
storeInstance.set(key, value);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function get<T>(key: string): T {
|
|
54
|
-
// @ts-expect-error type resolution failing because of electron-store library bug
|
|
55
|
-
return storeInstance.get(key) as T;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function rm(key: string) {
|
|
59
|
-
// @ts-expect-error type resolution failing because of electron-store library bug
|
|
60
|
-
storeInstance.delete(key);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
53
|
function setSettings(value: string): void {
|
|
64
|
-
set(settingsKey, value);
|
|
54
|
+
storeInstance.set(settingsKey, value);
|
|
65
55
|
}
|
|
66
56
|
|
|
67
57
|
function getSettings(): string {
|
|
68
|
-
// @ts-expect-error type resolution failing because of electron-store library bug
|
|
69
58
|
if (storeInstance.size < 2) {
|
|
70
59
|
setSettings(JSON.stringify(defaultSettings, null, 2));
|
|
71
60
|
}
|
|
72
|
-
return get(settingsKey);
|
|
61
|
+
return storeInstance.get(settingsKey);
|
|
73
62
|
}
|
|
74
63
|
|
|
75
64
|
function deleteSettings(): void {
|
|
76
|
-
|
|
65
|
+
storeInstance.delete(settingsKey);
|
|
77
66
|
}
|
|
78
67
|
|
|
68
|
+
/**
|
|
69
|
+
* @since 0.18
|
|
70
|
+
* @beta
|
|
71
|
+
*/
|
|
79
72
|
function getConfigurations(): Configurations {
|
|
80
|
-
return get(configurationKey);
|
|
73
|
+
return storeInstance.get(configurationKey) as Configurations;
|
|
81
74
|
}
|
|
82
75
|
|
|
83
76
|
export { deleteSettings, getConfigurations, getSettings, setSettings };
|
package/tsdoc.json
ADDED
package/vitest.config.ts
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
import localConfig from "./vite.config";
|
|
22
|
+
import { vitestVue as defaultConfig } from "@xwiki/cristal-dev-config";
|
|
22
23
|
import { mergeConfig } from "vitest/config";
|
|
23
|
-
import defaultConfig from "@xwiki/cristal-dev-config/vitest-vue.config";
|
|
24
24
|
|
|
25
25
|
export default mergeConfig(defaultConfig, localConfig);
|