Merge branch 'master' of github.com:Microsoft/TouchDevelop

This commit is contained in:
Michal Moskal 2015-03-30 19:00:13 -07:00
Родитель 5b16308e7e 48bde399e4
Коммит 83b93340d7
10 изменённых файлов: 155 добавлений и 67 удалений

Просмотреть файл

@ -117,7 +117,7 @@ function mkSimpleTask(production, dependencies, target) {
function mdkTask(production, dependencies, target) {
return file(production, expand(dependencies), { async: true, parallelLimit: branchingFactor }, function () {
var task = this;
jake.mkdirP('build/portal')
jake.mkdirP('build/portal')
console.log("[M] "+production);
jake.exec("node node_modules/madoko/lib/cli.js --verbose --odir=build/portal " + target, { printStdout: true }, function () {
task.complete();
@ -391,9 +391,9 @@ task('default', [
desc('clean up the build folders and files')
task('clean', [], function () {
// XXX do this in a single call? check out https://github.com/mde/utilities/blob/master/lib/file.js
generated.forEach(function (f) { jake.rmRf(f); });
jake.rmRf('build/');
// XXX do this in a single call? check out https://github.com/mde/utilities/blob/master/lib/file.js
generated.forEach(function (f) { jake.rmRf(f); });
jake.rmRf('build/');
});
desc('run local test suite')
@ -407,7 +407,7 @@ task('test', [ 'build/client.js', 'default', 'nw-build' ], { async: true }, func
// this task runs as a "after_success" step in the travis-ci automation
desc('upload current build to the cloud')
task('upload', [], { async : true }, function() {
task('upload', [ "build/client.js" ], { async : true }, function() {
var task = this;
var upload = function (buildVersion) {
var uploadKey = process.env.TD_UPLOAD_KEY || "direct";
@ -472,10 +472,10 @@ task('azure', [ 'build/shell.js' ], { async: true }, function() {
child_process.execFile(
"C:/Program Files/Microsoft SDKs/Azure/.NET SDK/v2.5/bin/cspack.exe",
[ "tdshell.csdef",
"/out:../../build/azure/tdshell.cspkg",
"/out:../../build/azure/tdshell.cspkg",
"/roleFiles:ShellRole;files.txt" ], { cwd: 'shell/azure' }, execCallback(this))
});
task('nw-npm', {async : true }, function() {
var task = this;
jake.mkdirP('build/nw');

Просмотреть файл

@ -460,7 +460,7 @@ module TDev
if (mx && mx[1] != "0") {
Cloud.lite = true;
(<any>window).rootUrl = mx[1].length > 2 ? "http://" + mx[1] + ".cloudapp.net" : "https://tdscratch.azurewebsites.net"
(<any>window).rootUrl = mx[1].length > 2 ? "http://" + mx[1] + ".cloudapp.net" : "https://mbitmain.azurewebsites.net"
TDev.Ticker.disable()
}

Просмотреть файл

@ -13,23 +13,35 @@ module TDev {
path: string;
}
export var externalEditors: ExternalEditor[] = [ {
name: "C++ Editor",
description: "Directly write C++ code using Ace",
id: "ace",
origin: "http://localhost:4242",
path: "/editor/local/ace/editor.html"
}, {
name: "Blockly editor",
description: "Great block-based environment!",
id: "blockly",
origin: "http://localhost:4242",
path: "/editor/local/blockly/editor.html"
} ];
var externalEditorsCache: ExternalEditor[] = null;
export function getExternalEditors(): ExternalEditor[] {
if (!externalEditorsCache) {
// Detect at run-time where we're running from!
var url = Ticker.mainJsName.replace(/main.js$/, "");
var match = url.match(/(https?:\/\/[^\/]+)(.*)/);
var origin = match[1];
var path = match[2];
externalEditorsCache = [ {
name: "C++ Editor",
description: "Directly write C++ code using Ace (OUTDATED)",
id: "ace",
origin: origin,
path: path+"ace/editor.html"
}, {
name: "Blockly editor",
description: "Great block-based environment!",
id: "blockly",
origin: origin,
path: path+"blockly/editor.html"
} ];
}
return externalEditorsCache;
}
// Assumes that [id] is a valid external editor id.
export function editorById(id: string): ExternalEditor {
var r = externalEditors.filter(x => x.id == id);
var r = getExternalEditors().filter(x => x.id == id);
Util.assert(r.length == 1);
return r[0];
}
@ -55,8 +67,10 @@ module TDev {
public receive(event) {
console.log("[outer message]", event);
if (event.origin != this.editor.origin)
if (event.origin != this.editor.origin) {
console.error("[outer message] not from the right origin!", event.origin, this.editor.origin);
return;
}
switch ((<Message> event.data).type) {
case MessageType.Save: {
@ -140,6 +154,14 @@ module TDev {
TheChannel = null;
break;
case MessageType.Compile:
this.post(<Message_CompileAck>{
type: MessageType.CompileAck,
status: Status.Error,
error: "Not implemented"
});
break;
default:
console.error("[external] unexpected message type", message.type);
break;

Просмотреть файл

@ -1015,7 +1015,7 @@ module TDev.Browser {
m.onDismiss = () => onSuccess(undefined);
var elts = [];
externalEditors.concat([{
getExternalEditors().concat([{
name: "TouchDevelop",
description: "The touch editor you love and know!",
id: "touchdevelop",

Просмотреть файл

@ -4,39 +4,23 @@
module TDev {
export module External {
export interface SavedScript {
scriptText: string;
editorState: string;
baseSnapshot: string;
// The base class for messages. This is what gets sent via [postMessage].
// Discriminating on the actual value of the [type] field will tell you
// which one of the [Message_*] interfaces below you can cast into
// (TypeScript doesn't, quite regrettably, have sum types.)
export interface Message {
type: MessageType;
}
// The pending merge data, if any.
export interface PendingMerge {
base: SavedScript;
theirs: SavedScript;
}
// [Quit] has no attached data, so not defining a special interface
export enum MessageType {
Init,
Metadata, MetadataAck,
Save, SaveAck,
Compile, CompileAck,
Merge, Quit
Merge, Quit // [Quit] has no attached data, so not defining a special interface
};
export enum Status {
Ok, Error
};
export enum SaveLocation {
Local, Cloud
};
export interface Message {
type: MessageType;
}
export interface Message_Init extends Message {
type: MessageType; // == MessageType.Init
script: SavedScript;
@ -54,14 +38,56 @@ module TDev {
status: Status;
error?: string; // non-null iff status == Error
newBaseSnapshot?: string; // non-null iff status == Ok && where == Cloud
cloudIsInSync?: boolean; // same remark as above; furthermore, true if the version we just
// wrote in the cloud is the latest version currently stored
// locally
cloudIsInSync?: boolean; // non-null iff status == Ok && where == Cloud
// true means the version we just wrote in
// the cloud is the latest version
// currently stored locally
}
export interface Message_Merge extends Message {
type: MessageType; // == MessageType.Merge
merge: PendingMerge;
}
export interface Message_Compile extends Message {
type: MessageType; // == MessageType.Compile
text: string;
language: Language;
}
export interface Message_CompileAck extends Message {
type: MessageType; // == MessageType.Message_CompileAck
status: Status;
error?: string; // non-null iff status == Error
}
// A saved script has some text (this is what ends up published when the
// user hits "publish"), an associated editor state (doesn't get
// published), and is saved on top of a cloud-assigned [baseVersion].
export interface SavedScript {
scriptText: string;
editorState: string;
baseSnapshot: string;
}
// In case local and remote modifications have been posted on top of the same cloud
// version, the editor needs to merge, and can then save on top of the
// new cloud version.
export interface PendingMerge {
base: SavedScript;
theirs: SavedScript;
}
export enum Status {
Ok, Error
};
export enum SaveLocation {
Local, Cloud
};
export enum Language {
TouchDevelop, CPlusPlus
}
}
}

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -3482,8 +3482,24 @@ function tdupload(args:string[])
var td_tok = "?access_token=" + fs.readFileSync(atokF, "utf8").replace(/\s/g, "").replace(/^#access_token=/, "")
}
// Recursively enumerates in each entry that's a directory
var expand = function (fileList) {
return Array.prototype.concat.apply([],
fileList.map(f => {
if (!fs.existsSync(f))
return [];
else if (path.basename(f)[0] == ".")
return [];
else if (fs.statSync(f).isDirectory())
return expand(fs.readdirSync(f).map(x => f + "/" + x));
else
return [f];
})
)
};
if (args.length == 0)
args = [
args = expand([
"build/main.js",
"build/main.js.map",
"build/runtime.js",
@ -3492,17 +3508,14 @@ function tdupload(args:string[])
"build/noderunner.js",
"build/noderuntime.js",
"build/buildinfo.json",
"www/default.css",
"www/editor.css",
"www/index.html",
"www/browsers.html",
"www/app.manifest",
"webapp/webapp.html",
"www/error.html",
"www",
"build/touchdevelop.tgz",
"officemix/officemix.html",
"build/officemix.js",
]
"build/ace.js",
"build/blockly.js",
])
var liteId = ""
var uploadFiles = () => args.forEach(p => {
@ -3514,7 +3527,8 @@ function tdupload(args:string[])
return
}
var fileName = liteId == "upload" ? p : path.basename(p)
// Strip the leading directory name, unless we are uploading a single file.
var fileName = liteId == "upload" ? p : p.split("/").splice(1).join("/")
var mime = getMime(p)
if (liteUrl) {

Просмотреть файл

@ -11,7 +11,8 @@ module TDev {
var allowedOrigins = {
"http://localhost:4242": null,
"http://www.touchdevelop.com": null,
"https://www.touchdevelop.com": null,
"https://mbitmain.azurewebsites.net": null
};
// Both of these are written once when we receive the first (trusted)
@ -111,5 +112,8 @@ module TDev {
document.querySelector("#command-compile").addEventListener("click", () => {
post({ type: External.MessageType.Compile });
});
document.querySelector("#command-quit").addEventListener("click", () => {
post({ type: External.MessageType.Quit });
});
}
}

Просмотреть файл

@ -77,6 +77,7 @@
<ul id="commands">
<li><button id="command-save">save</button></li>
<li><button id="command-compile">compile</button></li>
<li><button id="command-quit">exit</button></li>
</ul>
</div>
<div class="hbox">

Просмотреть файл

@ -8,7 +8,8 @@ module TDev {
var allowedOrigins: { [index: string]: any } = {
"http://localhost:4242": null,
"http://www.touchdevelop.com": null,
"https://www.touchdevelop.com": null,
"https://mbitmain.azurewebsites.net": null
};
// Both of these are written once when we receive the first (trusted)
@ -21,8 +22,10 @@ module TDev {
var inMerge: boolean = false;
window.addEventListener("message", (event) => {
if (!(event.origin in allowedOrigins))
if (!(event.origin in allowedOrigins)) {
console.error("[inner message] not from the right origin!", event.origin);
return;
}
if (!outer || !origin) {
outer = event.source;
@ -49,6 +52,9 @@ module TDev {
case External.MessageType.Merge:
promptMerge((<External.Message_Merge> message).merge);
break;
case External.MessageType.CompileAck:
compileAck(<External.Message_CompileAck> message);
}
}
@ -88,6 +94,17 @@ module TDev {
}
}
function compileAck(message: External.Message_CompileAck) {
switch (message.status) {
case External.Status.Error:
statusMsg("compilation error: "+message.error, message.status);
break;
case External.Status.Ok:
statusMsg("compilation successful", message.status);
break;
}
}
function promptMerge(merge: External.PendingMerge) {
console.log("[merge] merge request, base = "+merge.base.baseSnapshot +
", theirs = "+merge.theirs.baseSnapshot +
@ -250,7 +267,11 @@ module TDev {
doSave();
});
document.querySelector("#command-compile").addEventListener("click", () => {
post({ type: External.MessageType.Compile });
post(<External.Message_Compile> {
type: External.MessageType.Compile,
text: "", // TODO
language: External.Language.TouchDevelop
});
});
document.querySelector("#command-run").addEventListener("click", () => {
});