diff --git a/app/blocks/power_ups/weather.js b/app/blocks/power_ups/weather.js index de6e3e7..49f26d2 100644 --- a/app/blocks/power_ups/weather.js +++ b/app/blocks/power_ups/weather.js @@ -1,12 +1,12 @@ import weatherMixin from "./weather_mixin.js" - const { keyToLabel, HELP_TEXT_BY_PROP: propText } = weatherMixin, propLines = (prefix, props) => props.map(prop => `${prefix}- \`${keyToLabel(prop)}\`: ${propText[prop].description}`).join("") +/** @type {import('#types').BlockDefinitionRaw} */ export default { type: "weather", bytecodeKey: "weather", @@ -36,6 +36,7 @@ export default { weatherLocationOptions.unshift([ "Select Location", "" ]) } + // @ts-ignore block.replaceDropdownOptions("POWER_UP_ID", weatherLocationOptions) // skip the rest if we're in the toolbox @@ -46,16 +47,16 @@ export default { // nope out for insertion markers if(block.isInsertionMarker()) { return } - // auto-disable block, if necessary + // @ts-ignore auto-disable block, if necessary block.setEnabledByLocation() // react to incoming forecast data const unobserve = observeData('currentWeatherByLocation', (newData = {}) => { // if this block is disposed, clean up this listener if (block.isDisposed()) { unobserve(); return } - // update the reference to the injected/updated extension data + // @ts-ignore update the reference to the injected/updated extension data block.currentWeatherByLocation = newData - // re-run the things that use the data + // @ts-ignore re-run the things that use the data block.refreshPropertyOptions({}) }) }, 1) diff --git a/app/types.js b/app/types.js index cae964e..2a29686 100644 --- a/app/types.js +++ b/app/types.js @@ -11,6 +11,8 @@ /** * @typedef {object} BlockExtensionFunctionInjectable * @prop {Blockly.Block} block + * @prop {function} observeData + * @prop {object} data */ /** @@ -22,6 +24,14 @@ * @typedef {Object.} BlockExtensions */ +/** + * @typedef {string|object} BlocklyMixin + */ + + /** + * @typedef {BlocklyMixin[]} BlockMixins + */ + /** * @callback BlockGenerator * @param {Blockly.Block} block @@ -66,13 +76,16 @@ * @prop {string=} primaryCategory For blocks appearing in multiple categories, * this property determines which menu this block will appear under in the * docs. + * @prop {boolean=} ioPlus Indicates this block requires an IO+ account. * @prop {string} description Markdown documentation for this block. The first * line will be automatically set as the Block's tooltip. * @prop {BlockConnections} connections * @prop {BlockExtensions=} extensions + * @prop {BlockMixins=} mixins * @prop {string} template * @prop {object=} fields * @prop {object=} inputs * @prop {BlockGenerators=} generators * @prop {BlockRegenerators=} regenerators + * @prop {object=} docOverrides */