From 6a882ca2e89be70c0deafd8efa8085d34b9fb3cd Mon Sep 17 00:00:00 2001
From: Rachel Fenichel
Date: Fri, 23 Sep 2016 18:19:16 -0700
Subject: [PATCH 01/12] disallow variables on shadow blocks
---
core/field_variable.js | 11 +++++++++++
core/xml.js | 3 +++
2 files changed, 14 insertions(+)
diff --git a/core/field_variable.js b/core/field_variable.js
index f93caa150..242cee9f0 100644
--- a/core/field_variable.js
+++ b/core/field_variable.js
@@ -29,6 +29,7 @@ goog.provide('Blockly.FieldVariable');
goog.require('Blockly.FieldDropdown');
goog.require('Blockly.Msg');
goog.require('Blockly.Variables');
+goog.require('goog.asserts');
goog.require('goog.string');
@@ -73,6 +74,16 @@ Blockly.FieldVariable.prototype.init = function() {
}
};
+/**
+ * Attach this field to a block.
+ * @param {!Blockly.Block} block The block containing this field.
+ */
+Blockly.FieldVariable.prototype.setSourceBlock = function(block) {
+ goog.asserts.assert(!block.isShadow(),
+ 'Variable fields are not allowed to exist on shadow blocks.');
+ Blockly.FieldVariable.superClass_.setSourceBlock.call(this, block);
+};
+
/**
* Get the variable's name (use a variableDB to convert into a real name).
* Unline a regular dropdown, variables are literal and have no neutral value.
diff --git a/core/xml.js b/core/xml.js
index 2567560cd..8ee0e24af 100644
--- a/core/xml.js
+++ b/core/xml.js
@@ -535,6 +535,9 @@ Blockly.Xml.domToBlockHeadless_ = function(xmlBlock, workspace) {
goog.asserts.assert(child.isShadow(),
'Shadow block not allowed non-shadow child.');
}
+ // Ensure this block doesn't have any variable inputs.
+ goog.asserts.assert(block.getVars().length == 0,
+ 'Shadow blocks cannot have variable fields.');
block.setShadow(true);
}
return block;
From f9385d98d3df192c009bc155eedc747ffbcb2193 Mon Sep 17 00:00:00 2001
From: Rachel Fenichel
Date: Wed, 2 Nov 2016 16:52:37 -0700
Subject: [PATCH 02/12] Add ability to define blocks with a json array
---
core/blockly.js | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/core/blockly.js b/core/blockly.js
index 3d33d8e8c..9fa5966cb 100644
--- a/core/blockly.js
+++ b/core/blockly.js
@@ -399,6 +399,33 @@ Blockly.prompt = function(message, defaultValue, callback) {
callback(window.prompt(message, defaultValue));
};
+/**
+ * Helper function for defining a block from json. The resulting function has
+ * the correct value of jsonDef at the point in code where jsonInit is called.
+ * @param {Object} jsonDef The JSON definition of a block.
+ * @return {function} A function that calls jsonInit with the correct value
+ * of jsonDef.
+ */
+Blockly.jsonInitFactory_ = function(jsonDef) {
+ return function() {
+ this.jsonInit(jsonDef);
+ };
+};
+
+/**
+ * Define blocks from an array of JSON block definitions, as might be generated
+ * by the Blockly Developer Tools.
+ * @param {!Array
-
+
From b5822e29250f0d5a1e7e91c57d14d8b0611e84fc Mon Sep 17 00:00:00 2001
From: Rachel Fenichel
Date: Fri, 11 Nov 2016 17:05:13 -0800
Subject: [PATCH 08/12] Revert "Revert "Rebuild nov 3 16""
This reverts commit c8ca24a0007b70e137417e843459c87185141a55.
---
blockly_compressed.js | 326 ++++++++++--------
blockly_uncompressed.js | 2 +-
blocks/logic.js | 36 ++
blocks/loops.js | 9 +
blocks/procedures.js | 9 +
blocks_compressed.js | 19 +-
core/block_svg.js | 46 +--
core/blockly.js | 25 +-
core/contextmenu.js | 4 +
core/css.js | 16 +
core/field.js | 5 +-
core/field_angle.js | 2 +-
core/field_dropdown.js | 39 ++-
core/field_textinput.js | 13 +-
core/field_variable.js | 69 ++--
core/flyout.js | 79 ++---
core/flyout_button.js | 73 +++-
core/generator.js | 6 +-
core/inject.js | 11 +-
core/scrollbar.js | 2 +
core/toolbox.js | 16 +-
core/variables.js | 84 +++--
core/workspace.js | 59 ++--
core/workspace_svg.js | 133 ++++---
core/xml.js | 9 +
core/zoom_controls.js | 3 +
dart_compressed.js | 2 +-
demos/blockfactory/factory_utils.js | 2 +-
demos/blockfactory/index.html | 71 ++--
.../workspacefactory/wfactory_controller.js | 52 +--
.../workspacefactory/wfactory_init.js | 111 ++++--
.../workspacefactory/wfactory_view.js | 16 +-
demos/blockfactory_old/factory.js | 2 +-
demos/code/code.js | 10 +-
demos/custom-dialogs/custom-dialog.js | 173 ++++++++++
demos/custom-dialogs/index.html | 57 +++
demos/interpreter/acorn_interpreter.js | 121 +++----
demos/interpreter/index.html | 2 +-
demos/maxBlocks/index.html | 2 +-
demos/mirror/index.html | 3 +
generators/dart/logic.js | 27 +-
generators/javascript/logic.js | 27 +-
generators/lua/logic.js | 27 +-
generators/php/logic.js | 27 +-
generators/python/logic.js | 29 +-
javascript_compressed.js | 3 +-
lua_compressed.js | 2 +-
msg/js/ar.js | 1 +
msg/js/az.js | 1 +
msg/js/ba.js | 1 +
msg/js/bcc.js | 1 +
msg/js/be-tarask.js | 1 +
msg/js/bg.js | 1 +
msg/js/bn.js | 1 +
msg/js/br.js | 1 +
msg/js/ca.js | 1 +
msg/js/cs.js | 1 +
msg/js/da.js | 1 +
msg/js/de.js | 1 +
msg/js/diq.js | 1 +
msg/js/el.js | 1 +
msg/js/en-gb.js | 1 +
msg/js/en.js | 1 +
msg/js/es.js | 1 +
msg/js/et.js | 1 +
msg/js/fa.js | 1 +
msg/js/fi.js | 1 +
msg/js/fr.js | 1 +
msg/js/he.js | 1 +
msg/js/hi.js | 1 +
msg/js/hrx.js | 1 +
msg/js/hu.js | 1 +
msg/js/ia.js | 1 +
msg/js/id.js | 1 +
msg/js/is.js | 1 +
msg/js/it.js | 1 +
msg/js/ja.js | 1 +
msg/js/ko.js | 1 +
msg/js/lb.js | 1 +
msg/js/lki.js | 1 +
msg/js/lrc.js | 1 +
msg/js/lt.js | 1 +
msg/js/mk.js | 1 +
msg/js/ms.js | 1 +
msg/js/nb.js | 1 +
msg/js/nl.js | 1 +
msg/js/oc.js | 1 +
msg/js/pl.js | 5 +-
msg/js/pms.js | 1 +
msg/js/pt-br.js | 1 +
msg/js/pt.js | 1 +
msg/js/ro.js | 1 +
msg/js/ru.js | 1 +
msg/js/sc.js | 1 +
msg/js/sd.js | 1 +
msg/js/shn.js | 1 +
msg/js/sk.js | 9 +-
msg/js/sl.js | 1 +
msg/js/sq.js | 1 +
msg/js/sr.js | 1 +
msg/js/sv.js | 1 +
msg/js/ta.js | 1 +
msg/js/tcy.js | 1 +
msg/js/th.js | 1 +
msg/js/tl.js | 1 +
msg/js/tlh.js | 1 +
msg/js/tr.js | 1 +
msg/js/uk.js | 9 +-
msg/js/vi.js | 1 +
msg/js/zh-hans.js | 1 +
msg/js/zh-hant.js | 1 +
msg/json/en.json | 3 +-
msg/json/qqq.json | 8 +-
msg/messages.js | 7 +
php_compressed.js | 2 +-
python_compressed.js | 3 +-
tests/multi_playground.html | 5 +-
tests/playground.html | 5 +-
118 files changed, 1332 insertions(+), 646 deletions(-)
create mode 100644 demos/custom-dialogs/custom-dialog.js
create mode 100644 demos/custom-dialogs/index.html
diff --git a/blockly_compressed.js b/blockly_compressed.js
index dd378c0a4..ba07aee6d 100644
--- a/blockly_compressed.js
+++ b/blockly_compressed.js
@@ -4,8 +4,9 @@
var COMPILED=!0,goog=goog||{};goog.global=this;goog.isDef=function(a){return void 0!==a};goog.exportPath_=function(a,b,c){a=a.split(".");c=c||goog.global;a[0]in c||!c.execScript||c.execScript("var "+a[0]);for(var d;a.length&&(d=a.shift());)!a.length&&goog.isDef(b)?c[d]=b:c=c[d]?c[d]:c[d]={}};
goog.define=function(a,b){var c=b;COMPILED||(goog.global.CLOSURE_UNCOMPILED_DEFINES&&Object.prototype.hasOwnProperty.call(goog.global.CLOSURE_UNCOMPILED_DEFINES,a)?c=goog.global.CLOSURE_UNCOMPILED_DEFINES[a]:goog.global.CLOSURE_DEFINES&&Object.prototype.hasOwnProperty.call(goog.global.CLOSURE_DEFINES,a)&&(c=goog.global.CLOSURE_DEFINES[a]));goog.exportPath_(a,c)};goog.DEBUG=!1;goog.LOCALE="en";goog.TRUSTED_SITE=!0;goog.STRICT_MODE_COMPATIBLE=!1;goog.DISALLOW_TEST_ONLY_CODE=COMPILED&&!goog.DEBUG;
goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING=!1;goog.provide=function(a){if(goog.isInModuleLoader_())throw Error("goog.provide can not be used within a goog.module.");if(!COMPILED&&goog.isProvided_(a))throw Error('Namespace "'+a+'" already declared.');goog.constructNamespace_(a)};goog.constructNamespace_=function(a,b){if(!COMPILED){delete goog.implicitNamespaces_[a];for(var c=a;(c=c.substring(0,c.lastIndexOf(".")))&&!goog.getObjectByName(c);)goog.implicitNamespaces_[c]=!0}goog.exportPath_(a,b)};
-goog.VALID_MODULE_RE_=/^[a-zA-Z_$][a-zA-Z0-9._$]*$/;goog.module=function(a){if(!goog.isString(a)||!a||-1==a.search(goog.VALID_MODULE_RE_))throw Error("Invalid module identifier");if(!goog.isInModuleLoader_())throw Error("Module "+a+" has been loaded incorrectly.");if(goog.moduleLoaderState_.moduleName)throw Error("goog.module may only be called once per module.");goog.moduleLoaderState_.moduleName=a;if(!COMPILED){if(goog.isProvided_(a))throw Error('Namespace "'+a+'" already declared.');delete goog.implicitNamespaces_[a]}};
-goog.module.get=function(a){return goog.module.getInternal_(a)};goog.module.getInternal_=function(a){if(!COMPILED)return goog.isProvided_(a)?a in goog.loadedModules_?goog.loadedModules_[a]:goog.getObjectByName(a):null};goog.moduleLoaderState_=null;goog.isInModuleLoader_=function(){return null!=goog.moduleLoaderState_};
+goog.VALID_MODULE_RE_=/^[a-zA-Z_$][a-zA-Z0-9._$]*$/;
+goog.module=function(a){if(!goog.isString(a)||!a||-1==a.search(goog.VALID_MODULE_RE_))throw Error("Invalid module identifier");if(!goog.isInModuleLoader_())throw Error("Module "+a+" has been loaded incorrectly. Note, modules cannot be loaded as normal scripts. They require some kind of pre-processing step. You're likely trying to load a module via a script tag or as a part of a concatenated bundle without rewriting the module. For more info see: https://github.com/google/closure-library/wiki/goog.module:-an-ES6-module-like-alternative-to-goog.provide.");if(goog.moduleLoaderState_.moduleName)throw Error("goog.module may only be called once per module.");
+goog.moduleLoaderState_.moduleName=a;if(!COMPILED){if(goog.isProvided_(a))throw Error('Namespace "'+a+'" already declared.');delete goog.implicitNamespaces_[a]}};goog.module.get=function(a){return goog.module.getInternal_(a)};goog.module.getInternal_=function(a){if(!COMPILED)return goog.isProvided_(a)?a in goog.loadedModules_?goog.loadedModules_[a]:goog.getObjectByName(a):null};goog.moduleLoaderState_=null;goog.isInModuleLoader_=function(){return null!=goog.moduleLoaderState_};
goog.module.declareLegacyNamespace=function(){if(!COMPILED&&!goog.isInModuleLoader_())throw Error("goog.module.declareLegacyNamespace must be called from within a goog.module");if(!COMPILED&&!goog.moduleLoaderState_.moduleName)throw Error("goog.module must be called prior to goog.module.declareLegacyNamespace.");goog.moduleLoaderState_.declareLegacyNamespace=!0};
goog.setTestOnly=function(a){if(goog.DISALLOW_TEST_ONLY_CODE)throw a=a||"",Error("Importing test-only code into non-debug environment"+(a?": "+a:"."));};goog.forwardDeclare=function(a){};COMPILED||(goog.isProvided_=function(a){return a in goog.loadedModules_||!goog.implicitNamespaces_[a]&&goog.isDefAndNotNull(goog.getObjectByName(a))},goog.implicitNamespaces_={"goog.module":!0});
goog.getObjectByName=function(a,b){for(var c=a.split("."),d=b||goog.global,e;e=c.shift();)if(goog.isDefAndNotNull(d[e]))d=d[e];else return null;return d};goog.globalize=function(a,b){var c=b||goog.global,d;for(d in a)c[d]=a[d]};
@@ -16,18 +17,19 @@ goog.TRANSPILER="transpile.js";
goog.DEPENDENCIES_ENABLED&&(goog.dependencies_={loadFlags:{},nameToPath:{},requires:{},visited:{},written:{},deferred:{}},goog.inHtmlDocument_=function(){var a=goog.global.document;return null!=a&&"write"in a},goog.findBasePath_=function(){if(goog.isDef(goog.global.CLOSURE_BASE_PATH))goog.basePath=goog.global.CLOSURE_BASE_PATH;else if(goog.inHtmlDocument_())for(var a=goog.global.document.getElementsByTagName("SCRIPT"),b=a.length-1;0<=b;--b){var c=a[b].src,d=c.lastIndexOf("?"),d=-1==d?c.length:d;if("base.js"==
c.substr(d-7,7)){goog.basePath=c.substr(0,d-7);break}}},goog.importScript_=function(a,b){(goog.global.CLOSURE_IMPORT_SCRIPT||goog.writeScriptTag_)(a,b)&&(goog.dependencies_.written[a]=!0)},goog.IS_OLD_IE_=!(goog.global.atob||!goog.global.document||!goog.global.document.all),goog.importProcessedScript_=function(a,b,c){goog.importScript_("",'goog.retrieveAndExec_("'+a+'", '+b+", "+c+");")},goog.queuedModules_=[],goog.wrapModule_=function(a,b){return goog.LOAD_MODULE_USING_EVAL&&goog.isDef(goog.global.JSON)?
"goog.loadModule("+goog.global.JSON.stringify(b+"\n//# sourceURL="+a+"\n")+");":'goog.loadModule(function(exports) {"use strict";'+b+"\n;return exports});\n//# sourceURL="+a+"\n"},goog.loadQueuedModules_=function(){var a=goog.queuedModules_.length;if(0\x3c/script>')},goog.appendScriptSrcNode_=function(a){var b=goog.global.document,c=b.createElement("script");c.type="text/javascript";c.src=a;c.defer=!1;c.async=!1;b.head.appendChild(c)},goog.writeScriptTag_=function(a,b){if(goog.inHtmlDocument_()){var c=
-goog.global.document;if(!goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING&&"complete"==c.readyState){if(/\bdeps.js$/.test(a))return!1;throw Error('Cannot write "'+a+'" after document load');}if(void 0===b)if(goog.IS_OLD_IE_){var d=" onreadystatechange='goog.onScriptLoad_(this, "+ ++goog.lastNonModuleScriptIndex_+")' ";c.write('
+
+
+
+
+
+
+
+ This is a simple demo of replacing modal browser dialogs with HTML.
+
+ Try creating new variables, creating variables with names already in
+ use, or deleting multiple blocks on the workspace.
+
+
+
+
+
+
+
+
+
+
+
+ abc
+
+
+
+
+
+
+
+
+
+
+
+
+
+