Comments (1)
The message protocol has changed to send Webnative state on connect and disconnect messages. In addition, data messages have been have been broken into filesystem and session messages.
Messages
Messages are sent from Webnative to the extension as window post messages. When the extension initially connects, it configures Webnative with an extension ID which is used to tag all messages sent to the extension. The tag lets the extension filter window post messages to only receive messages intended for it.
State
Each message includes some information about the state of Webnative:
type State = {
app: {
namespace: AppInfo | string
capabilities?: Permissions
}
fileSystem: {
dataRootCID: string | null
}
user: {
username: string | null
accountDID: string | null
agentDID: string
}
odd: {
version: string
}
}
Updated on April 21st, 2023.
Connect message
The extension calls a connect function that is added to the global object (e.g. window
) by Webnative. When the connect function is called, Webnative sends a connect message to the extension:
globalThis.postMessage({
id: extensionId,
type: "connect",
timestamp: 1678487975,
state
})
Disconnect message
The extension calls a disconnect function when it does not need messages to be sent from Webnative:
globalThis.postMessage({
id: extensionId,
type: "disconnect",
timestamp: 1678487975,
state
})
Session messages
Webnative sends session create and destroy messages to the extension. Each message contains a detail field that includes the username and indicates the message type:
globalThis.postMessage({
id: extensionId,
type: "session",
timestamp: 1678487975,
state,
detail: {
type: "create",
username
}
})
globalThis.postMessage({
id: extensionId,
type: "session",
timestamp: 1678487975,
state,
detail: {
type: "destroy",
username
}
})
File system messages
Webnative sends filesystem local-change and publish messages to the extension. Each message contains a detail field that includes the root CID, path on local-change, and indicates the message type:
globalThis.postMessage({
id: extensionId,
type: "filesystem",
timestamp: 1678487975,
state,
detail: {
type: "local-change",
root: "<root-cid>",
path
}
})
globalThis.postMessage({
id: extensionId,
type: "filesystem",
timestamp: 1678487975,
state,
detail: {
type: "publish",
root: "<root-cid>"
}
})
from odd-devtools.
Related Issues (20)
- Reconnect on page load HOT 1
- Store messages in extension storage
- Duplicate devtools panels created in Firefox
- Hide connect and disconnect messages
- Implement text-based filtering
- Set not connected status when Webnative not available
- Publish to Chrome Web Store and Firefox Add-ons HOT 2
- Bind up/down arrows to quickly browse through event
- Add "copy raw response" for events
- The UI scales naively
- Add theming that updates with devtools toolbox theme HOT 1
- Add ODD SDK Not Connected view
- Update theme
- Messages are not displayed when multiple tabs are open
- Add project description and privacy policy
- Add Firefox extension ID
- Detect if the user has enabled the optional permissions HOT 4
- Firefox displays not connected view incorrectly
- Improve time direction indication HOT 3
- Improve state information in event payloads HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from odd-devtools.