UNPKG

@eagleoutice/flowr-dev

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

56 lines 3.86 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LinkedInputEntryPoints = exports.LinkedInputObjects = void 0; exports.narrowingFunctions = narrowingFunctions; const identifier_1 = require("../../../dataflow/environments/identifier"); const simple_input_classifier_1 = require("./simple-input-classifier"); const built_in_props_1 = require("../../../dataflow/environments/built-in-props"); const query_fn_props_1 = require("../../../dataflow/environments/query-fn-props"); /** shiny's ui-side control widgets, all taking the id of the `input` entry they feed as their first argument */ const ShinyInputWidgets = { argName: 'inputId', argIdx: 0, calls: identifier_1.Identifier.fromAll("shiny" /* PkgName.Shiny */, [ 'actionButton', 'actionLink', 'checkboxInput', 'checkboxGroupInput', 'dateInput', 'dateRangeInput', 'fileInput', 'numericInput', 'passwordInput', 'radioButtons', 'selectInput', 'selectizeInput', 'sliderInput', 'submitButton', 'textAreaInput', 'textInput', 'varSelectInput', 'varSelectizeInput' ]) }; /** * Objects that a framework binds for its users, without a definition visible in the code. * The `withParams` and `requires` guards keep ordinary functions that happen to have a parameter of the same * name out of this; where the framework is handed the function, {@link LinkedInputEntryPoints} is exact instead. * @see {@link LinkedInputObject} */ exports.LinkedInputObjects = [ /* shiny hands the server function its reactive `input` and `session` objects */ { name: 'input', type: simple_input_classifier_1.InputType.User, withParams: ['output'], requires: 'shiny', declaredBy: ShinyInputWidgets }, /* of the session only what the browser sends is user input, `userData` and `token` are the app's own */ { name: 'session', type: simple_input_classifier_1.InputType.User, withParams: ['input', 'output'], requires: 'shiny', fields: ['clientData', 'request'] } ]; /** * The functions whose result is bounded no matter what flows in, read back from the {@link CallProp.Narrows} * built-ins: with an {@link ArgProp.Bounds} parameter the result is one of that argument's values (`match.arg` * and its `choices`), without one it is a count, an index, or a logical of the call's own making. Label a * built-in `Narrows` (in the {@link DefaultBuiltinConfig} or your own definitions) and it shows up here. */ function narrowingFunctions(index = query_fn_props_1.BuiltInIndex.default()) { const bounds = new Map(index.params(built_in_props_1.ArgProp.Bounds).map(p => [identifier_1.Identifier.getName(p.call), p])); return index.with(built_in_props_1.CallProp.Narrows).map(call => { const bound = bounds.get(identifier_1.Identifier.getName(call)); return bound === undefined ? { call } : { call, argName: bound.name, argIdx: bound.index }; }); } /** shiny binds `input`, `output`, and `session` positionally, so their names are up to whoever writes the server */ const ShinyServerParams = ['input', undefined, 'session']; /** * Calls that hand a function to a framework which binds its parameters by position. * @see {@link LinkedInputEntryPoint} */ exports.LinkedInputEntryPoints = [ { call: identifier_1.Identifier.from(['shinyApp', "shiny" /* PkgName.Shiny */]), argName: 'server', argIdx: 1, params: ShinyServerParams }, { call: identifier_1.Identifier.from(['shinyServer', "shiny" /* PkgName.Shiny */]), argName: 'func', argIdx: 0, params: ShinyServerParams }, { call: identifier_1.Identifier.from(['moduleServer', "shiny" /* PkgName.Shiny */]), argName: 'module', argIdx: 1, params: ShinyServerParams }, { call: identifier_1.Identifier.from(['callModule', "shiny" /* PkgName.Shiny */]), argName: 'module', argIdx: 0, params: ShinyServerParams } ]; //# sourceMappingURL=input-source-functions.js.map