UNPKG

@blockly/block-shareable-procedures

Version:
140 lines 4.74 kB
/** * @license * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ import * as Blockly from 'blockly/core'; import { ObservableParameterModel } from './observable_parameter_model'; /** Represents a procedure signature. */ export declare class ObservableProcedureModel implements Blockly.procedures.IProcedureModel { private readonly workspace; private id; private name; private parameters; private returnTypes; private enabled; private shouldFireEvents; private shouldTriggerUpdates; /** * Constructor for the procedure model. * * @param workspace The workspace the procedure model is associated with. * @param name The name of the new procedure. * @param id The (optional) unique language-neutral ID for the procedure. */ constructor(workspace: Blockly.Workspace, name: string, id?: string); /** * Sets the human-readable name of the procedure. * * @param name The human-readable name of the procedure. * @returns This procedure model. */ setName(name: string): this; /** * Inserts a parameter into the list of parameters. * To move a parameter, first delete it, and then re-insert. * * @param parameterModel The parameter model to insert. * @param index The index to insert it at. * @returns This procedure model. */ insertParameter(parameterModel: ObservableParameterModel, index: number): this; /** * Removes the parameter at the given index from the parameter list. * * @param index The index of the parameter to remove. * @returns This procedure model. */ deleteParameter(index: number): this; /** * Sets whether the procedure has a return value (empty array) or no return * value (null). * This procedure model does not support procedures that have actual * return types (i.e. non-empty arrays, e.g. ['number']). * * @param types Used to set whether this procedure has a return value * (empty array) or no return value (null). * @returns This procedure model. */ setReturnTypes(types: string[] | null): this; /** * Sets whether this procedure is enabled/disabled. If a procedure is disabled * all procedure caller blocks should be disabled as well. * * @param enabled Whether this procedure is enabled/disabled. * @returns This procedure model. */ setEnabled(enabled: boolean): this; /** * Disables triggering updates to procedure blocks until the endBulkUpdate * is called. * * @internal */ startBulkUpdate(): void; /** * Triggers an update to procedure blocks. Should be used with * startBulkUpdate. * * @internal */ endBulkUpdate(): void; /** * @returns The unique language-neutral ID for the procedure. */ getId(): string; /** * @returns The human-readable name of the procedure */ getName(): string; /** * @param index The index of the parameter to return. * @returns the parameter at the given index in the parameter list. */ getParameter(index: number): Blockly.procedures.IParameterModel; /** * @returns an array of all of the parameters in the parameter list. */ getParameters(): Blockly.procedures.IParameterModel[]; /** * Returns the return type of the procedure. * Null represents a procedure that does not return a value. * * @returns the return type of the procedure. */ getReturnTypes(): string[] | null; /** * Returns whether the procedure is enabled/disabled. If a procedure is * disabled, all procedure caller blocks should be disabled as well. * * @returns Returns whether the procedure is enabled/disabled. */ getEnabled(): boolean; /** * Tells the procedure model it should fire events. * * @internal */ startPublishing(): void; /** * Tells the procedure model it should not fire events. * * @internal */ stopPublishing(): void; /** * Serializes the state of the procedure to JSON. * * @returns JSON serializable state of the procedure. */ saveState(): Blockly.serialization.procedures.State; /** * Returns a new procedure model with the given state. * * @param state The state of the procedure to load. * @param workspace The workspace to load the procedure into. * @returns The loaded procedure model. */ static loadState(state: Blockly.serialization.procedures.State, workspace: Blockly.Workspace): ObservableProcedureModel; } //# sourceMappingURL=observable_procedure_model.d.ts.map