Bring Your Own (BYO) Component SDK
Overview
Bring Your Own (BYO) Component enables Creators Also known as Unqork Users, or Designer Users; is anyone who is inside the Unqork platform. to create new components or configure existing custom components using Unqork's External Component V1 SDK (Software Development Kit).
This feature is intended for Unqork configurators who have a strong understanding of the Unqork Designer Platform.
External Component SDK Design Principles
The External Component SDK is designed as a guideline for Creators to create their own components. The SDK supports the following design principles:
-
Minimal Surface Area: Expose only essential interfaces to prevent unintended modifications.
-
Encapsulation: Protect internal state and logic from direct access.
-
Extensibility: Provide a structured way to introduce new components.
-
Security & Stability: Ensure external plugins cannot compromise the core system.
Core Architecture of a Web Component
To register and render third-party components in Unqork, it must be a valid web component as defined by MDM Web Docs: https://developer.mozilla.org/en-US/docs/Web/API/Web_components.
Here is an example of a basic web component:
export class CustomComponent extends HTMLElement {
initialize(config, api) {
/* Insert Component Configuration Logic Here */
}
connectedCallback() {
this.innerHTML = `<h1 id="heading">I'm custom component</h1>`
}
}
export default CustomComponent
This web component is the default export from a module and uses the initialize method to interact with the Unqork runtime.
Configuring the initalize Method for Custom Unqork Components
The initialize method enables the Web Component to be rendered in Unqork Express View. Two parameters are required for the method: config and api.
Using the config Parameter
The config parameter provides the initial configuration for a component.
The example below contains a component's properties that can be referenced in the config parameter:
{
"key": "myComponent",
"type": "byoc",
"name": "jm-byoc-component-tiiny",
"url": "https://palbyo.tiiny.site/palBYOL.js",
"args": {
"text": "textfieldA",
"color": "textFieldColor" // These are propertyNames of components.
},
"signature": "",
}
To view more examples of config parameter implementation, view our BYO 7.22 Implementation Examples and BYO 7.24 Implementation Examples articles.
Line 6: args
The most important information is the args object containing Creator-defined props with static values in the Unqork Designer Platform. The args are defined by the Creator in the Custom Assets Admin screen for a BYO component. This Admin screen stores the value of what's mapped in the configuration to your component. Doing so helps customize a component depending on the module or use case.
For example, you can change text color for a component (create textColor) or specify a component key that stores data to display a table (create dataComponentKey):
config.args.textColor
config.args.dataComponentKey
Using the api Parameter
Unqork provides the api service to expose Unqork features. In the example below, the state object displays multiple methods to manipulate a custom component:
interface UnqorkAPI {
state: {
set(state: ComponentState) => void
currentState() => ComponentState
state$(path: string, includeInitialValue: boolean) => Observable<ComponentState>
updateExternalComponentState(key: string, update: Partial<ComponentState>) => void
resolveByKey(key: string) => ComponentState
resolveByKey$(key: string) => Observable<ComponentState>
},
events: {
emit(event: Event) => void
}
}
To view more examples of api parameter implementation, view our BYO 7.22 Implementation Examples and BYO 7.24 Implementation Examples articles.
In the above example, each method performs a different function:
Line | Method | Description | Example |
---|---|---|---|
3 |
set(state: ComponentState) => void |
Updates the state of the BYO component. This can be a partial object. |
Copy
|
4 |
currentState() => ComponentState |
Gets the current state of the BYO component |
Copy
|
5 |
state$(path: string, includeInitialValue: boolean) => Observable<ComponentState> |
Gets a stream of state updates, you can specify if you want to receive the initial value |
Copy
|
6 |
updateExternalComponentState(key: string, update: Partial<ComponentState>) => void |
Updates the state of any component in a module with a partial object |
Copy
|
7 |
resolveByKey(key: string) => ComponentState |
Gets the current state of any component in the module |
Copy
|
8 |
resolveByKey$(key: string) => Observable<ComponentState> |
Gets the stream of state updates of any component in the module |
Copy
|
11 |
emit(event: Event) => void |
Dispatches an event from the BYO component, which can be configured in the Unqork Designer Platform for defining operations that should execute based on it. |
Copy
|
Resources
Introduction to the Bring Your Own (BYO) Framework
Create a BYO Package
Understanding the manifest.json File
Learn about the file's specification, component and event definitions.
Understanding the BYO Runtime Engine API
Discover the interface between your custom BYO components and the Unqork platform.
Custom Component
Understand the state, interface, and events of a custom component.
BYO 7.22 Implementation Examples
Discover examples of component implementation using the 7.22 Unqork Designer Platform.
BYO 7.24 Implementation Examples
Discover examples of component implementation using the 7.24 Unqork Designer Platform.
Host External Assets Using a CDN (Content Delivery Network) Setup
Learn about setting up Express roles and managing permissions.
BYO Best Practices
Learn about best practices for implementing and using BYO assets.