Subchapter 1.161
references/function-library/FUNCTION_LIBRARY_SPEC.mdMarkdown8 KBView on GitHub
Complete specification for the EditorFunctionLibrary manifest and all related types.
Defines a library of reusable functions that can be called from the Wix editor and runtime. Each library has a unique type identifier, a collection of function definitions, and a pointer to the runtime bundle that exports the implementations.
| Key | Type | Description | Constraints |
|---|---|---|---|
| id | string (UUID v4) | Unique identifier for this function library. Generated by wix generate; keep it as scaffolded | Required |
| type | string | A unique type identifier for the function library. Uses the codeIdentifier as a prefix and the lib name as a suffix (e.g., myApp.stringUtils) | Required, maxLength: 100 |
| functions | map<string, Function> | The function definitions exposed by this library. Each key is the function name and must exactly match the corresponding named export in the library bundle | Required |
| resources | FunctionResources | The bundle information for runtime | Required |
| name | string | The display name of the library for human readability, shown as its Source name in the editor. Always set it — without it the editor shows the raw type | Required by this skill (optional in the schema), maxLength: 100, translatable |
| description | string | A description of the library’s main use cases | Optional, maxLength: 100, translatable |
Defines the runtime resources needed to load and execute the function library.
| Key | Type | Description | Constraints |
|---|---|---|---|
| client | Resource | The ESM bundle resource for this function library in runtime | Required |
| moduleSpecifier | string | The module specifier for this library. Unique across all of Wix, so it must be <moduleSpecifierPrefix><library-name> (@/ by default, or the prefix the user gives you). Cannot be renamed once registered | Required, must start with <moduleSpecifierPrefix>; maxLength: 100 |
A resource specifier of where to load the ESM bundle from.
| Key | Type | Description | Constraints |
|---|---|---|---|
| url | string (URL) | The URL to the ESM bundle | Required |
Defines a single function with its parameters, return type, and execution characteristics.
| Key | Type | Description | Constraints |
|---|---|---|---|
| parameters | FunctionParameter[] | The parameters expected by the function. Can be empty for functions with no parameters | Optional, maxSize: 10 |
| returns | FunctionReturnType | The return type of the function. Omit for void return | Optional |
| async | bool | Whether the function returns a promise with the type of the result | Optional |
| displayName | string | The display name of the function for panels | Optional, maxLength: 100, translatable |
| description | string | The description of the function for human readability | Optional, maxLength: 100, translatable |
Defines a function parameter with its data type and optional structure.
A parameter is either a data parameter (specified via dataType) or a DOM event parameter (specified via domEvent). Exactly one of dataType or domEvent must be set.
| Key | Type | Description | Constraints |
|---|---|---|---|
| dataType | DataType | The type of the parameter | Oneof: exactly one of dataType or domEvent is required |
| domEvent | DomEventType | The DOM event type for this parameter | Oneof: exactly one of dataType or domEvent is required |
| optional | bool | Whether the parameter is optional. Due to JavaScript limitations, only the last parameters can be optional. Default is false | Optional |
| defaultValue | Value | The default value for this parameter, only for display purposes in the editor — will not be passed to the function | Only when optional is true |
| displayName | string | The display name of the parameter for human readability | Optional, maxLength: 100, translatable |
| description | string | The description of the parameter for human readability | Optional, maxLength: 100, translatable |
| arrayItems | FunctionParameterArrayItems | Array type definition | Only when dataType is arrayItems |
| data | FunctionParameterItems | Complex object structure | Only when dataType is data |
| function | Function | Callback function definition | Only when dataType is function |
| textEnum | TextEnum | List of enum options | Only when dataType is textEnum |
| changeEvent | ChangeEvent | Definition of the input type for this change event | Only when domEvent is CHANGE |
Note: The same Disallowed Data Types apply to function parameters.
DOM event types that a function parameter can receive instead of a data value.
| Value | DOM Event | Use When Your Function Handles… |
|---|---|---|
| POINTER | PointerEvent | Clicks, taps, drag starts, hover actions |
| CHANGE | Event (change) | Value changes in inputs, selects, checkboxes |
| KEYBOARD | KeyboardEvent | Key presses, key releases, shortcuts |
| FOCUS | FocusEvent | Focus and blur on interactive elements |
| SUBMIT | SubmitEvent | Form submissions |
When domEvent is CHANGE, the optional changeEvent enhancement declares where the meaningful value resides in the event object.
| Key | Type | Description | Constraints |
|---|---|---|---|
| inputType | InputType | The type of input this change event originates from, determines where the value resides and what type it is | Optional |
| Value | Path to Value | Value Type | Used For |
|---|---|---|---|
| text | target.value | string | Text inputs, selects, sliders, search boxes |
| checkbox | target.checked | boolean | Checkboxes, toggles, switches |
| number | target.valueAsNumber | number | Number inputs, range inputs |
| date | target.valueAsDate | Date | Date pickers, datetime inputs |
Defines the return type of a function with its data type and optional structure.
| Key | Type | Description | Constraints |
|---|---|---|---|
| dataType | DataType | The type of the return value | Required |
| displayName | string | The display name of the return type for human readability | Optional, maxLength: 100, translatable |
| description | string | The description of the function return type for human readability | Optional, maxLength: 100, translatable |
| textEnum | TextEnum | List of enum options | Only when dataType is textEnum |
| arrayItems | FunctionParameterArrayItems | Array type definition | Only when dataType is arrayItems |
| data | FunctionParameterItems | Complex object structure | Only when dataType is data |
Note: The same Disallowed Data Types apply to function return types. DOM event types are NOT allowed as return types.
Defines the structure of a complex object type used in function parameters or return types. For arrays of complex objects, each item in the array will contain this data structure.
| Key | Type | Description | Constraints |
|---|---|---|---|
| items | map<string, FunctionParameter> | Map of function parameters that define the structure of the complex object. Each key is the property name | Required |
Defines the structure of array items in function parameters or return types. Specifies the type of data inside the array using a FunctionParameter, which can represent simple types, complex objects, or nested arrays.
| Key | Type | Description | Constraints |
|---|---|---|---|
| item | FunctionParameter | Specifies the type of data inside the array | Required |
| Key | Type | Description | Constraints |
|---|---|---|---|
| options | Option[] | List of valid enum items | Required, maxSize: 100 |
Each option:
| Key | Type | Description | Constraints |
|---|---|---|---|
| value | string | Actual text value | Required, maxLength: 100, unique |
| displayName | string | Display name | Optional, maxLength: 100, translatable |