@gramlot/gramlot 0.2.9 → 0.2.11
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/dist/gramlot.js +207 -165
- package/package.json +1 -1
- package/src/binding/inline.js +1 -1
- package/src/binding/runtime.js +3 -3
- package/src/bootstrap.js +1 -1
- package/src/builder/source.js +1 -1
- package/src/dom.d.ts +6 -0
- package/src/gramlot.d.ts +20 -49
- package/src/gramlot.js +21 -119
- package/src/handlers/dom-handler.d.ts +19 -0
- package/src/handlers/dom-handler.js +16 -0
- package/src/handlers/handler.d.ts +14 -0
- package/src/handlers/handler.js +13 -0
- package/src/handlers/rpc-handler.d.ts +21 -0
- package/src/handlers/rpc-handler.js +18 -0
- package/src/handlers/source-handler.d.ts +47 -0
- package/src/handlers/source-handler.js +114 -0
- package/src/handlers/utilities-handler.d.ts +17 -0
- package/src/handlers/utilities-handler.js +16 -0
- package/src/index.d.ts +7 -2
- package/src/index.js +6 -1
- package/src/inout.d.ts +2 -2
- package/src/inout.js +7 -7
package/src/inout.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* @ts-self-types="./inout.d.ts" */
|
|
2
2
|
/**
|
|
3
|
-
* What the page sends, receives, saves and downloads (`gramlot.inout`).
|
|
3
|
+
* What the page sends, receives, saves and downloads (`gramlot.utl.inout`).
|
|
4
4
|
*
|
|
5
5
|
* @module
|
|
6
6
|
*/
|
|
@@ -17,7 +17,7 @@ function leafText(value) {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
* What the page sends, receives, saves and downloads: `gramlot.inout` (decisions of 2026-10-03).
|
|
20
|
+
* What the page sends, receives, saves and downloads: `gramlot.utl.inout` (decisions of 2026-10-03).
|
|
21
21
|
* Every function takes the Data path of a Bag branch; a missing path or a value that is not a Bag
|
|
22
22
|
* raises an Error. Part of the browser runtime, so Python and JavaScript pages use it alike, from
|
|
23
23
|
* inline code or from their Logic.
|
|
@@ -31,7 +31,7 @@ export class InOut {
|
|
|
31
31
|
/** The Bag at path in the Data. */
|
|
32
32
|
branch(path) {
|
|
33
33
|
const value = this.gramlot.data.getItem(path);
|
|
34
|
-
if (!(value instanceof Bag)) throw new Error(`gramlot.inout: no data Bag at '${path}'`);
|
|
34
|
+
if (!(value instanceof Bag)) throw new Error(`gramlot.utl.inout: no data Bag at '${path}'`);
|
|
35
35
|
return value;
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -54,7 +54,7 @@ export class InOut {
|
|
|
54
54
|
const url = `mailto:${encodeURIComponent(email)}?subject=${encodeURIComponent(this.document.title)}` +
|
|
55
55
|
`&body=${encodeURIComponent(this.mailText(path))}`;
|
|
56
56
|
if (url.length > MAILTO_LIMIT) {
|
|
57
|
-
throw new Error(`gramlot.inout.sendMail: the email of '${path}' is ${url.length} characters long, ` +
|
|
57
|
+
throw new Error(`gramlot.utl.inout.sendMail: the email of '${path}' is ${url.length} characters long, ` +
|
|
58
58
|
`over the mailto: limit of ${MAILTO_LIMIT}; send it with sendHttp or save it as a file`);
|
|
59
59
|
}
|
|
60
60
|
return url;
|
|
@@ -71,7 +71,7 @@ export class InOut {
|
|
|
71
71
|
const response = await this.document.defaultView.fetch(url, {
|
|
72
72
|
method: 'POST', headers: {'Content-Type': 'application/json'}, body,
|
|
73
73
|
});
|
|
74
|
-
if (!response.ok) throw new Error(`gramlot.inout.sendHttp: ${url} answered ${response.status}`);
|
|
74
|
+
if (!response.ok) throw new Error(`gramlot.utl.inout.sendHttp: ${url} answered ${response.status}`);
|
|
75
75
|
return response;
|
|
76
76
|
}
|
|
77
77
|
|
|
@@ -92,7 +92,7 @@ export class InOut {
|
|
|
92
92
|
this.gramlot.data.setItem(path, bag);
|
|
93
93
|
resolve(bag);
|
|
94
94
|
} catch (error) {
|
|
95
|
-
reject(new Error(`gramlot.inout.restore: the file is not a saved Gramlot branch: ${error.message}`,
|
|
95
|
+
reject(new Error(`gramlot.utl.inout.restore: the file is not a saved Gramlot branch: ${error.message}`,
|
|
96
96
|
{cause: error}));
|
|
97
97
|
}
|
|
98
98
|
}, {once: true});
|
|
@@ -104,7 +104,7 @@ export class InOut {
|
|
|
104
104
|
* after the last segment of path); types become text. */
|
|
105
105
|
download(path, filename, format) {
|
|
106
106
|
if (!['json', 'xml'].includes(format)) {
|
|
107
|
-
throw new Error(`gramlot.inout.download: format '${format}' is not 'json' or 'xml'`);
|
|
107
|
+
throw new Error(`gramlot.utl.inout.download: format '${format}' is not 'json' or 'xml'`);
|
|
108
108
|
}
|
|
109
109
|
const bag = this.branch(path);
|
|
110
110
|
if (format === 'json') {
|