Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function parseQR(url) {
const p = urlutil.parse(url)
return (p && p.host)
? { serverUrl: p.search ? url.substr(0, url.indexOf('?')) : url
, accessKey: p.search && p.search.startsWith(keyMarker) ? p.search.substr(keyMarker.length) : null }
: null
}
run(main, {
DOM: makeDOMDriver('#app')
, IPC: process.env.BUILD_TARGET === 'electron'
? require('./driver/electron-ipc')
: _ => _ => O.of() // noop driver
, storage: storageDriver
, route: makeRouteDriver(makeHashHistoryDriver())
, conf$: makeConfDriver(storageDriver)
, scan$: process.env.BUILD_TARGET === 'cordova'
? require('./driver/cordova-qrscanner')
: require('./driver/instascan')({ mirror: false, backgroundScan: false })
})
function main(sources) {
const history$ = sources.DOM.select('nav').events('click')
.map(e => e.target.dataset.page)
.compose(dropRepeats())
const vdom$ = view(sources.history);
return {
DOM: vdom$,
history: history$,
};
}
run(main, {
DOM: makeDOMDriver('#app'),
history: makeHashHistoryDriver()
});
import { modalify } from 'cyclejs-modal';
import { routerify } from 'cyclic-router';
import onionify from 'cycle-onionify';
import switchPath from 'switch-path';
import xs from 'xstream';
import { App, Sources } from './app';
let main = onionify(App, 'onion');
main = modalify(main);
main = routerify(main, switchPath);
const drivers: any = {
DOM: makeDOMDriver('#app'),
HTTP: makeHTTPDriver(),
history: makeHashHistoryDriver(),
time: timeDriver
};
export const driverNames: string[] = Object.keys(drivers);
const sinks: (s: Sources) => any = sources => ({
...driverNames.map(n => ({ [n]: xs.never() })).reduce(Object.assign, {}),
...main(sources)
});
run(sinks, drivers);