Mercurial > code > home > repos > streamed-graph
changeset 74:5cd795b4c545
merge
author | drewp@bigasterisk.com |
---|---|
date | Tue, 11 Feb 2020 21:44:06 -0800 |
parents | 70bc10f3eb07 (current diff) f7143866fae1 (diff) |
children | 0ba4bd0ba245 |
files | package.json pnpm-lock.yaml |
diffstat | 5 files changed, 30 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/package.json Tue Feb 11 21:34:28 2020 -0800 +++ b/package.json Tue Feb 11 21:44:06 2020 -0800 @@ -24,7 +24,7 @@ "@rollup/plugin-commonjs": "^11.0.1", "@rollup/plugin-node-resolve": "^7.0.0", "@rollup/plugin-replace": "^2.3.0", - "@types/jest": "^24.0.25", + "@types/jest": "^24.9.0", "@types/rollup-plugin-postcss": "^2.0.0", "jest": "^24.9.0", "node-globals": "^0.1.5", @@ -35,6 +35,6 @@ "stylus": "^0.54.7", "ts-jest": "^24.3.0", "tslib": "^1.10.0", - "typescript": "^3.7.4" + "typescript": "^3.7.5" } }
--- a/pnpm-lock.yaml Tue Feb 11 21:34:28 2020 -0800 +++ b/pnpm-lock.yaml Tue Feb 11 21:44:06 2020 -0800 @@ -18,11 +18,11 @@ rollup: 1.29.0 rollup-plugin-node-builtins: 2.1.2 rollup-plugin-postcss: 2.0.3 - rollup-plugin-typescript2: 0.25.3_rollup@1.29.0+typescript@3.7.4 + rollup-plugin-typescript2: 0.25.3_rollup@1.29.0+typescript@3.7.5 stylus: 0.54.7 ts-jest: 24.3.0_jest@24.9.0 tslib: 1.10.0 - typescript: 3.7.4 + typescript: 3.7.5 lockfileVersion: 5.1 packages: /@babel/code-frame/7.8.3: @@ -6020,7 +6020,7 @@ node: '>=6' resolution: integrity: sha512-d12oKl6za/GGXmlytzVPzzTdPCKgti/Kq2kNhtfm5vv9hkNbyrTvizMBm6zZ5rRWX/sIWl3znjIJ8xy6Hofoeg== - /rollup-plugin-typescript2/0.25.3_rollup@1.29.0+typescript@3.7.4: + /rollup-plugin-typescript2/0.25.3_rollup@1.29.0+typescript@3.7.5: dependencies: find-cache-dir: 3.2.0 fs-extra: 8.1.0 @@ -6028,7 +6028,7 @@ rollup: 1.29.0 rollup-pluginutils: 2.8.1 tslib: 1.10.0 - typescript: 3.7.4 + typescript: 3.7.5 dev: true peerDependencies: rollup: '>=1.26.3' @@ -6754,13 +6754,13 @@ dev: true resolution: integrity: sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= - /typescript/3.7.4: + /typescript/3.7.5: dev: true engines: node: '>=4.2.0' hasBin: true resolution: - integrity: sha512-A25xv5XCtarLwXpcDNZzCGvW2D1S3/bACratYBx2sax8PefsFhlYmkQicKHvpYflFS8if4zne5zT5kpJ7pzuvw== + integrity: sha512-/P5lkRXkWHNAbcJIiHPfRoKqyd7bsyCma1hZNUGfn20qm64T6ZBlrzprymeu918H+mB/0rIg2gGK/BXkhhYgBw== /umd/3.0.3: dev: true hasBin: true @@ -7079,7 +7079,7 @@ '@rollup/plugin-commonjs': ^11.0.1 '@rollup/plugin-node-resolve': ^7.0.0 '@rollup/plugin-replace': ^2.3.0 - '@types/jest': ^24.0.25 + '@types/jest': ^24.9.0 '@types/jsonld': ^1.5.1 '@types/n3': ^1.1.5 '@types/rollup-plugin-postcss': ^2.0.0 @@ -7096,4 +7096,4 @@ stylus: ^0.54.7 ts-jest: ^24.3.0 tslib: ^1.10.0 - typescript: ^3.7.4 + typescript: ^3.7.5
--- a/src/graph_view.ts Tue Feb 11 21:34:28 2020 -0800 +++ b/src/graph_view.ts Tue Feb 11 21:44:06 2020 -0800 @@ -4,6 +4,7 @@ const { namedNode } = DataFactory; import { SuffixLabels } from "./suffixLabels"; +import { Quad_Object } from "n3"; // import ns from 'n3/src/IRIs'; // const { rdf } = ns; const rdf = {
--- a/src/index.ts Tue Feb 11 21:34:28 2020 -0800 +++ b/src/index.ts Tue Feb 11 21:44:06 2020 -0800 @@ -1,13 +1,13 @@ +import { PolymerElement, html } from "@polymer/polymer"; import { customElement, property, computed } from "@polymer/decorators"; -import { N3Store } from "n3"; -import { PolymerElement, html } from "@polymer/polymer"; import { render } from "lit-html"; +import { N3Store, Store } from "n3"; + import { GraphView } from "./graph_view"; import { StreamedGraphClient } from "./streamed_graph_client"; -import { Store } from "n3"; +import style from "./style.styl"; -import style from "./style.styl"; export * from "./graph_queries"; export interface VersionedGraph {
--- a/src/streamed_graph_client.ts Tue Feb 11 21:34:28 2020 -0800 +++ b/src/streamed_graph_client.ts Tue Feb 11 21:44:06 2020 -0800 @@ -11,6 +11,7 @@ onStatus: (msg: string) => void; onGraphChanged: () => void; store: N3Store; + _deletedCount: number = 0; events!: EventSource; constructor( eventsUrl: string, @@ -41,6 +42,11 @@ // }); } + _vacuum() { + // workaround for the growing _ids map + this.store = new Store(this.store.getQuads(null, null, null, null)); + } + 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)); @@ -97,8 +103,16 @@ async patchGraph(patchJson: string) { var patch = JSON.parse(patchJson).patch; - await eachJsonLdQuad(patch.deletes, this.store.removeQuad.bind(this.store)); + await eachJsonLdQuad(patch.deletes, quad => { + this.store.removeQuad(quad); + this._deletedCount++; + }); await eachJsonLdQuad(patch.adds, this.store.addQuad.bind(this.store)); + + if (this._deletedCount > 100) { + this._vacuum(); + this._deletedCount = 0; + } } close() {