From e2ee3aa9c9b7dbaf27c3afb0c77de8d3eaeb2abb Mon Sep 17 00:00:00 2001 From: CoryDCode Date: Fri, 26 May 2017 10:43:02 -0700 Subject: [PATCH] Setting up accessible Blockly for Closure compilation. (#1134) Moving closure compilation into the build file. Fixing up goog.requires for accessible blockly. Adding accessible to the build script. --- accessible/app.component.js | 23 + accessible/audio.service.js | 5 + accessible/block-connection.service.js | 6 + accessible/block-options-modal.component.js | 10 + accessible/block-options-modal.service.js | 3 + accessible/commonModal.js | 3 + accessible/field-segment.component.js | 7 + accessible/keyboard-input.service.js | 3 + accessible/notifications.service.js | 3 + accessible/sidebar.component.js | 11 + accessible/toolbox-modal.component.js | 11 + accessible/toolbox-modal.service.js | 9 + accessible/translate.pipe.js | 3 + accessible/tree.service.js | 10 + accessible/utils.service.js | 4 +- accessible/variable-add-modal.component.js | 10 + accessible/variable-modal.service.js | 3 + accessible/variable-remove-modal.component.js | 10 + accessible/variable-rename-modal.component.js | 9 + accessible/workspace-block.component.js | 11 + accessible/workspace.component.js | 10 + blockly_accessible_compressed.js | 1621 +++++++++++++++ blockly_accessible_uncompressed.js | 1786 +++++++++++++++++ build.py | 47 +- core/field_variable.js | 1 + demos/accessible/index.html | 38 +- 26 files changed, 3618 insertions(+), 39 deletions(-) create mode 100644 blockly_accessible_compressed.js create mode 100644 blockly_accessible_uncompressed.js diff --git a/accessible/app.component.js b/accessible/app.component.js index 117e818a6..c31fd4259 100644 --- a/accessible/app.component.js +++ b/accessible/app.component.js @@ -22,6 +22,29 @@ * @author madeeha@google.com (Madeeha Ghori) */ +goog.provide('blocklyApp.AppComponent'); + +goog.require('Blockly'); + +goog.require('blocklyApp.AudioService'); +goog.require('blocklyApp.BlockConnectionService'); +goog.require('blocklyApp.BlockOptionsModalComponent'); +goog.require('blocklyApp.BlockOptionsModalService'); +goog.require('blocklyApp.KeyboardInputService'); +goog.require('blocklyApp.NotificationsService'); +goog.require('blocklyApp.SidebarComponent'); +goog.require('blocklyApp.ToolboxModalComponent'); +goog.require('blocklyApp.ToolboxModalService'); +goog.require('blocklyApp.TranslatePipe'); +goog.require('blocklyApp.TreeService'); +goog.require('blocklyApp.UtilsService'); +goog.require('blocklyApp.VariableAddModalComponent'); +goog.require('blocklyApp.VariableModalService'); +goog.require('blocklyApp.VariableRenameModalComponent'); +goog.require('blocklyApp.VariableRemoveModalComponent'); +goog.require('blocklyApp.WorkspaceComponent'); + + blocklyApp.workspace = new Blockly.Workspace(); blocklyApp.AppComponent = ng.core.Component({ diff --git a/accessible/audio.service.js b/accessible/audio.service.js index 1225bb6bd..4f7eb4f08 100644 --- a/accessible/audio.service.js +++ b/accessible/audio.service.js @@ -22,6 +22,11 @@ * @author sll@google.com (Sean Lip) */ +goog.provide('blocklyApp.AudioService'); + +goog.require('blocklyApp.NotificationsService'); + + blocklyApp.AudioService = ng.core.Class({ constructor: [ blocklyApp.NotificationsService, function(notificationsService) { diff --git a/accessible/block-connection.service.js b/accessible/block-connection.service.js index 930ef6f15..c1ee03aac 100644 --- a/accessible/block-connection.service.js +++ b/accessible/block-connection.service.js @@ -23,6 +23,12 @@ * @author sll@google.com (Sean Lip) */ +goog.provide('blocklyApp.BlockConnectionService'); + +goog.require('blocklyApp.AudioService'); +goog.require('blocklyApp.NotificationsService'); + + blocklyApp.BlockConnectionService = ng.core.Class({ constructor: [ blocklyApp.NotificationsService, blocklyApp.AudioService, diff --git a/accessible/block-options-modal.component.js b/accessible/block-options-modal.component.js index 73565ec14..6ac7975b5 100644 --- a/accessible/block-options-modal.component.js +++ b/accessible/block-options-modal.component.js @@ -23,6 +23,16 @@ * @author sll@google.com (Sean Lip) */ +goog.provide('blocklyApp.BlockOptionsModalComponent'); + +goog.require('blocklyApp.AudioService'); +goog.require('blocklyApp.BlockOptionsModalService'); +goog.require('blocklyApp.KeyboardInputService'); +goog.require('blocklyApp.TranslatePipe'); + +goog.require('Blockly.CommonModal'); + + blocklyApp.BlockOptionsModalComponent = ng.core.Component({ selector: 'blockly-block-options-modal', template: ` diff --git a/accessible/block-options-modal.service.js b/accessible/block-options-modal.service.js index c7b068d42..ad775c6d4 100644 --- a/accessible/block-options-modal.service.js +++ b/accessible/block-options-modal.service.js @@ -23,6 +23,9 @@ * @author sll@google.com (Sean Lip) */ +goog.provide('blocklyApp.BlockOptionsModalService'); + + blocklyApp.BlockOptionsModalService = ng.core.Class({ constructor: [function() { this.actionButtonsInfo = []; diff --git a/accessible/commonModal.js b/accessible/commonModal.js index 23ac695ac..57e88b529 100644 --- a/accessible/commonModal.js +++ b/accessible/commonModal.js @@ -1,3 +1,6 @@ +goog.provide('Blockly.CommonModal'); + + Blockly.CommonModal = function() {}; Blockly.CommonModal.setupKeyboardOverrides = function(component) { diff --git a/accessible/field-segment.component.js b/accessible/field-segment.component.js index d0020a7fa..0f3ee6c58 100644 --- a/accessible/field-segment.component.js +++ b/accessible/field-segment.component.js @@ -24,6 +24,13 @@ * @author madeeha@google.com (Madeeha Ghori) */ +goog.provide('blocklyApp.FieldSegmentComponent'); + +goog.require('blocklyApp.NotificationsService'); +goog.require('blocklyApp.TranslatePipe'); +goog.require('blocklyApp.VariableModalService'); + + blocklyApp.FieldSegmentComponent = ng.core.Component({ selector: 'blockly-field-segment', template: ` diff --git a/accessible/keyboard-input.service.js b/accessible/keyboard-input.service.js index 8f0d2933d..638275637 100644 --- a/accessible/keyboard-input.service.js +++ b/accessible/keyboard-input.service.js @@ -23,6 +23,9 @@ * @author sll@google.com (Sean Lip) */ +goog.provide('blocklyApp.KeyboardInputService'); + + blocklyApp.KeyboardInputService = ng.core.Class({ constructor: [function() { // Default custom actions for global keystrokes. The keys of this object diff --git a/accessible/notifications.service.js b/accessible/notifications.service.js index d16d765f4..b1ce22b27 100644 --- a/accessible/notifications.service.js +++ b/accessible/notifications.service.js @@ -23,6 +23,9 @@ * @author sll@google.com (Sean Lip) */ +goog.provide('blocklyApp.NotificationsService'); + + blocklyApp.NotificationsService = ng.core.Class({ constructor: [function() { this.currentMessage = ''; diff --git a/accessible/sidebar.component.js b/accessible/sidebar.component.js index 016fac979..66f735eda 100644 --- a/accessible/sidebar.component.js +++ b/accessible/sidebar.component.js @@ -24,6 +24,17 @@ * @author sll@google.com (Sean Lip) */ +goog.provide('blocklyApp.SidebarComponent'); + +goog.require('blocklyApp.UtilsService'); + +goog.require('blocklyApp.BlockConnectionService'); +goog.require('blocklyApp.ToolboxModalService'); +goog.require('blocklyApp.TranslatePipe'); +goog.require('blocklyApp.TreeService'); +goog.require('blocklyApp.VariableModalService'); + + blocklyApp.SidebarComponent = ng.core.Component({ selector: 'blockly-sidebar', template: ` diff --git a/accessible/toolbox-modal.component.js b/accessible/toolbox-modal.component.js index 2732fdcda..25358e82e 100644 --- a/accessible/toolbox-modal.component.js +++ b/accessible/toolbox-modal.component.js @@ -23,6 +23,17 @@ * @author sll@google.com (Sean Lip) */ +goog.provide('blocklyApp.ToolboxModalComponent'); + +goog.require('Blockly.CommonModal'); +goog.require('blocklyApp.AudioService'); +goog.require('blocklyApp.KeyboardInputService'); +goog.require('blocklyApp.ToolboxModalService'); +goog.require('blocklyApp.TranslatePipe'); +goog.require('blocklyApp.TreeService'); +goog.require('blocklyApp.UtilsService'); + + blocklyApp.ToolboxModalComponent = ng.core.Component({ selector: 'blockly-toolbox-modal', template: ` diff --git a/accessible/toolbox-modal.service.js b/accessible/toolbox-modal.service.js index 66211b505..a135840eb 100644 --- a/accessible/toolbox-modal.service.js +++ b/accessible/toolbox-modal.service.js @@ -23,6 +23,15 @@ * @author sll@google.com (Sean Lip) */ +goog.provide('blocklyApp.ToolboxModalService'); + +goog.require('blocklyApp.UtilsService'); + +goog.require('blocklyApp.BlockConnectionService'); +goog.require('blocklyApp.NotificationsService'); +goog.require('blocklyApp.TreeService'); + + blocklyApp.ToolboxModalService = ng.core.Class({ constructor: [ blocklyApp.BlockConnectionService, diff --git a/accessible/translate.pipe.js b/accessible/translate.pipe.js index 1ec66eeda..fef1940cd 100644 --- a/accessible/translate.pipe.js +++ b/accessible/translate.pipe.js @@ -22,6 +22,9 @@ * @author sll@google.com (Sean Lip) */ +goog.provide('blocklyApp.TranslatePipe'); + + blocklyApp.TranslatePipe = ng.core.Pipe({ name: 'translate' }) diff --git a/accessible/tree.service.js b/accessible/tree.service.js index bbd2e71a5..cf13475ba 100644 --- a/accessible/tree.service.js +++ b/accessible/tree.service.js @@ -25,6 +25,16 @@ * @author madeeha@google.com (Madeeha Ghori) */ +goog.provide('blocklyApp.TreeService'); + +goog.require('blocklyApp.UtilsService'); + +goog.require('blocklyApp.AudioService'); +goog.require('blocklyApp.BlockConnectionService'); +goog.require('blocklyApp.BlockOptionsModalService'); +goog.require('blocklyApp.NotificationsService'); + + blocklyApp.TreeService = ng.core.Class({ constructor: [ blocklyApp.AudioService, diff --git a/accessible/utils.service.js b/accessible/utils.service.js index aea954419..d78472dc8 100644 --- a/accessible/utils.service.js +++ b/accessible/utils.service.js @@ -25,7 +25,9 @@ * @author madeeha@google.com (Madeeha Ghori) */ -var blocklyApp = {}; +goog.provide('blocklyApp.UtilsService'); + + blocklyApp.ID_FOR_EMPTY_WORKSPACE_BTN = 'blocklyEmptyWorkspaceBtn'; blocklyApp.BLOCK_ROOT_ID_SUFFIX = '-blockRoot'; diff --git a/accessible/variable-add-modal.component.js b/accessible/variable-add-modal.component.js index 46d57b0a0..2220ce9ea 100644 --- a/accessible/variable-add-modal.component.js +++ b/accessible/variable-add-modal.component.js @@ -23,6 +23,16 @@ * @author corydiers@google.com (Cory Diers) */ +goog.provide('blocklyApp.VariableAddModalComponent'); + +goog.require('blocklyApp.AudioService'); +goog.require('blocklyApp.KeyboardInputService'); +goog.require('blocklyApp.TranslatePipe'); +goog.require('blocklyApp.VariableModalService'); + +goog.require('Blockly.CommonModal'); + + blocklyApp.VariableAddModalComponent = ng.core.Component({ selector: 'blockly-add-variable-modal', template: ` diff --git a/accessible/variable-modal.service.js b/accessible/variable-modal.service.js index 720afde7f..77a121c29 100644 --- a/accessible/variable-modal.service.js +++ b/accessible/variable-modal.service.js @@ -23,6 +23,9 @@ * @author corydiers@google.com (Cory Diers) */ +goog.provide('blocklyApp.VariableModalService'); + + blocklyApp.VariableModalService = ng.core.Class({ constructor: [ function() { diff --git a/accessible/variable-remove-modal.component.js b/accessible/variable-remove-modal.component.js index f3daf9c17..585f1cd61 100644 --- a/accessible/variable-remove-modal.component.js +++ b/accessible/variable-remove-modal.component.js @@ -23,6 +23,16 @@ * @author corydiers@google.com (Cory Diers) */ +goog.provide('blocklyApp.VariableRemoveModalComponent'); + +goog.require('blocklyApp.AudioService'); +goog.require('blocklyApp.KeyboardInputService'); +goog.require('blocklyApp.TranslatePipe'); +goog.require('blocklyApp.VariableModalService'); + +goog.require('Blockly.CommonModal'); + + blocklyApp.VariableRemoveModalComponent = ng.core.Component({ selector: 'blockly-remove-variable-modal', template: ` diff --git a/accessible/variable-rename-modal.component.js b/accessible/variable-rename-modal.component.js index 060c251f9..534e74372 100644 --- a/accessible/variable-rename-modal.component.js +++ b/accessible/variable-rename-modal.component.js @@ -23,6 +23,15 @@ * @author corydiers@google.com (Cory Diers) */ +goog.provide('blocklyApp.VariableRenameModalComponent'); + +goog.require('Blockly.CommonModal'); +goog.require('blocklyApp.AudioService'); +goog.require('blocklyApp.KeyboardInputService'); +goog.require('blocklyApp.TranslatePipe'); +goog.require('blocklyApp.VariableModalService'); + + blocklyApp.VariableRenameModalComponent = ng.core.Component({ selector: 'blockly-rename-variable-modal', template: ` diff --git a/accessible/workspace-block.component.js b/accessible/workspace-block.component.js index ab2df0bc9..ca20b7fde 100644 --- a/accessible/workspace-block.component.js +++ b/accessible/workspace-block.component.js @@ -23,6 +23,17 @@ * @author madeeha@google.com (Madeeha Ghori) */ +goog.provide('blocklyApp.WorkspaceBlockComponent'); + +goog.require('blocklyApp.UtilsService'); + +goog.require('blocklyApp.AudioService'); +goog.require('blocklyApp.BlockConnectionService'); +goog.require('blocklyApp.FieldSegmentComponent'); +goog.require('blocklyApp.TranslatePipe'); +goog.require('blocklyApp.TreeService'); + + blocklyApp.WorkspaceBlockComponent = ng.core.Component({ selector: 'blockly-workspace-block', template: ` diff --git a/accessible/workspace.component.js b/accessible/workspace.component.js index b6150a956..084460117 100644 --- a/accessible/workspace.component.js +++ b/accessible/workspace.component.js @@ -24,6 +24,16 @@ * @author madeeha@google.com (Madeeha Ghori) */ +goog.provide('blocklyApp.WorkspaceComponent'); + +goog.require('blocklyApp.NotificationsService'); +goog.require('blocklyApp.ToolboxModalService'); +goog.require('blocklyApp.TranslatePipe'); +goog.require('blocklyApp.TreeService'); + +goog.require('blocklyApp.WorkspaceBlockComponent'); + + blocklyApp.WorkspaceComponent = ng.core.Component({ selector: 'blockly-workspace', template: ` diff --git a/blockly_accessible_compressed.js b/blockly_accessible_compressed.js new file mode 100644 index 000000000..3b872ef1a --- /dev/null +++ b/blockly_accessible_compressed.js @@ -0,0 +1,1621 @@ +// Do not edit this file; automatically generated by build.py. +'use strict'; + +var COMPILED=!0,goog=goog||{};goog.global=this;goog.isDef=function(a){return void 0!==a};goog.isString=function(a){return"string"==typeof a};goog.isBoolean=function(a){return"boolean"==typeof a};goog.isNumber=function(a){return"number"==typeof 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]!==Object.prototype[d]?c[d]:c[d]={}}; +goog.define=function(a,b){COMPILED||(goog.global.CLOSURE_UNCOMPILED_DEFINES&&void 0===goog.global.CLOSURE_UNCOMPILED_DEFINES.nodeType&&Object.prototype.hasOwnProperty.call(goog.global.CLOSURE_UNCOMPILED_DEFINES,a)?b=goog.global.CLOSURE_UNCOMPILED_DEFINES[a]:goog.global.CLOSURE_DEFINES&&void 0===goog.global.CLOSURE_DEFINES.nodeType&&Object.prototype.hasOwnProperty.call(goog.global.CLOSURE_DEFINES,a)&&(b=goog.global.CLOSURE_DEFINES[a]));goog.exportPath_(a,b)};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. 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){if(a in goog.loadedModules_)return goog.loadedModules_[a];if(!goog.implicitNamespaces_[a])return a=goog.getObjectByName(a),null!=a?a:null}return 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){a=a.split(".");b=b||goog.global;for(var c;c=a.shift();)if(goog.isDefAndNotNull(b[c]))b=b[c];else return null;return b};goog.globalize=function(a,b){b=b||goog.global;for(var c in a)b[c]=a[c]}; +goog.addDependency=function(a,b,c,d){if(goog.DEPENDENCIES_ENABLED){var e;a=a.replace(/\\/g,"/");var f=goog.dependencies_;d&&"boolean"!==typeof d||(d=d?{module:"goog"}:{});for(var g=0;e=b[g];g++)f.nameToPath[e]=a,f.loadFlags[a]=d;for(d=0;b=c[d];d++)a in f.requires||(f.requires[a]={}),f.requires[a][b]=!0}};goog.ENABLE_DEBUG_LOADER=!0;goog.logToConsole_=function(a){goog.global.console&&goog.global.console.error(a)}; +goog.require=function(a){if(!COMPILED){goog.ENABLE_DEBUG_LOADER&&goog.IS_OLD_IE_&&goog.maybeProcessDeferredDep_(a);if(goog.isProvided_(a)){if(goog.isInModuleLoader_())return goog.module.getInternal_(a)}else if(goog.ENABLE_DEBUG_LOADER){var b=goog.getPathFromDeps_(a);if(b)goog.writeScripts_(b);else throw a="goog.require could not find: "+a,goog.logToConsole_(a),Error(a);}return null}};goog.basePath="";goog.nullFunction=function(){}; +goog.abstractMethod=function(){throw Error("unimplemented abstract method");};goog.addSingletonGetter=function(a){a.instance_=void 0;a.getInstance=function(){if(a.instance_)return a.instance_;goog.DEBUG&&(goog.instantiatedSingletons_[goog.instantiatedSingletons_.length]=a);return a.instance_=new a}};goog.instantiatedSingletons_=[];goog.LOAD_MODULE_USING_EVAL=!0;goog.SEAL_MODULE_EXPORTS=goog.DEBUG;goog.loadedModules_={};goog.DEPENDENCIES_ENABLED=!COMPILED&&goog.ENABLE_DEBUG_LOADER;goog.TRANSPILE="detect"; +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.isString(goog.global.CLOSURE_BASE_PATH))goog.basePath=goog.global.CLOSURE_BASE_PATH;else if(goog.inHtmlDocument_()){var a=goog.global.document;var b=a.currentScript;a=b?[b]:a.getElementsByTagName("SCRIPT");for(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.oldIeWaiting_=!1,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');}void 0===b?goog.IS_OLD_IE_?(goog.oldIeWaiting_=!0,b=" onreadystatechange='goog.onScriptLoad_(this, "+ ++goog.lastNonModuleScriptIndex_+")' ",c.write(''); + // Load fresh Closure Library. + document.write(''); + document.write(''); +} diff --git a/build.py b/build.py index 56756acfb..790bc2942 100755 --- a/build.py +++ b/build.py @@ -71,13 +71,13 @@ class Gen_uncompressed(threading.Thread): """Generate a JavaScript file that loads Blockly's raw files. Runs in a separate thread. """ - def __init__(self, search_paths): + def __init__(self, search_paths, target_filename): threading.Thread.__init__(self) self.search_paths = search_paths + self.target_filename = target_filename def run(self): - target_filename = 'blockly_uncompressed.js' - f = open(target_filename, 'w') + f = open(self.target_filename, 'w') f.write(HEADER) f.write(""" var isNodeJS = !!(typeof module !== 'undefined' && module.exports && @@ -92,7 +92,7 @@ window.BLOCKLY_DIR = (function() { if (!isNodeJS) { // Find name of current directory. var scripts = document.getElementsByTagName('script'); - var re = new RegExp('(.+)[\/]blockly_uncompressed\.js$'); + var re = new RegExp('(.+)[\/]blockly_(.+)uncompressed\.js$'); for (var i = 0, script; script = scripts[i]; i++) { var match = re.exec(script.src); if (match) { @@ -159,7 +159,7 @@ if (isNodeJS) { } """) f.close() - print("SUCCESS: " + target_filename) + print("SUCCESS: " + self.target_filename) class Gen_compressed(threading.Thread): @@ -174,6 +174,7 @@ class Gen_compressed(threading.Thread): def run(self): self.gen_core() + self.gen_accessible() self.gen_blocks() self.gen_generator("javascript") self.gen_generator("python") @@ -207,6 +208,33 @@ class Gen_compressed(threading.Thread): self.do_compile(params, target_filename, filenames, "") + def gen_accessible(self): + target_filename = "blockly_accessible_compressed.js" + # Define the parameters for the POST request. + params = [ + ("compilation_level", "SIMPLE_OPTIMIZATIONS"), + ("use_closure_library", "true"), + ("language_out", "ES5"), + ("output_format", "json"), + ("output_info", "compiled_code"), + ("output_info", "warnings"), + ("output_info", "errors"), + ("output_info", "statistics"), + ] + + # Read in all the source files. + filenames = calcdeps.CalculateDependencies(self.search_paths, + [os.path.join("accessible", "app.component.js")]) + for filename in filenames: + # Filter out the Closure files (the compiler will add them). + if filename.startswith(os.pardir + os.sep): # '../' + continue + f = open(filename) + params.append(("js_code", "".join(f.readlines()))) + f.close() + + self.do_compile(params, target_filename, filenames, "") + def gen_blocks(self): target_filename = "blocks_compressed.js" # Define the parameters for the POST request. @@ -456,14 +484,17 @@ if __name__ == "__main__": developers.google.com/blockly/guides/modify/web/closure""") sys.exit(1) - search_paths = calcdeps.ExpandDirectories( + core_search_paths = calcdeps.ExpandDirectories( ["core", os.path.join(os.path.pardir, "closure-library")]) + full_search_paths = calcdeps.ExpandDirectories( + ["accessible", "core", os.path.join(os.path.pardir, "closure-library")]) # Run both tasks in parallel threads. # Uncompressed is limited by processor speed. # Compressed is limited by network and server speed. - Gen_uncompressed(search_paths).start() - Gen_compressed(search_paths).start() + Gen_uncompressed(core_search_paths, 'blockly_uncompressed.js').start() + Gen_uncompressed(full_search_paths, 'blockly_accessible_uncompressed.js').start() + Gen_compressed(full_search_paths).start() # This is run locally in a separate thread. Gen_langfiles().start() diff --git a/core/field_variable.js b/core/field_variable.js index 6a32ff61b..a1469e4bc 100644 --- a/core/field_variable.js +++ b/core/field_variable.js @@ -30,6 +30,7 @@ goog.require('Blockly.FieldDropdown'); goog.require('Blockly.Msg'); goog.require('Blockly.VariableModel'); goog.require('Blockly.Variables'); +goog.require('Blockly.VariableModel'); goog.require('goog.asserts'); goog.require('goog.string'); diff --git a/demos/accessible/index.html b/demos/accessible/index.html index 3c0a830c1..39104d417 100644 --- a/demos/accessible/index.html +++ b/demos/accessible/index.html @@ -4,42 +4,20 @@ Accessible Blockly Demo - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - + + + + + +