Composition (Components)
Blocklets can be composed of other blocklets, creating modular and powerful applications. This composition is managed through the components
property in blocklet.yml
, which allows you to define other blocklets as dependencies.
The runtime environment uses this information to build a dependency tree, ensuring that all required components are installed and running before the parent blocklet starts. This enables the creation of complex applications from smaller, single-purpose, and reusable parts.
The components
Property#
The components
property is a top-level key in blocklet.yml
that accepts an array of component objects. Each object in the array defines a child blocklet that the current blocklet depends on.
Component Object Schema#
Each object within the components
array defines a single dependency and its configuration.
Field | Type | Required | Description |
---|---|---|---|
|
| Yes | Defines where to fetch the component blocklet from. See |
|
| No | If |
|
| No | A suggested title for the component instance when presented to the user. The user can override this during setup. |
|
| No | A suggested description for the component instance. |
|
| No | A suggested mount point (URL path) for the component instance. |
The source
Property#
The source
object is mandatory for each component and specifies its origin. It can be configured in two primary ways: sourcing from a URL or sourcing from a Blocklet Store.
Sourcing from a Blocklet Store#
This is the recommended method, as it leverages a registry for versioning, discovery, and management.
Field | Type | Required | Description |
---|---|---|---|
|
| Yes | The URI of the blocklet store or registry. |
|
| Yes | The name of the component blocklet in the store. |
|
| No | A semantic version range (e.g., |
Example:
components:
- source:
store: 'https://store.arcblock.io'
name: 'did-wallet-provider'
version: '^1.18.0'
required: true
title: 'DID Wallet Provider'
description: 'Provides DID authentication services.'
mountPoint: '/wallet'
Sourcing from a URL#
This method allows you to specify a direct URL to a component's distributable package. This is useful for development, private components, or when a Blocklet Store is not available.
Field | Type | Required | Description |
---|---|---|---|
|
| Yes | A direct URI to the component's tarball. An array of URIs can be provided for fallback purposes. |
|
| No | A semantic version range (e.g., |
Example:
components:
- source:
url: 'https://github.com/arcblock/did-connect/releases/download/v1.0.0/blocklet.tgz'
version: '^1.0.0'
required: true
Full components
Example#
Here is a complete example demonstrating how to define multiple components with different sources and requirements.
did: z8iZpLARDM1b62J1az1iFAoA9g4Ejo69xWj1Z
name: my-web-app
version: 1.2.0
title: My Web Application
description: A web application built from several blocklet components.
components:
# A required component from a blocklet store
- source:
store: 'https://store.arcblock.io'
name: 'blog-engine'
version: '3.x'
required: true
title: 'Main Blog'
description: 'The primary blog for the application.'
mountPoint: '/blog'
# An optional component sourced from a direct URL
- source:
url: 'https://example.com/downloads/analytics-widget-v2.1.0.tgz'
version: '^2.1.0'
required: false
title: 'Analytics Widget'
# A required foundational service
- source:
store: 'https://store.arcblock.io'
name: 'auth-service'
version: '>=2.0.0 <3.0.0'
required: true
title: 'Authentication Service'
After defining how your blocklet is composed of other blocklets, the next step is to configure its own contributions to the user interface. Proceed to the UI & Theming section to learn about the navigation
and theme
properties.