@knapsack/app
Version:
Build Design Systems on top of knapsack, by Basalt
39 lines (33 loc) • 1.24 kB
JavaScript
System.register([], function (exports, module) {
'use strict';
return {
execute: function () {
var metaTag = document.getElementById('ks-meta');
var metaString = metaTag.innerText;
var meta = JSON.parse(metaString); // console.log(`got ks meta!`, meta);
var isInIframe = meta.isInIframe,
websocketsPort = meta.websocketsPort; // if (!isInIframe && websocketsPort) {
if (websocketsPort) {
if ('WebSocket' in window && window.location.hostname === 'localhost') {
var socket = new window.WebSocket("ws://localhost:".concat(websocketsPort));
socket.addEventListener('message', function () {
window.location.reload();
});
}
}
if (isInIframe) {
/**
* Prevents the natural click behavior of any links within the iframe.
* Otherwise the iframe reloads with the current page or follows the url provided.
*/
var links = document.querySelectorAll('a');
links.forEach(function (link) {
link.addEventListener('click', function (e) {
e.preventDefault();
});
});
module.import('./setup-iframe-94cce5b3.js');
}
}
};
});