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.
This commit is contained in:
CoryDCode
2017-05-26 10:43:02 -07:00
committed by GitHub
parent c0b906f4b6
commit e2ee3aa9c9
26 changed files with 3618 additions and 39 deletions

View File

@@ -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({

View File

@@ -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) {

View File

@@ -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,

View File

@@ -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: `

View File

@@ -23,6 +23,9 @@
* @author sll@google.com (Sean Lip)
*/
goog.provide('blocklyApp.BlockOptionsModalService');
blocklyApp.BlockOptionsModalService = ng.core.Class({
constructor: [function() {
this.actionButtonsInfo = [];

View File

@@ -1,3 +1,6 @@
goog.provide('Blockly.CommonModal');
Blockly.CommonModal = function() {};
Blockly.CommonModal.setupKeyboardOverrides = function(component) {

View File

@@ -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: `

View File

@@ -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

View File

@@ -23,6 +23,9 @@
* @author sll@google.com (Sean Lip)
*/
goog.provide('blocklyApp.NotificationsService');
blocklyApp.NotificationsService = ng.core.Class({
constructor: [function() {
this.currentMessage = '';

View File

@@ -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: `

View File

@@ -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: `

View File

@@ -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,

View File

@@ -22,6 +22,9 @@
* @author sll@google.com (Sean Lip)
*/
goog.provide('blocklyApp.TranslatePipe');
blocklyApp.TranslatePipe = ng.core.Pipe({
name: 'translate'
})

View File

@@ -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,

View File

@@ -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';

View File

@@ -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: `

View File

@@ -23,6 +23,9 @@
* @author corydiers@google.com (Cory Diers)
*/
goog.provide('blocklyApp.VariableModalService');
blocklyApp.VariableModalService = ng.core.Class({
constructor: [
function() {

View File

@@ -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: `

View File

@@ -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: `

View File

@@ -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: `

View File

@@ -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: `

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -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()

View File

@@ -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');

View File

@@ -4,42 +4,20 @@
<meta charset="utf-8">
<title>Accessible Blockly Demo</title>
<!-- Load Blockly -->
<script src="../../blockly_compressed.js"></script>
<script src="../../blocks_compressed.js"></script>
<script src="../../javascript_compressed.js"></script>
<script src="../../msg/js/en.js"></script>
<script src="../../msg/messages.js"></script>
<script src="../../accessible/messages.js"></script>
<!-- Load accessibleBlockly -->
<script src="../../accessible/libs/es6-shim.min.js"></script>
<script src="../../accessible/libs/angular2-polyfills.min.js"></script>
<script src="../../accessible/libs/Rx.umd.min.js"></script>
<script src="../../accessible/libs/angular2-all.umd.min.js"></script>
<script src="../../accessible/utils.service.js"></script>
<script src="../../accessible/notifications.service.js"></script>
<script src="../../accessible/audio.service.js"></script>
<script src="../../accessible/block-connection.service.js"></script>
<script src="../../accessible/block-options-modal.service.js"></script>
<script src="../../accessible/keyboard-input.service.js"></script>
<script src="../../accessible/tree.service.js"></script>
<script src="../../accessible/toolbox-modal.service.js"></script>
<script src="../../accessible/translate.pipe.js"></script>
<script src="../../accessible/variable-modal.service.js"></script>
<!-- Load accessibleBlockly -->
<script src="../../blockly_accessible_compressed.js"></script>
<script src="../../accessible/commonModal.js"></script>
<script src="../../accessible/field-segment.component.js"></script>
<script src="../../accessible/block-options-modal.component.js"></script>
<script src="../../accessible/toolbox-modal.component.js"></script>
<script src="../../accessible/variable-add-modal.component.js"></script>
<script src="../../accessible/variable-rename-modal.component.js"></script>
<script src="../../accessible/variable-remove-modal.component.js"></script>
<script src="../../accessible/sidebar.component.js"></script>
<script src="../../accessible/workspace-block.component.js"></script>
<script src="../../accessible/workspace.component.js"></script>
<script src="../../accessible/app.component.js"></script>
<!-- Load Blockly -->
<script src="../../blocks_compressed.js"></script>
<script src="../../javascript_compressed.js"></script>
<script src="../../msg/js/en.js"></script>
<script src="../../msg/messages.js"></script>
<script src="../../accessible/messages.js"></script>
<link rel="stylesheet" href="../../accessible/media/accessible.css">
<style>