Skip to content

Commit 7892567

Browse files
committed
add rpc command #69
1 parent 36577b9 commit 7892567

File tree

6 files changed

+37
-18
lines changed

6 files changed

+37
-18
lines changed

parser.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/codemirror.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"let", "not", "or", "post", "return", "sleep", "then", "true", "while",
3535
"throw", "lambda", "do", "continue", "break", "store", "config", "parse",
3636
"type", "ask*", "echo*", "input*", "update", "clear", "mask", "import",
37-
"prompt"
37+
"prompt", "rpc"
3838
], keywords = wordRE(keywordList);
3939

4040
var indentTokens = wordRE(["def", "then", "lambda", "do", "\\(", "{"]);

src/grammar.peg

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@
236236
obj.type === 'Literal' &&
237237
typeof obj.value === 'number';
238238
}
239-
var async_commands = ["ask", "get", "post", "sleep", "echo*", "prompt*", "input*", "ask*", "post*"];
239+
var async_commands = ["ask", "get", "post", "sleep", "echo*", "prompt*", "input*", "ask*", "post*", "rpc"];
240240
var sync_commands = ["echo", "type", "prompt", "config", "input", "parse*", "parse", "store", "complete", "update", "clear", "mask"];
241241
var available_commands = async_commands.concat(sync_commands);
242242
var extra_single = ["sleep*", "get*"];

src/prefix.js

+19
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,25 @@ const Gaiman = {
116116
set_cookie(name, value) {
117117
document.cookie = `${name}=${value}`;
118118
cookie[name] = value;
119+
},
120+
async rpc(url) {
121+
// TODO: add Open-RPC
122+
return new Proxy({}, {
123+
get(target, name) {
124+
if (name in target) {
125+
return target[name];
126+
}
127+
if (name === 'then') {
128+
return undefined;
129+
}
130+
return (...args) => {
131+
return $.rpc(url, name, args);
132+
};
133+
},
134+
set() {
135+
throw new Error("You can't set properties on rpc object");
136+
}
137+
});
119138
}
120139
};
121140

umd.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Copyright (C) 2021 Jakub T. Jankiewicz <https://jcubic.pl/me>
99
*
1010
* Released under GNU GPL v3 or later
11-
* Buid time: Wed, 08 Jun 2022 11:47:06 GMT
11+
* Buid time: Wed, 08 Jun 2022 14:28:42 GMT
1212
*/
1313
(function (global, factory) {
1414
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -209,7 +209,7 @@
209209
};
210210
return new_loc;
211211
}
212-
var async_commands = ["ask", "get", "post", "sleep", "echo*", "prompt*", "input*", "ask*", "post*"];
212+
var async_commands = ["ask", "get", "post", "sleep", "echo*", "prompt*", "input*", "ask*", "post*", "rpc"];
213213
var sync_commands = ["echo", "type", "prompt", "config", "input", "parse*", "parse", "store", "complete", "update", "clear", "mask"];
214214
var available_commands = async_commands.concat(sync_commands);
215215
var extra_single = ["sleep*", "get*"];
@@ -11158,7 +11158,7 @@
1115811158
var _args = [
1115911159
[
1116011160
11161-
"/home/kuba/projects/jcubic/gaiman"
11161+
"/home/users/jankiewj/projects/jcubic/gaiman"
1116211162
]
1116311163
];
1116411164
var _from = "[email protected]";
@@ -11184,7 +11184,7 @@
1118411184
];
1118511185
var _resolved = "https://registry.npmjs.org/escodegen/-/escodegen-2.0.0.tgz";
1118611186
var _spec = "2.0.0";
11187-
var _where = "/home/kuba/projects/jcubic/gaiman";
11187+
var _where = "/home/users/jankiewj/projects/jcubic/gaiman";
1118811188
var bin$1 = {
1118911189
esgenerate: "bin/esgenerate.js",
1119011190
escodegen: "bin/escodegen.js"
@@ -13990,7 +13990,7 @@
1399013990
* \____/\__,_/_/_/ /_/ /_/\__,_/_/ /_/
1399113991
*
1399213992
* Storytelling Text Based Game Engine
13993-
* Copyrigth (C) 2021 Jakub T. Jankiewicz <https://jcubic.pl/me>
13993+
* Copyrigth (C) 2021-2022 Jakub T. Jankiewicz <https://jcubic.pl/me>
1399413994
*
1399513995
* Released under GNU GPL v3 or later
1399613996
*/

umd.min.js

+10-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)