"use strict";
const UI = activate require("@syndicate-lang/driver-browser-ui");
// @jsx UI.html
// @jsxFrag UI.htmlFragment
const { ToBroker, FromBroker, BrokerConnected } = activate require("./client");
assertion type ConnectionName(scope, id);
assertion type Connection(connId);
message type Disconnect(connId);
spawn {
const ui = new UI.Anchor();
assert ui.html('body',
);
const url = (function () {
const u = new URL(document.location);
u.protocol = u.protocol.replace(/^http/, 'ws');
u.pathname = '/monitor';
return u.toString();
})();
during BrokerConnected(url) {
during FromBroker(url, Connection(ConnectionName($scope, _))) {
const ui = new UI.Anchor();
assert ui.html('#scopes',
);
during FromBroker(url, Connection(ConnectionName(scope, $id))) {
const ui = new UI.Anchor();
assert ui.html(`#scopes div.scope_${scope} ul`,
{id.toString()} );
on message UI.UIEvent(ui.fragmentId, 'button.disconnect', 'click', _) {
send ToBroker(url, Disconnect(ConnectionName(scope, id)));
}
}
}
}
}