|
13 | 13 |
|
14 | 14 | goog.module('Blockly.main'); |
15 | 15 |
|
16 | | -/** @suppress {extraRequire} */ |
17 | | -goog.require('Blockly'); |
| 16 | +const Blockly = goog.require('Blockly'); |
18 | 17 | const Msg = goog.require('Blockly.Msg'); |
| 18 | +const colour = goog.require('Blockly.utils.colour'); |
| 19 | +const deprecation = goog.require('Blockly.utils.deprecation'); |
| 20 | + |
| 21 | +/* |
| 22 | + * Aliased functions and properties that used to be on the Blockly namespace. |
| 23 | + * Everything in this section is deprecated. Both external and internal code |
| 24 | + * should avoid using these functions and use the designated replacements. |
| 25 | + * Everything in this section will be removed in a future version of Blockly. |
| 26 | + */ |
| 27 | + |
| 28 | +// Add accessors for properties on Blockly that have now been deprecated. |
| 29 | +Object.defineProperties(Blockly, { |
| 30 | + /** |
| 31 | + * The richness of block colours, regardless of the hue. |
| 32 | + * Must be in the range of 0 (inclusive) to 1 (exclusive). |
| 33 | + * @name Blockly.HSV_SATURATION |
| 34 | + * @type {number} |
| 35 | + * @deprecated Use Blockly.colour.getHsvSaturation() / .setHsvSaturation( |
| 36 | + * instead. (July 2023) |
| 37 | + * @suppress {checkTypes} |
| 38 | + */ |
| 39 | + HSV_SATURATION: { |
| 40 | + get: function () { |
| 41 | + deprecation.warn( |
| 42 | + 'Blockly.HSV_SATURATION', |
| 43 | + 'version 10', |
| 44 | + 'version 11', |
| 45 | + 'Blockly.colour.getHsvSaturation()' |
| 46 | + ); |
| 47 | + return colour.getHsvSaturation(); |
| 48 | + }, |
| 49 | + set: function (newValue) { |
| 50 | + deprecation.warn( |
| 51 | + 'Blockly.HSV_SATURATION', |
| 52 | + 'version 10', |
| 53 | + 'version 11', |
| 54 | + 'Blockly.colour.setHsvSaturation()' |
| 55 | + ); |
| 56 | + colour.setHsvSaturation(newValue); |
| 57 | + }, |
| 58 | + }, |
| 59 | + /** |
| 60 | + * The intensity of block colours, regardless of the hue. |
| 61 | + * Must be in the range of 0 (inclusive) to 1 (exclusive). |
| 62 | + * @name Blockly.HSV_VALUE |
| 63 | + * @type {number} |
| 64 | + * @deprecated Use Blockly.colour.getHsvValue() / .setHsvValue instead. |
| 65 | + * (July 2023) |
| 66 | + * @suppress {checkTypes} |
| 67 | + */ |
| 68 | + HSV_VALUE: { |
| 69 | + get: function () { |
| 70 | + deprecation.warn( |
| 71 | + 'Blockly.HSV_VALUE', |
| 72 | + 'version 10', |
| 73 | + 'version 11', |
| 74 | + 'Blockly.colour.getHsvValue()' |
| 75 | + ); |
| 76 | + return colour.getHsvValue(); |
| 77 | + }, |
| 78 | + set: function (newValue) { |
| 79 | + deprecation.warn( |
| 80 | + 'Blockly.HSV_VALUE', |
| 81 | + 'version 10', |
| 82 | + 'version 11', |
| 83 | + 'Blockly.colour.setHsvValue()' |
| 84 | + ); |
| 85 | + colour.setHsvValue(newValue); |
| 86 | + }, |
| 87 | + }, |
| 88 | +}); |
19 | 89 |
|
20 | 90 | // If Blockly is compiled with ADVANCED_COMPILATION and/or loaded as a |
21 | 91 | // CJS or ES module there will not be a Blockly global variable |
|
0 commit comments