The Exporter bridge object

Many of your plugin's entry point methods receive an argument object named 'exporter'. This is called the "exporter bridge": it allows the plugin to call functions on the Neonto Studio native side.

A plugin can use the exporter bridge functions for tasks like file I/O (e.g. writing source code files into a generated project file); inspecting the Neonto Studio project state; and reporting errors back to the Studio UI.

General utilities

reportError(errorMsg)

Interrupts the export process and reports the message 'errorMsg' back to the user.

getPackageName()

Returns a string containing the package identifier of the app being generated, e.g. "com.neonto.exampleproject".

getProjectObjectId()

Returns a string which is an id for the Neonto Studio project object that is currently being exported. Typically this would be the id for the screen containing the plugin.

escapeStringForSourceCode(str)

Returns a string which is safe to assign to a string object in a source code file for the target language. (E.g. if the target language is Java, this method will escape all double-quotes because that's the delimiter for string constants in Java.)

Writing files into the exported project

writeSourceCode(file, text)

Writes the string 'text' to a source code file named 'file'.

writeImageAsset(name, srcPath)

Writes an image asset named 'name' from an image file at path 'srcPath'. The path would typically come from the plugin's resources. The format is assumed to be PNG.

writeVideoAsset(name, srcPath)

Writes a video asset named 'name' from an image file at path 'srcPath'. The path would typically come from the plugin's resources.

writeCustomAsset(srcPath)

Writes a custom asset for a file at path 'srcPath'. This is typically a resource file being included in the generated project(s).

writeArchive(dstPath, src)

Write an archive (a .zip file) to a specified project path. src-parameter can be a path to a file or a byte buffer object when used with methods such as HttpClient.load().

registerFontNamed(fontName)

Registers the font 'fontName' for inclusion into the generated project(s).

When a font is registered, Neonto Studio will try to discover a font by that name by looking up the font on the Mac. If found, the font file will be copied into the generated project(s).

Code generation setup

getObjCImports()

For use in iOS code generation.

Returns a string containing #import lines that should be added at the top of any generated class. (The imports could be e.g. for data sheet classes referenced by the plugin.)

getPropertyDeclsForLinkedElements()

For use in both iOS and Android code generation.

Returns an array containing property/field declarations that should be added into the interface of any generated class. These properties are accessed at runtime to fill out references to other elements within the Studio project.

If the plugin's UI doesn't include any element link parameters, then this function doesn't need to be called. It's only needed for resolving references to other elements.

For the ReactJS equivalent, see below under 'Specific to ReactJS'.

Accessing data slots / sheets

valueAccessForDataSlotByName(dataSlotName)

Supported by all targets.

Returns a string containing code that can be used to access a data slot by the name 'dataSlotName'.

The code is an expression that can be used as a right-side value in your plugin code (for example, it might be something along the lines of "AppDelegate.dataSlotFooBar").

(A deprecated alias for this method is 'propertyAccessForDataSlotByName').

valueAccessForDataSheetByName(dataSheetName)

Returns a string containing code that can be used to access a data sheet by the name 'dataSheetName'.

The code is an expression that can be used as a right-side value in your plugin code (for example, it might be something along the lines of "AppDelegate.dataSheetFooBar").

(A deprecated alias for this method is 'propertyAccessForDataSheetByName').

setValueCodeForDataSlotByName(dataSlotName, expr)

Returns a string containing code that sets the value of a data slot by the name 'dataSlotName' to the value specified by 'expr'.

Use this to update a data slot's value in your plugin code.

Code generation for async actions

writeActionFinishedCode()

For use in both iOS and Android code generation.

Returns a string containing code that should be executed when an async interaction has finished. (Typically this might be a callback that executes the next interaction specified by the user in Neonto Studio.)

writeActionCanceledCode()

For use in both iOS and Android code generation.

Returns a string containing code that should be executed when an async interaction has been cancelled.

writeLoadImageFromDataSheetCode(dataSheetVar, dataSheetRow, columnName)

For use in both iOS and Android code generation.

Returns a string containing code that asynchronously loads an image using a value in a data sheet.

The value within the data sheet is specified using the 'dataSheetRow' (an integer) and 'columnName' (a string) parameters. The code generated by this call will check the value in the data sheet at that cell, and will execute an async load if the value is a suitable URL or asset reference.

Getting info about other project objects

classNameForDataSheetByName(dataSheetName)

Supported by all targets.

Returns a string which is a generated class name for a corresponding data sheet block.

classNameForScreenByName(screenName)

Supported by all targets.

Returns a string which is a generated class name for a corresponding screen block (in Android a fragment class name).

varNameForDataSlotByName(dataSlotName)

Supported by all targets.

Returns a string which is a generated variable name for a corresponding data slot block.

varNameForDataSheetByName(dataSheetName)

Supported by all targets.

Returns a string which is a generated variable name for a corresponding data sheet block.

Specific to ReactJS target

classNameForComponentByName(compName)

Returns a string which is a generated class name for the corresponding component block.

valueAccessForElementById(elementId)

Returns a string containing code that can be used to access an element 'elementId'.

The code is an expression that can be used as a right-side value in your plugin code (for example, it might be something along the lines of "foo.refs.elementId").

valueAccessForDataSlotsAsMap()

Returns a JS object containing the values for all data slots indexed by the data slot names as property keys.

idForScreenByName(screenName)

Returns a string which can be used as a navigation lookup id for the screen block.

getExpressionForLinkKey(linkKey)

Returns a string containing code that can be used to access a dynamic data value for the plugin's data linkage with key 'linkKey'.

For example, a plugin that has dynamic content might expose two data linkage keys 'text' and 'image'. (Note that these keys must be declared by the plugin as an array using the entry point reactWebDataLinkKeys.) The user in the Studio host app can then link these values to e.g. data slots or a component's properties.

During its code generation, the plugin should use this method to get the dynamic values. The code is an expression that can be used as a right-side value in your plugin code, so you can store it in a local variable and use that in your code generation.

getCallbackForInteractEvent(interactionId)

Returns a string containing a reference to a method that will be available on the exported component (could be something like "this.valueChanged"). This should be set as the callback for custom interactions in a nested component. Typically you'd set this call's return value as the value of a prop in a nested component, something like onChange={<this method's return value>}.

The parameter interactionId must be a Studio UI interaction type declared by your plugin using the entry point reactWebInteractEventsForStudioUI (see Element; that documentation contains more discussion on the rationale and use cases for this API).

getLoginGateSuccessCode()

Returns a string containing code that should be executed if a login action is successful.

getLoginGateFailureCode()

Returns a string containing code that should be executed if a login action fails.

Specific to Android target

activityClassNameForScreenByName(screenName)

For use in Android code generation.

Returns a string which is a generated activity class name for a corresponding screen block (as opposed to classNameForScreenByName(screenName) function which returns a fragment class name).

getAndroidApplicationClassName()

For use in Android code generation.

Returns a string which is a generated class name for the Application subclass in the generated Android Studio project.

Specific to iOS target

getIOSAppDelegateClassName()

For use in iOS code generation.

Returns a string which is a generated class name for the implementation of the generated Xcode project's UIApplicationDelegate protocol.