@basthon/gui-base 0.36.7 → 0.37.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/lib/main.d.ts CHANGED
@@ -16,7 +16,8 @@ export declare class GUIBase {
16
16
  /**
17
17
  * Kernel getter.
18
18
  */
19
- get kernel(): KernelBase | null;
19
+ get kernel(): KernelBase | undefined;
20
+ get kernelSafe(): KernelBase | null;
20
21
  /**
21
22
  * KernelLoader getter.
22
23
  */
@@ -40,10 +41,10 @@ export declare class GUIBase {
40
41
  /**
41
42
  * Ask the user to select a choice.
42
43
  */
43
- select(title: string, message: string, textCancel: string, choices: {
44
+ select(title: string, message: string, choices: {
44
45
  text: string;
45
46
  handler: () => void;
46
- }[]): void;
47
+ }[], textCancel: string, callbackCancel: (() => void)): void;
47
48
  /**
48
49
  * The error notification system.
49
50
  */
@@ -59,6 +60,10 @@ export declare class GUIBase {
59
60
  * init process, trying to do our best...
60
61
  */
61
62
  initCaller(func: () => Promise<any>, message: string, catchError: boolean): Promise<any>;
63
+ /**
64
+ * Get mode as a string (dark/light).
65
+ */
66
+ theme(): "dark" | "light" | undefined;
62
67
  /**
63
68
  * Restart the kernel.
64
69
  */
@@ -91,7 +96,7 @@ export declare class GUIBase {
91
96
  /**
92
97
  * Open an URL in a new tab or download a file.
93
98
  */
94
- static openURL(url: string, download?: string | null | undefined): void;
99
+ static openURL(url: string, download?: string): void;
95
100
  /**
96
101
  * Share content via URL.
97
102
  */
package/lib/main.js CHANGED
@@ -22,6 +22,7 @@ export class GUIBase {
22
22
  * Kernel getter.
23
23
  */
24
24
  get kernel() { return this._loader.kernel; }
25
+ get kernelSafe() { return this._loader.kernelSafe; }
25
26
  /**
26
27
  * KernelLoader getter.
27
28
  */
@@ -45,7 +46,7 @@ export class GUIBase {
45
46
  /**
46
47
  * Ask the user to select a choice.
47
48
  */
48
- select(title, message, textCancel, choices) { }
49
+ select(title, message, choices, textCancel, callbackCancel) { }
49
50
  /**
50
51
  * The error notification system.
51
52
  */
@@ -100,10 +101,14 @@ export class GUIBase {
100
101
  this.notifyError(error);
101
102
  }
102
103
  }
104
+ /**
105
+ * Get mode as a string (dark/light).
106
+ */
107
+ theme() { return; }
103
108
  /**
104
109
  * Restart the kernel.
105
110
  */
106
- kernelRestart() { var _a; (_a = this.kernel) === null || _a === void 0 ? void 0 : _a.restart(); }
111
+ kernelRestart() { var _a; (_a = this.kernelSafe) === null || _a === void 0 ? void 0 : _a.restart(); }
107
112
  /**
108
113
  * Load ressources from URL (common part to files and modules).
109
114
  */
@@ -136,9 +141,9 @@ export class GUIBase {
136
141
  const reader = new FileReader();
137
142
  reader.readAsArrayBuffer(file);
138
143
  reader.onload = async (event) => {
139
- var _a, _b;
140
- (_a = this.kernel) === null || _a === void 0 ? void 0 : _a.putRessource(file.name, reader.result);
141
- this.info("Fichier utilisable depuis ${this.kernel?.languageName()", `${file.name} est maintenant utilisable depuis ${(_b = this.kernel) === null || _b === void 0 ? void 0 : _b.languageName()}`);
144
+ var _a, _b, _c;
145
+ (_a = this.kernelSafe) === null || _a === void 0 ? void 0 : _a.putRessource(file.name, reader.result);
146
+ this.info(`Fichier utilisable depuis ${(_b = this.kernel) === null || _b === void 0 ? void 0 : _b.languageName()}`, `${file.name} est maintenant utilisable depuis ${(_c = this.kernel) === null || _c === void 0 ? void 0 : _c.languageName()}`);
142
147
  resolve();
143
148
  };
144
149
  reader.onerror = reject;
@@ -148,17 +153,17 @@ export class GUIBase {
148
153
  * Load auxiliary files submited via URL (aux= parameter) (async).
149
154
  */
150
155
  async loadURLAux() {
151
- if (this.kernel == null)
156
+ if (this.kernelSafe == null)
152
157
  return;
153
- await this._loadFromURL('aux', this.kernel.putFile.bind(this.kernel));
158
+ await this._loadFromURL('aux', this.kernelSafe.putFile.bind(this.kernelSafe));
154
159
  }
155
160
  /**
156
161
  * Load modules submited via URL (module= parameter) (async).
157
162
  */
158
163
  async loadURLModules() {
159
- if (this.kernel == null)
164
+ if (this.kernelSafe == null)
160
165
  return;
161
- await this._loadFromURL('module', this.kernel.putModule.bind(this.kernel));
166
+ await this._loadFromURL('module', this.kernelSafe.putModule.bind(this.kernelSafe));
162
167
  }
163
168
  /**
164
169
  * Opening file: If it has ext as extension, loading it in
@@ -195,7 +200,7 @@ export class GUIBase {
195
200
  /**
196
201
  * Open an URL in a new tab or download a file.
197
202
  */
198
- static openURL(url, download = null) {
203
+ static openURL(url, download) {
199
204
  let anchor = document.createElement("a");
200
205
  if (download != null)
201
206
  anchor.download = download;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@basthon/gui-base",
3
- "version": "0.36.7",
3
+ "version": "0.37.0",
4
4
  "description": "Basthon - Base GUI",
5
5
  "homepage": "https://basthon.fr",
6
6
  "bugs": {
@@ -25,8 +25,8 @@
25
25
  "clean": "rm -rf lib/"
26
26
  },
27
27
  "dependencies": {
28
- "@basthon/kernel-base": "^0.36.7",
29
- "@basthon/kernel-loader": "^0.36.7",
28
+ "@basthon/kernel-base": "^0.37.0",
29
+ "@basthon/kernel-loader": "^0.37.0",
30
30
  "js-base64": "^3.7.2",
31
31
  "pako": "^2.0.4",
32
32
  "promise-delegate": "^1.0.1"
@@ -40,5 +40,5 @@
40
40
  "publishConfig": {
41
41
  "access": "public"
42
42
  },
43
- "gitHead": "ac135f7d63e88c0830dbf557f70d2912bc3fd488"
43
+ "gitHead": "bdafd1d07f6280d24e7b879d035c342c8fe7d61e"
44
44
  }