-
Notifications
You must be signed in to change notification settings - Fork 9
/
webpack.entry.js
51 lines (46 loc) · 1.58 KB
/
webpack.entry.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const postMessageRuntime = require('noflo-runtime-postmessage');
const exported = {
noflo: require('noflo'),
'noflo-assembly': require('noflo-assembly'),
'noflo-runtime': require('noflo-runtime'),
'fbp-protocol-client': require('fbp-protocol-client'),
};
window.require = (moduleName) => {
if (exported[moduleName]) {
return exported[moduleName];
}
throw new Error(`Module '${moduleName}' not available`);
};
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
const regex = new RegExp("[\\?&]" + name + "=([^&#]*)");
const results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
const runtimeOptions = {
baseDir: 'browser',
defaultPermissions: [
'protocol:graph',
'protocol:component',
'protocol:network',
'protocol:runtime',
'component:getsource',
'component:setsource'
]
};
const queryProtocol = getParameterByName('fbp_protocol') || 'opener';
if (queryProtocol == 'opener') {
const ide = 'https://app.flowhub.io';
const debugUrl = `${ide}#runtime/endpoint?${encodeURIComponent('protocol=opener&address=' + window.location.href)}`;
const debugButton = document.getElementById('flowhub_debug_url');
if (debugButton) {
debugButton.className = "debug";
debugButton.href = debugUrl;
postMessageRuntime.opener(runtimeOptions, debugButton);
}
} else if (queryProtocol == 'iframe') {
postMessageRuntime.iframe(runtimeOptions);
}
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('service-worker.js');
}