@basthon/gui-base 0.50.5 → 0.50.7
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/lib/main.d.ts +10 -1
- package/lib/main.js +18 -1
- package/package.json +5 -5
package/lib/main.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CheckpointsManager } from "@basthon/checkpoints";
|
|
1
|
+
import { CheckpointsManager, Storage } from "@basthon/checkpoints";
|
|
2
2
|
import { KernelBase } from "@basthon/kernel-base";
|
|
3
3
|
import { KernelLoader } from "@basthon/kernel-loader";
|
|
4
4
|
declare global {
|
|
@@ -24,6 +24,7 @@ export declare class GUIBase {
|
|
|
24
24
|
protected _contentFilename: string;
|
|
25
25
|
protected _urlKey: string;
|
|
26
26
|
private _extensions;
|
|
27
|
+
protected _stateStorage: Storage<boolean>;
|
|
27
28
|
private _console_error;
|
|
28
29
|
constructor(options: GUIOptions);
|
|
29
30
|
/**
|
|
@@ -100,6 +101,14 @@ export declare class GUIBase {
|
|
|
100
101
|
* Setup the UI (typically connect events, load extensions etc..).
|
|
101
102
|
*/
|
|
102
103
|
protected setupUI(options: any): Promise<void>;
|
|
104
|
+
/**
|
|
105
|
+
* Get state from strorage.
|
|
106
|
+
*/
|
|
107
|
+
protected getState(state: string, def?: undefined): Promise<any>;
|
|
108
|
+
/**
|
|
109
|
+
* Set state in storage.
|
|
110
|
+
*/
|
|
111
|
+
protected setState(state: string, value: any): Promise<void>;
|
|
103
112
|
/**
|
|
104
113
|
* Load content at startup.
|
|
105
114
|
*/
|
package/lib/main.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PromiseDelegate } from "promise-delegate";
|
|
2
|
-
import { CheckpointsManager } from "@basthon/checkpoints";
|
|
2
|
+
import { CheckpointsManager, Storage } from "@basthon/checkpoints";
|
|
3
3
|
import { KernelLoader } from "@basthon/kernel-loader";
|
|
4
4
|
/**
|
|
5
5
|
* Base class for console and notebook GUI.
|
|
@@ -20,6 +20,8 @@ export class GUIBase {
|
|
|
20
20
|
/* per language checkpoints */
|
|
21
21
|
if (!options.noCheckpointsInit)
|
|
22
22
|
this._checkpoints = new CheckpointsManager(`${options.uiName}.${options.language}`, this._maxCheckpoints);
|
|
23
|
+
/* globale states (not language specific) */
|
|
24
|
+
this._stateStorage = new Storage(`${options.uiName}.states`);
|
|
23
25
|
}
|
|
24
26
|
/**
|
|
25
27
|
* Language getter.
|
|
@@ -182,6 +184,21 @@ export class GUIBase {
|
|
|
182
184
|
kernel.addEventListener("eval.error", () => {
|
|
183
185
|
this.validateBackup();
|
|
184
186
|
});
|
|
187
|
+
/* instanciate the storage */
|
|
188
|
+
await this._stateStorage.ready();
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Get state from strorage.
|
|
192
|
+
*/
|
|
193
|
+
async getState(state, def = undefined) {
|
|
194
|
+
var _a;
|
|
195
|
+
return (_a = await this._stateStorage.get(state)) !== null && _a !== void 0 ? _a : def;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Set state in storage.
|
|
199
|
+
*/
|
|
200
|
+
async setState(state, value) {
|
|
201
|
+
await this._stateStorage.set(state, value);
|
|
185
202
|
}
|
|
186
203
|
/**
|
|
187
204
|
* Load content at startup.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basthon/gui-base",
|
|
3
|
-
"version": "0.50.
|
|
3
|
+
"version": "0.50.7",
|
|
4
4
|
"description": "Basthon - Base GUI",
|
|
5
5
|
"homepage": "https://basthon.fr",
|
|
6
6
|
"bugs": {
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"clean": "rm -rf lib/"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@basthon/checkpoints": "0.50.
|
|
29
|
-
"@basthon/kernel-base": "0.50.
|
|
30
|
-
"@basthon/kernel-loader": "0.50.
|
|
28
|
+
"@basthon/checkpoints": "0.50.7",
|
|
29
|
+
"@basthon/kernel-base": "0.50.7",
|
|
30
|
+
"@basthon/kernel-loader": "0.50.7",
|
|
31
31
|
"js-base64": "^3.7.2",
|
|
32
32
|
"pako": "^2.0.4",
|
|
33
33
|
"promise-delegate": "^1.0.1"
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "b973c8727a592f8db22827c3da65fad52133ddd0"
|
|
45
45
|
}
|