chore(generators): Migrate generators to ES Modules (#7103)

* feat(j2ts): Add support for migrating renaming imports

  Convert
      const {foo: bar} = require(/*...*/);
  into
      import {foo as bar} from /*...*/;
              ^^^^^^^^^^

  Also fix a bug that caused relative paths to ESM in the same
  directory to be missing a leading "./".

* fix(build): Fix trivial error exports for generators

  The UMD wrapper was inadvertently exporting the contents of (e.g.)
  the Blockly.JavaScript closure module rather than the intended
  export of Blockly.JavaScript.all module - which went unnoticed
  because the latter just reexported the former - but we are
  about to convert the former to ESM.

* chore(generators): Migrate language generators to ESM

  Migrate the main language generators in generators/*.js to ESM.

  This was done by running js2ts on the files, renaming them back
  to .js, and commenting out "import type" statements, which are
  legal TS but not needed in JS (at least if you are not actually
  letting Closure Compiler do type checking, which we are not.)

* chore(generators): Migrate block generators to ESM

  Migrate generators/*/*.js (except all.js) to ESM.

  This was done by running js2ts on the files, renaming them back
  to .js, and removing now-spurious @suppress {extraRequire}
  directives.

* chores(generators): Migrate generator chunk entrypoints to ESM

  This was done by running js2ts on the files, renaming them back
  to .js, and manually fixing the export statements.

  An additional change to the chunk exports configuration in
  build_tasks.js was necessary in order for the UMD wrapper to
  find the new module object, which is given a different name
  than the old exports object.
This commit is contained in:
Christopher Allen
2023-05-19 23:09:37 +01:00
committed by GitHub
parent 3ce3d45116
commit 4d2201a427
57 changed files with 299 additions and 309 deletions

View File

@@ -8,17 +8,17 @@
* @fileoverview Helper functions for generating Dart for blocks.
* @suppress {checkTypes|globalThis}
*/
'use strict';
goog.module('Blockly.Dart');
import * as goog from '../closure/goog/goog.js';
goog.declareModuleId('Blockly.Dart');
const Variables = goog.require('Blockly.Variables');
const stringUtils = goog.require('Blockly.utils.string');
const {Block} = goog.requireType('Blockly.Block');
const {CodeGenerator} = goog.require('Blockly.CodeGenerator');
const {Names, NameType} = goog.require('Blockly.Names');
const {Workspace} = goog.requireType('Blockly.Workspace');
const {inputTypes} = goog.require('Blockly.inputTypes');
import * as Variables from '../core/variables.js';
import * as stringUtils from '../core/utils/string.js';
// import type {Block} from '../core/block.js';
import {CodeGenerator} from '../core/generator.js';
import {Names, NameType} from '../core/names.js';
// import type {Workspace} from '../core/workspace.js';
import {inputTypes} from '../core/inputs/input_types.js';
/**
@@ -299,5 +299,4 @@ Dart.getAdjusted = function(block, atId, opt_delta, opt_negate,
}
return at;
};
exports.dartGenerator = Dart;
export {Dart as dartGenerator};

View File

@@ -9,19 +9,18 @@
* blocks. This is the entrypoint for dart_compressed.js.
* @suppress {extraRequire}
*/
'use strict';
goog.module('Blockly.Dart.all');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.Dart.all');
const moduleExports = goog.require('Blockly.Dart');
goog.require('Blockly.Dart.colour');
goog.require('Blockly.Dart.lists');
goog.require('Blockly.Dart.logic');
goog.require('Blockly.Dart.loops');
goog.require('Blockly.Dart.math');
goog.require('Blockly.Dart.procedures');
goog.require('Blockly.Dart.texts');
goog.require('Blockly.Dart.variables');
goog.require('Blockly.Dart.variablesDynamic');
import './colour.js';
import './lists.js';
import './logic.js';
import './loops.js';
import './math.js';
import './procedures.js';
import './text.js';
import './variables.js';
import './variables_dynamic.js';
exports = moduleExports;
export * from '../dart.js';

View File

@@ -7,11 +7,11 @@
/**
* @fileoverview Generating Dart for colour blocks.
*/
'use strict';
goog.module('Blockly.Dart.colour');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.Dart.colour');
const {dartGenerator: Dart} = goog.require('Blockly.Dart');
import {dartGenerator as Dart} from '../dart.js';
Dart.addReservedWords('Math');

View File

@@ -7,12 +7,12 @@
/**
* @fileoverview Generating Dart for list blocks.
*/
'use strict';
goog.module('Blockly.Dart.lists');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.Dart.lists');
const {NameType} = goog.require('Blockly.Names');
const {dartGenerator: Dart} = goog.require('Blockly.Dart');
import {NameType} from '../../core/names.js';
import {dartGenerator as Dart} from '../dart.js';
Dart.addReservedWords('Math');

View File

@@ -7,11 +7,11 @@
/**
* @fileoverview Generating Dart for logic blocks.
*/
'use strict';
goog.module('Blockly.Dart.logic');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.Dart.logic');
const {dartGenerator: Dart} = goog.require('Blockly.Dart');
import {dartGenerator as Dart} from '../dart.js';
Dart['controls_if'] = function(block) {

View File

@@ -7,13 +7,13 @@
/**
* @fileoverview Generating Dart for loop blocks.
*/
'use strict';
goog.module('Blockly.Dart.loops');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.Dart.loops');
const {dartGenerator: Dart} = goog.require('Blockly.Dart');
const stringUtils = goog.require('Blockly.utils.string');
const {NameType} = goog.require('Blockly.Names');
import {dartGenerator as Dart} from '../dart.js';
import * as stringUtils from '../../core/utils/string.js';
import {NameType} from '../../core/names.js';
Dart['controls_repeat_ext'] = function(block) {

View File

@@ -7,12 +7,12 @@
/**
* @fileoverview Generating Dart for math blocks.
*/
'use strict';
goog.module('Blockly.Dart.math');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.Dart.math');
const {NameType} = goog.require('Blockly.Names');
const {dartGenerator: Dart} = goog.require('Blockly.Dart');
import {NameType} from '../../core/names.js';
import {dartGenerator as Dart} from '../dart.js';
Dart.addReservedWords('Math');

View File

@@ -7,12 +7,12 @@
/**
* @fileoverview Generating Dart for procedure blocks.
*/
'use strict';
goog.module('Blockly.Dart.procedures');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.Dart.procedures');
const {NameType} = goog.require('Blockly.Names');
const {dartGenerator: Dart} = goog.require('Blockly.Dart');
import {NameType} from '../../core/names.js';
import {dartGenerator as Dart} from '../dart.js';
Dart['procedures_defreturn'] = function(block) {

View File

@@ -7,12 +7,12 @@
/**
* @fileoverview Generating Dart for text blocks.
*/
'use strict';
goog.module('Blockly.Dart.texts');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.Dart.texts');
const {NameType} = goog.require('Blockly.Names');
const {dartGenerator: Dart} = goog.require('Blockly.Dart');
import {NameType} from '../../core/names.js';
import {dartGenerator as Dart} from '../dart.js';
Dart.addReservedWords('Html,Math');

View File

@@ -7,12 +7,12 @@
/**
* @fileoverview Generating Dart for variable blocks.
*/
'use strict';
goog.module('Blockly.Dart.variables');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.Dart.variables');
const {NameType} = goog.require('Blockly.Names');
const {dartGenerator: Dart} = goog.require('Blockly.Dart');
import {NameType} from '../../core/names.js';
import {dartGenerator as Dart} from '../dart.js';
Dart['variables_get'] = function(block) {

View File

@@ -7,13 +7,12 @@
/**
* @fileoverview Generating Dart for dynamic variable blocks.
*/
'use strict';
goog.module('Blockly.Dart.variablesDynamic');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.Dart.variablesDynamic');
const {dartGenerator: Dart} = goog.require('Blockly.Dart');
/** @suppress {extraRequire} */
goog.require('Blockly.Dart.variables');
import {dartGenerator as Dart} from '../dart.js';
import './variables.js';
// Dart is dynamically typed.

View File

@@ -8,17 +8,17 @@
* @fileoverview Helper functions for generating JavaScript for blocks.
* @suppress {checkTypes|globalThis}
*/
'use strict';
goog.module('Blockly.JavaScript');
import * as goog from '../closure/goog/goog.js';
goog.declareModuleId('Blockly.JavaScript');
const Variables = goog.require('Blockly.Variables');
const stringUtils = goog.require('Blockly.utils.string');
const {Block} = goog.requireType('Blockly.Block');
const {CodeGenerator} = goog.require('Blockly.CodeGenerator');
const {inputTypes} = goog.require('Blockly.inputTypes');
const {Names, NameType} = goog.require('Blockly.Names');
const {Workspace} = goog.requireType('Blockly.Workspace');
import * as Variables from '../core/variables.js';
import * as stringUtils from '../core/utils/string.js';
// import type {Block} from '../core/block.js';
import {CodeGenerator} from '../core/generator.js';
import {inputTypes} from '../core/inputs/input_types.js';
import {Names, NameType} from '../core/names.js';
// import type {Workspace} from '../core/workspace.js';
/**
@@ -317,5 +317,4 @@ JavaScript.getAdjusted = function(
}
return at;
};
exports.javascriptGenerator = JavaScript;
export {JavaScript as javascriptGenerator};

View File

@@ -9,19 +9,18 @@
* blocks. This is the entrypoint for javascript_compressed.js.
* @suppress {extraRequire}
*/
'use strict';
goog.module('Blockly.JavaScript.all');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.JavaScript.all');
const moduleExports = goog.require('Blockly.JavaScript');
goog.require('Blockly.JavaScript.colour');
goog.require('Blockly.JavaScript.lists');
goog.require('Blockly.JavaScript.logic');
goog.require('Blockly.JavaScript.loops');
goog.require('Blockly.JavaScript.math');
goog.require('Blockly.JavaScript.procedures');
goog.require('Blockly.JavaScript.texts');
goog.require('Blockly.JavaScript.variables');
goog.require('Blockly.JavaScript.variablesDynamic');
import './colour.js';
import './lists.js';
import './logic.js';
import './loops.js';
import './math.js';
import './procedures.js';
import './text.js';
import './variables.js';
import './variables_dynamic.js';
exports = moduleExports;
export * from '../javascript.js';

View File

@@ -7,11 +7,11 @@
/**
* @fileoverview Generating JavaScript for colour blocks.
*/
'use strict';
goog.module('Blockly.JavaScript.colour');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.JavaScript.colour');
const {javascriptGenerator: JavaScript} = goog.require('Blockly.JavaScript');
import {javascriptGenerator as JavaScript} from '../javascript.js';
JavaScript['colour_picker'] = function(block) {

View File

@@ -8,12 +8,12 @@
* @fileoverview Generating JavaScript for list blocks.
* @suppress {missingRequire}
*/
'use strict';
goog.module('Blockly.JavaScript.lists');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.JavaScript.lists');
const {NameType} = goog.require('Blockly.Names');
const {javascriptGenerator: JavaScript} = goog.require('Blockly.JavaScript');
import {NameType} from '../../core/names.js';
import {javascriptGenerator as JavaScript} from '../javascript.js';
JavaScript['lists_create_empty'] = function(block) {

View File

@@ -7,11 +7,11 @@
/**
* @fileoverview Generating JavaScript for logic blocks.
*/
'use strict';
goog.module('Blockly.JavaScript.logic');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.JavaScript.logic');
const {javascriptGenerator: JavaScript} = goog.require('Blockly.JavaScript');
import {javascriptGenerator as JavaScript} from '../javascript.js';
JavaScript['controls_if'] = function(block) {

View File

@@ -7,13 +7,13 @@
/**
* @fileoverview Generating JavaScript for loop blocks.
*/
'use strict';
goog.module('Blockly.JavaScript.loops');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.JavaScript.loops');
const stringUtils = goog.require('Blockly.utils.string');
const {NameType} = goog.require('Blockly.Names');
const {javascriptGenerator: JavaScript} = goog.require('Blockly.JavaScript');
import * as stringUtils from '../../core/utils/string.js';
import {NameType} from '../../core/names.js';
import {javascriptGenerator as JavaScript} from '../javascript.js';
JavaScript['controls_repeat_ext'] = function(block) {

View File

@@ -8,12 +8,12 @@
* @fileoverview Generating JavaScript for math blocks.
* @suppress {missingRequire}
*/
'use strict';
goog.module('Blockly.JavaScript.math');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.JavaScript.math');
const {NameType} = goog.require('Blockly.Names');
const {javascriptGenerator: JavaScript} = goog.require('Blockly.JavaScript');
import {NameType} from '../../core/names.js';
import {javascriptGenerator as JavaScript} from '../javascript.js';
JavaScript['math_number'] = function(block) {

View File

@@ -7,12 +7,12 @@
/**
* @fileoverview Generating JavaScript for procedure blocks.
*/
'use strict';
goog.module('Blockly.JavaScript.procedures');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.JavaScript.procedures');
const {NameType} = goog.require('Blockly.Names');
const {javascriptGenerator: JavaScript} = goog.require('Blockly.JavaScript');
import {NameType} from '../../core/names.js';
import {javascriptGenerator as JavaScript} from '../javascript.js';
JavaScript['procedures_defreturn'] = function(block) {

View File

@@ -7,12 +7,12 @@
/**
* @fileoverview Generating JavaScript for text blocks.
*/
'use strict';
goog.module('Blockly.JavaScript.texts');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.JavaScript.texts');
const {NameType} = goog.require('Blockly.Names');
const {javascriptGenerator: JavaScript} = goog.require('Blockly.JavaScript');
import {NameType} from '../../core/names.js';
import {javascriptGenerator as JavaScript} from '../javascript.js';
/**

View File

@@ -7,12 +7,12 @@
/**
* @fileoverview Generating JavaScript for variable blocks.
*/
'use strict';
goog.module('Blockly.JavaScript.variables');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.JavaScript.variables');
const {NameType} = goog.require('Blockly.Names');
const {javascriptGenerator: JavaScript} = goog.require('Blockly.JavaScript');
import {NameType} from '../../core/names.js';
import {javascriptGenerator as JavaScript} from '../javascript.js';
JavaScript['variables_get'] = function(block) {

View File

@@ -7,13 +7,12 @@
/**
* @fileoverview Generating JavaScript for dynamic variable blocks.
*/
'use strict';
goog.module('Blockly.JavaScript.variablesDynamic');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.JavaScript.variablesDynamic');
const {javascriptGenerator: JavaScript} = goog.require('Blockly.JavaScript');
/** @suppress {extraRequire} */
goog.require('Blockly.JavaScript.variables');
import {javascriptGenerator as JavaScript} from '../javascript.js';
import './variables.js';
// JavaScript is dynamically typed.

View File

@@ -9,16 +9,16 @@
* Based on Ellen Spertus's blocky-lua project.
* @suppress {checkTypes|globalThis}
*/
'use strict';
goog.module('Blockly.Lua');
import * as goog from '../closure/goog/goog.js';
goog.declareModuleId('Blockly.Lua');
const stringUtils = goog.require('Blockly.utils.string');
const {Block} = goog.requireType('Blockly.Block');
const {CodeGenerator} = goog.require('Blockly.CodeGenerator');
const {inputTypes} = goog.require('Blockly.inputTypes');
const {Names} = goog.require('Blockly.Names');
const {Workspace} = goog.requireType('Blockly.Workspace');
import * as stringUtils from '../core/utils/string.js';
// import type {Block} from '../core/block.js';
import {CodeGenerator} from '../core/generator.js';
import {inputTypes} from '../core/inputs/input_types.js';
import {Names} from '../core/names.js';
// import type {Workspace} from '../core/workspace.js';
/**
@@ -201,5 +201,4 @@ Lua.scrub_ = function(block, code, opt_thisOnly) {
const nextCode = opt_thisOnly ? '' : this.blockToCode(nextBlock);
return commentCode + code + nextCode;
};
exports.luaGenerator = Lua;
export {Lua as luaGenerator};

View File

@@ -9,19 +9,18 @@
* blocks. This is the entrypoint for lua_compressed.js.
* @suppress {extraRequire}
*/
'use strict';
goog.module('Blockly.Lua.all');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.Lua.all');
const moduleExports = goog.require('Blockly.Lua');
goog.require('Blockly.Lua.colour');
goog.require('Blockly.Lua.lists');
goog.require('Blockly.Lua.logic');
goog.require('Blockly.Lua.loops');
goog.require('Blockly.Lua.math');
goog.require('Blockly.Lua.procedures');
goog.require('Blockly.Lua.texts');
goog.require('Blockly.Lua.variables');
goog.require('Blockly.Lua.variablesDynamic');
import './colour.js';
import './lists.js';
import './logic.js';
import './loops.js';
import './math.js';
import './procedures.js';
import './text.js';
import './variables.js';
import './variables_dynamic.js';
exports = moduleExports;
export * from '../lua.js';

View File

@@ -7,11 +7,11 @@
/**
* @fileoverview Generating Lua for colour blocks.
*/
'use strict';
goog.module('Blockly.Lua.colour');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.Lua.colour');
const {luaGenerator: Lua} = goog.require('Blockly.Lua');
import {luaGenerator as Lua} from '../lua.js';
Lua['colour_picker'] = function(block) {

View File

@@ -7,12 +7,12 @@
/**
* @fileoverview Generating Lua for list blocks.
*/
'use strict';
goog.module('Blockly.Lua.lists');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.Lua.lists');
const {NameType} = goog.require('Blockly.Names');
const {luaGenerator: Lua} = goog.require('Blockly.Lua');
import {NameType} from '../../core/names.js';
import {luaGenerator as Lua} from '../lua.js';
Lua['lists_create_empty'] = function(block) {

View File

@@ -7,11 +7,11 @@
/**
* @fileoverview Generating Lua for logic blocks.
*/
'use strict';
goog.module('Blockly.Lua.logic');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.Lua.logic');
const {luaGenerator: Lua} = goog.require('Blockly.Lua');
import {luaGenerator as Lua} from '../lua.js';
Lua['controls_if'] = function(block) {

View File

@@ -7,13 +7,13 @@
/**
* @fileoverview Generating Lua for loop blocks.
*/
'use strict';
goog.module('Blockly.Lua.loops');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.Lua.loops');
const stringUtils = goog.require('Blockly.utils.string');
const {NameType} = goog.require('Blockly.Names');
const {luaGenerator: Lua} = goog.require('Blockly.Lua');
import * as stringUtils from '../../core/utils/string.js';
import {NameType} from '../../core/names.js';
import {luaGenerator as Lua} from '../lua.js';
/**

View File

@@ -7,12 +7,12 @@
/**
* @fileoverview Generating Lua for math blocks.
*/
'use strict';
goog.module('Blockly.Lua.math');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.Lua.math');
const {NameType} = goog.require('Blockly.Names');
const {luaGenerator: Lua} = goog.require('Blockly.Lua');
import {NameType} from '../../core/names.js';
import {luaGenerator as Lua} from '../lua.js';
Lua['math_number'] = function(block) {

View File

@@ -7,12 +7,12 @@
/**
* @fileoverview Generating Lua for procedure blocks.
*/
'use strict';
goog.module('Blockly.Lua.procedures');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.Lua.procedures');
const {NameType} = goog.require('Blockly.Names');
const {luaGenerator: Lua} = goog.require('Blockly.Lua');
import {NameType} from '../../core/names.js';
import {luaGenerator as Lua} from '../lua.js';
Lua['procedures_defreturn'] = function(block) {

View File

@@ -7,12 +7,12 @@
/**
* @fileoverview Generating Lua for text blocks.
*/
'use strict';
goog.module('Blockly.Lua.texts');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.Lua.texts');
const {NameType} = goog.require('Blockly.Names');
const {luaGenerator: Lua} = goog.require('Blockly.Lua');
import {NameType} from '../../core/names.js';
import {luaGenerator as Lua} from '../lua.js';
Lua['text'] = function(block) {

View File

@@ -7,12 +7,12 @@
/**
* @fileoverview Generating Lua for variable blocks.
*/
'use strict';
goog.module('Blockly.Lua.variables');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.Lua.variables');
const {NameType} = goog.require('Blockly.Names');
const {luaGenerator: Lua} = goog.require('Blockly.Lua');
import {NameType} from '../../core/names.js';
import {luaGenerator as Lua} from '../lua.js';
Lua['variables_get'] = function(block) {

View File

@@ -7,13 +7,12 @@
/**
* @fileoverview Generating Lua for dynamic variable blocks.
*/
'use strict';
goog.module('Blockly.Lua.variablesDynamic');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.Lua.variablesDynamic');
const {luaGenerator: Lua} = goog.require('Blockly.Lua');
/** @suppress {extraRequire} */
goog.require('Blockly.Lua.variables');
import {luaGenerator as Lua} from '../lua.js';
import './variables.js';
// Lua is dynamically typed.

View File

@@ -8,16 +8,16 @@
* @fileoverview Helper functions for generating PHP for blocks.
* @suppress {checkTypes|globalThis}
*/
'use strict';
goog.module('Blockly.PHP');
import * as goog from '../closure/goog/goog.js';
goog.declareModuleId('Blockly.PHP');
const stringUtils = goog.require('Blockly.utils.string');
const {Block} = goog.requireType('Blockly.Block');
const {CodeGenerator} = goog.require('Blockly.CodeGenerator');
const {inputTypes} = goog.require('Blockly.inputTypes');
const {Names} = goog.require('Blockly.Names');
const {Workspace} = goog.requireType('Blockly.Workspace');
import * as stringUtils from '../core/utils/string.js';
// import type {Block} from '../core/block.js';
import {CodeGenerator} from '../core/generator.js';
import {inputTypes} from '../core/inputs/input_types.js';
import {Names} from '../core/names.js';
// import type {Workspace} from '../core/workspace.js';
/**
@@ -298,5 +298,4 @@ PHP.getAdjusted = function(block, atId, opt_delta, opt_negate, opt_order) {
}
return at;
};
exports.phpGenerator = PHP;
export {PHP as phpGenerator};

View File

@@ -9,19 +9,18 @@
* blocks. This is the entrypoint for php_compressed.js.
* @suppress {extraRequire}
*/
'use strict';
goog.module('Blockly.PHP.all');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.PHP.all');
const moduleExports = goog.require('Blockly.PHP');
goog.require('Blockly.PHP.colour');
goog.require('Blockly.PHP.lists');
goog.require('Blockly.PHP.logic');
goog.require('Blockly.PHP.loops');
goog.require('Blockly.PHP.math');
goog.require('Blockly.PHP.procedures');
goog.require('Blockly.PHP.texts');
goog.require('Blockly.PHP.variables');
goog.require('Blockly.PHP.variablesDynamic');
import './colour.js';
import './lists.js';
import './logic.js';
import './loops.js';
import './math.js';
import './procedures.js';
import './text.js';
import './variables.js';
import './variables_dynamic.js';
exports = moduleExports;
export * from '../php.js';

View File

@@ -7,11 +7,11 @@
/**
* @fileoverview Generating PHP for colour blocks.
*/
'use strict';
goog.module('Blockly.PHP.colour');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.PHP.colour');
const {phpGenerator: PHP} = goog.require('Blockly.PHP');
import {phpGenerator as PHP} from '../php.js';
PHP['colour_picker'] = function(block) {

View File

@@ -18,13 +18,13 @@
* PHP (because only variables can be passed by reference).
* ex: end(true ? list1 : list2)
*/
'use strict';
goog.module('Blockly.PHP.lists');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.PHP.lists');
const stringUtils = goog.require('Blockly.utils.string');
const {NameType} = goog.require('Blockly.Names');
const {phpGenerator: PHP} = goog.require('Blockly.PHP');
import * as stringUtils from '../../core/utils/string.js';
import {NameType} from '../../core/names.js';
import {phpGenerator as PHP} from '../php.js';
PHP['lists_create_empty'] = function(block) {
// Create an empty list.

View File

@@ -7,11 +7,11 @@
/**
* @fileoverview Generating PHP for logic blocks.
*/
'use strict';
goog.module('Blockly.PHP.logic');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.PHP.logic');
const {phpGenerator: PHP} = goog.require('Blockly.PHP');
import {phpGenerator as PHP} from '../php.js';
PHP['controls_if'] = function(block) {

View File

@@ -7,13 +7,13 @@
/**
* @fileoverview Generating PHP for loop blocks.
*/
'use strict';
goog.module('Blockly.PHP.loops');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.PHP.loops');
const stringUtils = goog.require('Blockly.utils.string');
const {NameType} = goog.require('Blockly.Names');
const {phpGenerator: PHP} = goog.require('Blockly.PHP');
import * as stringUtils from '../../core/utils/string.js';
import {NameType} from '../../core/names.js';
import {phpGenerator as PHP} from '../php.js';
PHP['controls_repeat_ext'] = function(block) {

View File

@@ -7,12 +7,12 @@
/**
* @fileoverview Generating PHP for math blocks.
*/
'use strict';
goog.module('Blockly.PHP.math');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.PHP.math');
const {NameType} = goog.require('Blockly.Names');
const {phpGenerator: PHP} = goog.require('Blockly.PHP');
import {NameType} from '../../core/names.js';
import {phpGenerator as PHP} from '../php.js';
PHP['math_number'] = function(block) {

View File

@@ -7,13 +7,13 @@
/**
* @fileoverview Generating PHP for procedure blocks.
*/
'use strict';
goog.module('Blockly.PHP.procedures');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.PHP.procedures');
const Variables = goog.require('Blockly.Variables');
const {NameType} = goog.require('Blockly.Names');
const {phpGenerator: PHP} = goog.require('Blockly.PHP');
import * as Variables from '../../core/variables.js';
import {NameType} from '../../core/names.js';
import {phpGenerator as PHP} from '../php.js';
PHP['procedures_defreturn'] = function(block) {

View File

@@ -7,12 +7,12 @@
/**
* @fileoverview Generating PHP for text blocks.
*/
'use strict';
goog.module('Blockly.PHP.texts');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.PHP.texts');
const {NameType} = goog.require('Blockly.Names');
const {phpGenerator: PHP} = goog.require('Blockly.PHP');
import {NameType} from '../../core/names.js';
import {phpGenerator as PHP} from '../php.js';
PHP['text'] = function(block) {

View File

@@ -7,12 +7,12 @@
/**
* @fileoverview Generating PHP for variable blocks.
*/
'use strict';
goog.module('Blockly.PHP.variables');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.PHP.variables');
const {NameType} = goog.require('Blockly.Names');
const {phpGenerator: PHP} = goog.require('Blockly.PHP');
import {NameType} from '../../core/names.js';
import {phpGenerator as PHP} from '../php.js';
PHP['variables_get'] = function(block) {

View File

@@ -7,13 +7,12 @@
/**
* @fileoverview Generating PHP for dynamic variable blocks.
*/
'use strict';
goog.module('Blockly.PHP.variablesDynamic');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.PHP.variablesDynamic');
const {phpGenerator: PHP} = goog.require('Blockly.PHP');
/** @suppress {extraRequire} */
goog.require('Blockly.PHP.variables');
import {phpGenerator as PHP} from '../php.js';
import './variables.js';
// PHP is dynamically typed.

View File

@@ -8,17 +8,17 @@
* @fileoverview Helper functions for generating Python for blocks.
* @suppress {checkTypes|globalThis}
*/
'use strict';
goog.module('Blockly.Python');
import * as goog from '../closure/goog/goog.js';
goog.declareModuleId('Blockly.Python');
const stringUtils = goog.require('Blockly.utils.string');
const Variables = goog.require('Blockly.Variables');
const {Block} = goog.requireType('Blockly.Block');
const {CodeGenerator} = goog.require('Blockly.CodeGenerator');
const {inputTypes} = goog.require('Blockly.inputTypes');
const {Names, NameType} = goog.require('Blockly.Names');
const {Workspace} = goog.requireType('Blockly.Workspace');
import * as stringUtils from '../core/utils/string.js';
import * as Variables from '../core/variables.js';
// import type {Block} from '../core/block.js';
import {CodeGenerator} from '../core/generator.js';
import {inputTypes} from '../core/inputs/input_types.js';
import {Names, NameType} from '../core/names.js';
// import type {Workspace} from '../core/workspace.js';
/**
@@ -329,5 +329,4 @@ Python.getAdjustedInt = function(block, atId, opt_delta, opt_negate) {
}
return at;
};
exports.pythonGenerator = Python;
export {Python as pythonGenerator};

View File

@@ -9,19 +9,18 @@
* blocks. This is the entrypoint for python_compressed.js.
* @suppress {extraRequire}
*/
'use strict';
goog.module('Blockly.Python.all');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.Python.all');
const moduleExports = goog.require('Blockly.Python');
goog.require('Blockly.Python.colour');
goog.require('Blockly.Python.lists');
goog.require('Blockly.Python.logic');
goog.require('Blockly.Python.loops');
goog.require('Blockly.Python.math');
goog.require('Blockly.Python.procedures');
goog.require('Blockly.Python.texts');
goog.require('Blockly.Python.variables');
goog.require('Blockly.Python.variablesDynamic');
import './colour.js';
import './lists.js';
import './logic.js';
import './loops.js';
import './math.js';
import './procedures.js';
import './text.js';
import './variables.js';
import './variables_dynamic.js';
exports = moduleExports;
export * from '../python.js';

View File

@@ -7,11 +7,11 @@
/**
* @fileoverview Generating Python for colour blocks.
*/
'use strict';
goog.module('Blockly.Python.colour');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.Python.colour');
const {pythonGenerator: Python} = goog.require('Blockly.Python');
import {pythonGenerator as Python} from '../python.js';
Python['colour_picker'] = function(block) {

View File

@@ -7,13 +7,13 @@
/**
* @fileoverview Generating Python for list blocks.
*/
'use strict';
goog.module('Blockly.Python.lists');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.Python.lists');
const stringUtils = goog.require('Blockly.utils.string');
const {NameType} = goog.require('Blockly.Names');
const {pythonGenerator: Python} = goog.require('Blockly.Python');
import * as stringUtils from '../../core/utils/string.js';
import {NameType} from '../../core/names.js';
import {pythonGenerator as Python} from '../python.js';
Python['lists_create_empty'] = function(block) {

View File

@@ -7,11 +7,11 @@
/**
* @fileoverview Generating Python for logic blocks.
*/
'use strict';
goog.module('Blockly.Python.logic');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.Python.logic');
const {pythonGenerator: Python} = goog.require('Blockly.Python');
import {pythonGenerator as Python} from '../python.js';
Python['controls_if'] = function(block) {

View File

@@ -7,13 +7,13 @@
/**
* @fileoverview Generating Python for loop blocks.
*/
'use strict';
goog.module('Blockly.Python.loops');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.Python.loops');
const stringUtils = goog.require('Blockly.utils.string');
const {NameType} = goog.require('Blockly.Names');
const {pythonGenerator: Python} = goog.require('Blockly.Python');
import * as stringUtils from '../../core/utils/string.js';
import {NameType} from '../../core/names.js';
import {pythonGenerator as Python} from '../python.js';
Python['controls_repeat_ext'] = function(block) {

View File

@@ -7,12 +7,12 @@
/**
* @fileoverview Generating Python for math blocks.
*/
'use strict';
goog.module('Blockly.Python.math');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.Python.math');
const {NameType} = goog.require('Blockly.Names');
const {pythonGenerator: Python} = goog.require('Blockly.Python');
import {NameType} from '../../core/names.js';
import {pythonGenerator as Python} from '../python.js';
// If any new block imports any library, add that library name here.

View File

@@ -7,13 +7,13 @@
/**
* @fileoverview Generating Python for procedure blocks.
*/
'use strict';
goog.module('Blockly.Python.procedures');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.Python.procedures');
const Variables = goog.require('Blockly.Variables');
const {NameType} = goog.require('Blockly.Names');
const {pythonGenerator: Python} = goog.require('Blockly.Python');
import * as Variables from '../../core/variables.js';
import {NameType} from '../../core/names.js';
import {pythonGenerator as Python} from '../python.js';
Python['procedures_defreturn'] = function(block) {

View File

@@ -7,13 +7,13 @@
/**
* @fileoverview Generating Python for text blocks.
*/
'use strict';
goog.module('Blockly.Python.texts');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.Python.texts');
const stringUtils = goog.require('Blockly.utils.string');
const {NameType} = goog.require('Blockly.Names');
const {pythonGenerator: Python} = goog.require('Blockly.Python');
import * as stringUtils from '../../core/utils/string.js';
import {NameType} from '../../core/names.js';
import {pythonGenerator as Python} from '../python.js';
Python['text'] = function(block) {

View File

@@ -7,12 +7,12 @@
/**
* @fileoverview Generating Python for variable blocks.
*/
'use strict';
goog.module('Blockly.Python.variables');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.Python.variables');
const {NameType} = goog.require('Blockly.Names');
const {pythonGenerator: Python} = goog.require('Blockly.Python');
import {NameType} from '../../core/names.js';
import {pythonGenerator as Python} from '../python.js';
Python['variables_get'] = function(block) {

View File

@@ -7,13 +7,12 @@
/**
* @fileoverview Generating Python for dynamic variable blocks.
*/
'use strict';
goog.module('Blockly.Python.variablesDynamic');
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.Python.variablesDynamic');
const {pythonGenerator: Python} = goog.require('Blockly.Python');
/** @suppress {extraRequire} */
goog.require('Blockly.Python.variables');
import {pythonGenerator as Python} from '../python.js';
import './variables.js';
// Python is dynamically typed.