![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
@blockv/web-face-sdk
Advanced tools
This is the official BLOCKv Web Face SDK. It allows you to easily build Web Faces which communicate with compatible Vatom Viewers.
This is the official BLOCKv Web Face SDK. It allows you to easily build Web Faces which communicate with compatible Vatom Viewers.
Install from npm
npm install @blockv/web-face-sdk
Import (ES6 & ES7)
import Blockv from '@blockv/web-face-sdk'
Import via script tag
<script src='https://unpkg.com/@blockv/web-face-sdk/dist/web-face-sdk.min.js'></script>
The Web Face SDK provides a simple interface into the underlying Vatom Viewer.
If you would like to access the backing Vatom or interact with the BLOCKv platform in any way, you should start by initializing the SDK.
Trying to access any other features of the SDK prior to initialization will cause an error to be thrown.
Blockv.init()
.then((data) => {
// the SDK is ready to use
return data;
})
.catch((error) => {
// this web code is not being displayed by a BLOCKv viewer
});
By initializing the SDK you allow it to establish a connection with the underlying viewer and gain context of the backing Vatom.
Object containing the data for the backing Vatom. The backing Vatom is the Vatom to which this face belongs, typically, it is Vatom currently being displayed by the viewer.
Trying to access this prior to initializing the SDK will cause an error to be thrown.
Blockv.backingVatom;
This is the data for the selected face being used to display this Vatom.
Trying to access this prior to initializing the SDK will cause an error to be thrown.
Blockv.backingFace;
Respond to updates to the backing Vatom, e.g. state updates, by adding an event listener.
Blockv.backingVatom.addEventListener('update', (vatom) => {
// Vatom is the updated backing vatom
});
Fetch a permitted Vatom by providing its id
.
Restriction: Only the backing Vatom of one of its immediate children may be queried.
Providing an id that is not the backing Vatom or one its immediate children will throw an error.
Blockv.vatomManager
.getVatom(Blockv.backingVatom.id)
.then((vatom) => {
// success
});
Fetch the children of the backing Vatom by providing its id
.
Restriction: Only the backing Vatom may be queried.
Providing an id that is not the backing Vatom will throw an error.
Blockv
.vatomManager
.getChildren(Blockv.backingVatom.id)
.then((children) => {
// children is an array of vatoms
});
Perform an action on a the backing Vatom by providing an action payload.
Restriction: Only permitted on the backing Vatom.
Providing an id that is not the backing Vatom throw an error.
Blockv.vatomManager
.performAction('<action-name>', {
'this.id': Blockv.backingVatom.id, // this.id must match the backing vatom's id
// ... other properties required for the action.
})
.then((response) => {
// success
});
Fetch the public profile of any user by providing their id
.
Blockv.userManager
.getPublicUser(Blockv.backingVatom.properties.owner)
.then((user) => {
// success
})
Fetch the public profile of the current user with additional information regarding their tokens.
Blockv.userManager
.getCurrentUser()
.then((user) => {
// success
})
Allows the Web Face to set the parent ID of the one of the backing vAtoms children. This essentially gives the Web Face the ability to "Split" a child vAtom from the parent's folder.
let parentID = null;
let firstID = null;
return Promise.resolve().then(() => {
parentID = Blockv.backingVatom.properties.propertyData.parent_id;
// find all children
return Blockv.vatomManager.getChildren(Blockv.backingVatom.id);
}).then((children) => {
// sanity check
if (children.length === 0) throw new Error('No child vatom found');
// grab first id
firstID = children[0].id;
// set parent ID
return Blockv.vatomManager.setParentId(firstID, parentID);
}).then(() => {
// parent id update on the child has been requested
})
Allows the Web face to observe changes to the backing Vatom's children.
// add a listener on for child updates
Blockv.init()
.then((data) => {
Blockv.backingVatom.addEventListener('children', this.onBackingVatomChildrenUpdate.bind(this));
}
// function to call
onBackingVatomChildrenUpdate(data) {
// handle changes to the 'vatoms' array containing the backing vatom's children
}
Displaying Vatom resources requires each URL to be encoded with BLOCKv access credentials.
Blockv.resourceManager
.encodeResources(Blockv
.backingVatom
.properties
.resources.map(res => res.value.value))
.then((resources) => {
// resources is an ordered array of encoded urls
})
You are able to send any custom messages to the viewer as follows (note, the message name must be prefixed with viewer.
).
Sending a message with a name not prefixed by
viewer.
will throw an error.
Blockv.sendMessage('viewer.<custom-message>', {/* ... custom data*/})
.then((data) => {
// success
});
You are also able to receive custom messages sent by the viewer.
Blockv.addRequestHandler('viewer.<custom-message>', data => {
// ...
});
All BLOCKv Vatoms apps support the following face messages:
Method | Description |
---|---|
viewer.vatom.show | Request the viewer to engage the specified Vatom. |
viewer.map.show | Request the viewer to shows its map UI. |
viewer.qr.scan | Request the viewer to show a QR scanner and passes back the response to the web app. |
viewer.view.close | Request the viewer to close the current Vatom. |
viewer.scanner.show | Request the viewer to open a scanner and to interpret the scan result itself. |
viewer.card.show | Request the viewer to show the card view mode. |
viewer.url.open | Request the viewer to open the URL. |
viewer.scanner.show | Request the viewer to open the image recognition scanner. |
viewer.action.send | Request the viewer to prompt the user to send the vatom to another user. |
viewer.action.share | Request the viewer to prompt the user to share the vatom to another user. |
BLOCKv is available under the BLOCKv AG license. See the LICENSE file for more info.
FAQs
This is the official BLOCKv Web Face SDK. It allows you to easily build Web Faces which communicate with compatible Vatom Viewers.
The npm package @blockv/web-face-sdk receives a total of 19 weekly downloads. As such, @blockv/web-face-sdk popularity was classified as not popular.
We found that @blockv/web-face-sdk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.