![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Robust, developer-friendly postMessage
.
Burrata has two modes:
Master-slave mode assumes that you've got one master document containing one or more slave iframes that connect to it. This mode also makes it easy to broadcast a message to all slaves.
Peer-to-peer mode sets up communication between exactly two iframes.
In both modes, bidirectional communication is fully supported. Masters, slaves, and peers can all define and invoke commands. The distinction between both modes exists purely to accommodate common use cases.
Just use npm (or Yarn) to install Burrata:
npm install burrata
Under node_modules/burrata
, you'll then find:
dist/burrata.js
: the unminified UMD bundle;dist/burrata.min.js
: the minified UMD bundle;src/*.js
: the ECMAScript 2018 source files.To get started, load dist/burrata.js
using a <script>
tag, which will make
burrata
available on the window
:
<script src="burrata.js"></script>
You can also load the bundles directly from unpkg or use your favorite bundler to build from source.
In both modes, it is recommended that you enter a meaningful value for ns
(namespace) and id
(node identifier) where applicable. In the examples below,
we'll use dummy values.
In the top-level HTML document, create an instance of Master
. Then,
register some command handlers; in this case, we're creating a simple echo
command. Finally, call init()
to start listening for commands from slaves.
const ns = 'testing' // Pick a namespace.
const master = new burrata.Master({ ns })
// Register the "echo" command, which sends back the value of the "msg" arg.
master.setHandler('echo', async ({ msg }) => {
return msg
})
// Start listening for commands.
master.init()
Add an <iframe>
for each slave. Inside the iframe, set up the slave.
const ns = 'testing' // The same namespace as for the master.
const id = 'slave_1' // A unique ID for this slave.
const slave = new burrata.Slave({ ns, id })
// Connect to master.
await slave.init()
Now that everything is wired up, make the slave call its master's echo
command.
const response = await slave.send('echo', { msg: 'Hello!' })
console.log('Response: ' + response)
Slaves can define command handlers using the same setHandler()
function.
Please consult the demo for more examples.
In peer-to-peer mode, you create two instances of burrata.Peer
and await their
init()
call. Like in master-slave mode, you can use setHandler()
to define
commands on peers, and send()
to invoke them.
In most cases, you will also want to pass two additional options to the Peer
constructor, alongside ns
and id
:
source
: the Window
on which message
events for the peer will arive;target
: the Window
on which the peer will call postMessage()
.Both options default to the current window
, which allows two peers to talk to
one another without creating iframes.
To find out more about peer-to-peer mode, please take a look at the demo.
MIT
FAQs
Robust, developer-friendly postMessage.
The npm package burrata receives a total of 2 weekly downloads. As such, burrata popularity was classified as not popular.
We found that burrata demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.