Commit dc8cdc0c authored by Jérome Perrin's avatar Jérome Perrin

monaco_editor: Add incomplete typescript declarations for Renderjs & RSVP

So that javascript editor provides hints for code using these libraries.

See this doc to complete:
https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html
parent 918859d4
......@@ -65,6 +65,7 @@
})
.onStateChange(function (modification_dict) {
var queue = new RSVP.Queue();
if (modification_dict.hasOwnProperty('value')) {
// Do not notify the UI when initializing the value
this.state.ignoredChangeDuringInitialization = true;
......@@ -72,7 +73,25 @@
this.state.ignoredChangeDuringInitialization = false;
}
if (modification_dict.hasOwnProperty('model_language')) {
monaco.editor.setModelLanguage(this.editor.getModel(), this.state.model_language);
monaco.editor.setModelLanguage(
this.editor.getModel(),
this.state.model_language);
if (this.state.model_language == 'javascript') {
function addExtraLibrary(script_name) {
return fetch(script_name)
.then(function (resp) { return resp.text(); })
.then(function (script_code) {
monaco.languages.typescript.javascriptDefaults.addExtraLib(
script_code, script_name);
});
}
queue
.push(addExtraLibrary("./monaco-renderjs.ts"))
.push(addExtraLibrary("./monaco-rsvp.ts"));
}
return queue;
}
})
......
// Type definitions for RenderJS
// XXX this is work in progress.
declare class Gadget {
/**
* RenderJs gadget class.
*/
constructor();
/**
* `ready`: define a function to be called when gadget is ready
* XXX (gadget: Gadget) ? isn't it a gadget *instance* ?
*
* @params f function to call when gadget is ready. XXX this function returns a queue and gadget is ready once the queue is "empty" / "resolved" ?
*/
ready(f: (gadget: Gadget) => RSVP.Queue): Gadget;
/**
* `declareService`: declare a service.
*
* @params serviceName name of the service
* @params service function implementing the service logic.
*/
declareService(serviceName: String, service: (gadget: Gadget) => RSVP.Queue): Gadget;
declareJob(serviceName: String, service: (gadget: Gadget) => RSVP.Queue): Gadget;
declareMethod(methodName: String, method: (gadget: Gadget) => RSVP.Queue): Gadget;
declareAcquiredMethod(localMethodName: String, parentMethodName: String): Gadget;
}
/**
* Initialize this gadget.
*/
declare function rJS(window: Window): Gadget;
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>monaco-renderjs.ts</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/typescript</string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>monaco-rsvp.ts</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/typescript</string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment