Skip to content

Commit 2d7ec49

Browse files
cpcallenericblackmonGoogle
authored andcommitted
fix: Restore HSV_SATURATION and HSV_VALUE accessors and deprecate (#7249)
* fix: Restore HSV_SATURATION and HSV_VALUE accessors Contrary to the notice at the top of the `Object.defineProperties` call, these were not actually marked as deprecated, and their removal in Blockly 10.0.0 constituted an avoidable zero-notice breaking change. * deprecate: Add deprecation notices for HSV_SATURATION and HSV_VALUE DEPRECATION: Blockly.HSV_SATURATION and Blockly.HSV_VALUE are deprecated and will be removed in a future version of Blockly. Use Blockly.colour.getHsvSaturation / Blockly.colour.setHsvSaturation and Blockly.colour.getHsvValue / Blockly.colour.setHsvValue instead. (cherry picked from commit a677355)
1 parent d832085 commit 2d7ec49

1 file changed

Lines changed: 72 additions & 2 deletions

File tree

core/main.js

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,79 @@
1313

1414
goog.module('Blockly.main');
1515

16-
/** @suppress {extraRequire} */
17-
goog.require('Blockly');
16+
const Blockly = goog.require('Blockly');
1817
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+
});
1989

2090
// If Blockly is compiled with ADVANCED_COMPILATION and/or loaded as a
2191
// CJS or ES module there will not be a Blockly global variable

0 commit comments

Comments
 (0)