# HG changeset patch # User drewp@bigasterisk.com # Date 1575447808 28800 # Node ID a668a774b1625c9edbce9584877a2db6f39e81d6 # Parent a7ba8627a7b6190768b3df1bc2e153e02b6a8da9 back up, slowly turn on code again until ts breaks diff -r a7ba8627a7b6 -r a668a774b162 src/streamed-graph.ts --- a/src/streamed-graph.ts Wed Dec 04 00:09:15 2019 -0800 +++ b/src/streamed-graph.ts Wed Dec 04 00:23:28 2019 -0800 @@ -7,6 +7,9 @@ import { customElement, property, computed } from '@polymer/decorators'; import { render } from 'lit-html'; // import { graphView } from '/rdf/browse/graphView.js'; + + + import { StreamedGraphClient } from './streamed_graph_client'; @customElement('streamed-graph') @@ -66,12 +69,12 @@ _onUrl(url) { // if (this.sg) { this.sg.close(); } - this.sg = new StreamedGraphClient( - url, - this.onGraphChanged.bind(this), - this.set.bind(this, 'status'), - [],//window.NS, - []); + // this.sg = new StreamedGraphClient( + // url, + // this.onGraphChanged.bind(this), + // this.set.bind(this, 'status'), + // [],//window.NS, + // []); } onGraphChanged() { diff -r a7ba8627a7b6 -r a668a774b162 src/streamed_graph_client.ts --- a/src/streamed_graph_client.ts Wed Dec 04 00:09:15 2019 -0800 +++ b/src/streamed_graph_client.ts Wed Dec 04 00:23:28 2019 -0800 @@ -10,10 +10,10 @@ const EventSource = window.EventSource; export class StreamedGraphClient { - // onStatus: (msg: string) => void; - // onGraphChanged: () => void; - // store: Store; - // events: EventSource; + onStatus: (msg: string) => void; + onGraphChanged: () => void; + store: Store; + events: EventSource; constructor( eventsUrl: string, onGraphChanged: () => void, @@ -27,14 +27,14 @@ // this.onGraphChanged = onGraphChanged; // this.onStatus('startup...'); - // this.store = new Store({}); + this.store = new Store({}); // // Object.keys(prefixes).forEach((prefix) => { // // this.store.setPrefix(prefix, prefixes[prefix]); // // }); - // this.connect(eventsUrl); - // this.reconnectOnWake(); + this.connect(eventsUrl); + this.reconnectOnWake(); // staticGraphUrls.forEach((url) => { // fetch(url).then((response) => response.text()) @@ -45,47 +45,47 @@ } - // reconnectOnWake() { - // // it's not this, which fires on every mouse-in on a browser window, and doesn't seem to work for screen-turned-back-on - // //window.addEventListener('focus', function() { this.connect(eventsUrl); }.bind(this)); + reconnectOnWake() { + // it's not this, which fires on every mouse-in on a browser window, and doesn't seem to work for screen-turned-back-on + //window.addEventListener('focus', function() { this.connect(eventsUrl); }.bind(this)); - // } + } - // connect(eventsUrl: string) { - // // need to exit here if this obj has been replaced + connect(eventsUrl: string) { + // need to exit here if this obj has been replaced - // this.onStatus('start connect...'); - // this.close(); - // if (this.events && this.events.readyState != EventSource.CLOSED) { - // this.onStatus('zombie'); - // throw new Error("zombie eventsource"); - // } + this.onStatus('start connect...'); + // this.close(); + if (this.events && this.events.readyState != EventSource.CLOSED) { + this.onStatus('zombie'); + throw new Error("zombie eventsource"); + } - // this.events = new EventSource(eventsUrl); + this.events = new EventSource(eventsUrl); - // this.events.addEventListener('error', (ev) => { - // // todo: this is piling up tons of retries and eventually multiple connections - // this.testEventUrl(eventsUrl); - // this.onStatus('connection lost- retrying'); - // setTimeout(() => { - // requestAnimationFrame(() => { - // this.connect(eventsUrl); - // }); - // }, 3000); - // }); + this.events.addEventListener('error', (ev) => { + // todo: this is piling up tons of retries and eventually multiple connections + // this.testEventUrl(eventsUrl); + this.onStatus('connection lost- retrying'); + setTimeout(() => { + requestAnimationFrame(() => { + this.connect(eventsUrl); + }); + }, 3000); + }); - // this.events.addEventListener('fullGraph', (ev) => { - // // this.updates.push({ type: 'fullGraph', data: ev.data }); - // // this.flushUpdates(); - // }); + this.events.addEventListener('fullGraph', (ev) => { + // this.updates.push({ type: 'fullGraph', data: ev.data }); + // this.flushUpdates(); + }); - // this.events.addEventListener('patch', (ev) => { - // // this.updates.push({ type: 'patch', data: ev.data }); - // // this.flushUpdates(); - // }); - // this.onStatus('connecting...'); - // } + this.events.addEventListener('patch', (ev) => { + // this.updates.push({ type: 'patch', data: ev.data }); + // this.flushUpdates(); + }); + this.onStatus('connecting...'); + } // replaceFullGraph(jsonLdText: string, done: () => void) { // // this.quadStore.clear(); diff -r a7ba8627a7b6 -r a668a774b162 tsconfig.json --- a/tsconfig.json Wed Dec 04 00:09:15 2019 -0800 +++ b/tsconfig.json Wed Dec 04 00:23:28 2019 -0800 @@ -5,13 +5,13 @@ "target": "es6", "rootDirs": [ "node_modules", - "src" + // "src" ], "esModuleInterop": true, "allowSyntheticDefaultImports": true }, "files": [ "./src/streamed-graph.ts", - "./src/streamed_graph_client.ts" + // "./src/streamed_graph_client.ts" ] } diff -r a7ba8627a7b6 -r a668a774b162 webpack-dev.config.ts --- a/webpack-dev.config.ts Wed Dec 04 00:09:15 2019 -0800 +++ b/webpack-dev.config.ts Wed Dec 04 00:23:28 2019 -0800 @@ -5,7 +5,7 @@ mode: "development", entry: [ './src/streamed-graph.ts', - './src/streamed_graph_client.ts', + // './src/streamed_graph_client.ts', './src/streamed-graph.css' // doesn't emit anything ],