changeset 674:2b9865bf1737

streamed-graph finally imports and builds. polymer bindings don't work in a <dom-bind> though Ignore-this: afcf4436ac3d7b88c0d7fc88de81d8e4
author drewp@bigasterisk.com
date Thu, 02 Jan 2020 00:23:36 -0800
parents f2215949c0c9
children 9ae34280218b
files service/wifi/.dockerignore service/wifi/index.html service/wifi/package-lock.json service/wifi/package.json service/wifi/rollup.config.js service/wifi/src/index.ts service/wifi/wifi.py
diffstat 7 files changed, 115 insertions(+), 115 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/service/wifi/.dockerignore	Thu Jan 02 00:23:36 2020 -0800
@@ -0,0 +1,1 @@
+node_modules
--- a/service/wifi/index.html	Tue Dec 31 02:45:25 2019 -0800
+++ b/service/wifi/index.html	Thu Jan 02 00:23:36 2020 -0800
@@ -3,41 +3,37 @@
   <head>
     <title>wifi</title>
     <meta charset="utf-8" />
+    <script src="/lib/webcomponents/2.4.0/webcomponents-bundle.js"></script>
     <script src="/rdf/common_paths_and_ns.js?v3"></script>
-    <link rel="stylesheet" href="/rdf/streamed-graph.css" />
+    <script type="module" src="build/bundle.js"></script>
   </head>
-
+  <link rel="stylesheet" href="/rdf/streamed-graph.css" />
   <body class="rdfBrowsePage">
-    pre dombind
+    <hr />
     <dom-bind>
-      inside dombind
-      <style>
-        #subjectRequest {
-          width: 50em;
-        }
-      </style>
-sg:
-      <streamed-graph
-        url="graph/events"
-        realurl="sse_collector/graph/network"
-        static="['demo.n3']"
-        graph="{{graph}}"
-      ></streamed-graph>
-
-      wifi-display:
-      <wifi-display graph="{{graph}}" show-groups="true"></wifi-display>
-
+      <template>
+        <style>
+          body {
+            background: #3a3a3a;
+          }
+          #subjectRequest {
+            width: 50em;
+          }
+        </style>
+        <streamed-graph
+          url="/sse_collector/graph/env"
+          n="network"
+          static="['demo.n3']"
+          graph="{{graph}}"
+          expanded="{{e}}"
+        ></streamed-graph>
+        g={{graph.version}} e={{e}}
+        <wifi-display graph="{{graph}}" show-groups="true"></wifi-display>
+      </template>
     </dom-bind>
     <form method="POST" action="remoteSuspend">
       <button>Suspend windows/VR machine</button>
     </form>
     <!-- also put wakeonlan actions down here -->
-
-    <script type="module" src="build/bundle.js"></script>
-    <script type="module">
-      document.querySelector("dom-bind").style.display = "block"; // not sure why polymer hides this and never shows it
-    </script>
-
-    
   </body>
 </html>
--- a/service/wifi/package-lock.json	Tue Dec 31 02:45:25 2019 -0800
+++ b/service/wifi/package-lock.json	Thu Jan 02 00:23:36 2020 -0800
@@ -425,6 +425,16 @@
         "resolve": "^1.11.1"
       }
     },
+    "@rollup/plugin-replace": {
+      "version": "2.3.0",
+      "resolved": "https://registry.npmjs.org/@rollup/plugin-replace/-/plugin-replace-2.3.0.tgz",
+      "integrity": "sha512-rzWAMqXAHC1w3eKpK6LxRqiF4f3qVFaa1sGii6Bp3rluKcwHNOpPt+hWRCmAH6SDEPtbPiLFf0pfNQyHs6Btlg==",
+      "dev": true,
+      "requires": {
+        "magic-string": "^0.25.2",
+        "rollup-pluginutils": "^2.6.0"
+      }
+    },
     "@rollup/pluginutils": {
       "version": "3.0.1",
       "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.0.1.tgz",
@@ -7158,6 +7168,12 @@
         }
       }
     },
+    "rollup-plugin-force-binding": {
+      "version": "1.0.6",
+      "resolved": "https://registry.npmjs.org/rollup-plugin-force-binding/-/rollup-plugin-force-binding-1.0.6.tgz",
+      "integrity": "sha1-SRsQVK2dvCPglyexalXmbj6GCi4=",
+      "dev": true
+    },
     "rollup-plugin-node-builtins": {
       "version": "2.1.2",
       "resolved": "https://registry.npmjs.org/rollup-plugin-node-builtins/-/rollup-plugin-node-builtins-2.1.2.tgz",
@@ -7663,7 +7679,7 @@
       }
     },
     "streamed-graph": {
-      "version": "file:../../../../../home/drewp/projects/streamed-graph",
+      "version": "file:../../../../../../my/proj/streamed-graph",
       "requires": {
         "@polymer/decorators": "^3.0.0",
         "@polymer/polymer": "^3.3.1",
@@ -7864,11 +7880,6 @@
             }
           }
         },
-        "@rdfjs/data-model": {
-          "version": "1.1.2",
-          "resolved": "https://registry.npmjs.org/@rdfjs/data-model/-/data-model-1.1.2.tgz",
-          "integrity": "sha512-pk/G/JLYGaXesoBLvEmoC/ic0H3B79fTyS0Ujjh5YQB2DZW+mn05ZowFFv88rjB9jf7c1XE5XSmf8jzn6U0HHA=="
-        },
         "@rollup/plugin-commonjs": {
           "version": "11.0.0",
           "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-11.0.0.tgz",
@@ -7944,9 +7955,9 @@
           },
           "dependencies": {
             "@types/node": {
-              "version": "13.1.1",
-              "resolved": "https://registry.npmjs.org/@types/node/-/node-13.1.1.tgz",
-              "integrity": "sha512-hx6zWtudh3Arsbl3cXay+JnkvVgCKzCWKv42C9J01N2T2np4h8w5X8u6Tpz5mj38kE3M9FM0Pazx8vKFFMnjLQ=="
+              "version": "13.1.2",
+              "resolved": "https://registry.npmjs.org/@types/node/-/node-13.1.2.tgz",
+              "integrity": "sha512-B8emQA1qeKerqd1dmIsQYnXi+mmAzTB7flExjmy5X1aVAKFNNNDubkavwR13kR6JnpeLp3aLoJhwn9trWPAyFQ=="
             },
             "@types/rdf-js": {
               "version": "2.0.7",
@@ -9612,11 +9623,6 @@
           "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz",
           "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA=="
         },
-        "encoding": {
-          "version": "0.1.12",
-          "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz",
-          "integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s="
-        },
         "end-of-stream": {
           "version": "1.4.4",
           "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz",
@@ -10456,11 +10462,6 @@
           "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz",
           "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8="
         },
-        "isomorphic-fetch": {
-          "version": "2.2.1",
-          "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz",
-          "integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk="
-        },
         "isstream": {
           "version": "0.1.2",
           "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz",
@@ -11118,16 +11119,6 @@
             }
           }
         },
-        "jsonld-context-parser": {
-          "version": "1.3.4",
-          "resolved": "https://registry.npmjs.org/jsonld-context-parser/-/jsonld-context-parser-1.3.4.tgz",
-          "integrity": "sha512-mR2uoEWqFLE1PrF1pbUuppKajHSGwodXtI9hlcpKflvolDEFAh4hd7z9874pWaK+TtQfHC3Xqfk0U8SEnt2htw=="
-        },
-        "jsonld-streaming-parser": {
-          "version": "1.1.2",
-          "resolved": "https://registry.npmjs.org/jsonld-streaming-parser/-/jsonld-streaming-parser-1.1.2.tgz",
-          "integrity": "sha512-nKCvqHz2JDHJjt2Iv3kW7yoFpIcKX8bWGqe9r5xaadBg9yp7pg3iuwt7Tl8ADOj5z7jYWKGmO8s31Ho+XN1slQ=="
-        },
         "jsonparse": {
           "version": "1.3.1",
           "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz",
@@ -11608,11 +11599,6 @@
           "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz",
           "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ=="
         },
-        "node-fetch": {
-          "version": "1.7.3",
-          "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz",
-          "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ=="
-        },
         "node-forge": {
           "version": "0.8.5",
           "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.8.5.tgz",
@@ -12223,11 +12209,6 @@
             }
           }
         },
-        "relative-to-absolute-iri": {
-          "version": "1.0.5",
-          "resolved": "https://registry.npmjs.org/relative-to-absolute-iri/-/relative-to-absolute-iri-1.0.5.tgz",
-          "integrity": "sha512-sHpUlpF3fRWtTcBa8uBIwQ+Z/YnjDjerocV3q0FrP8T9oZ3z6d61I12ZcGlGr9jW2cQbcCkErCT9XLcN18ZLaQ=="
-        },
         "remove-trailing-separator": {
           "version": "1.1.0",
           "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz",
@@ -13266,11 +13247,6 @@
           "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-1.0.5.tgz",
           "integrity": "sha512-b5lim54JOPN9HtzvK9HFXvBma/rnfFeqsic0hSpjtDbVxR3dJKLc+KB4V6GgiGOvl7CY/KNh8rxSo9DKQrnUEw=="
         },
-        "whatwg-fetch": {
-          "version": "3.0.0",
-          "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz",
-          "integrity": "sha512-9GSJUgz1D4MfyKU7KRqwOjXCXTqWdFNvEr7eUBYchQiVc744mqK/MzXPNR2WsPkmkOa4ywfg8C2n8h+13Bey1Q=="
-        },
         "whatwg-mimetype": {
           "version": "2.3.0",
           "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-2.3.0.tgz",
--- a/service/wifi/package.json	Tue Dec 31 02:45:25 2019 -0800
+++ b/service/wifi/package.json	Thu Jan 02 00:23:36 2020 -0800
@@ -18,15 +18,17 @@
     "@types/n3": "^1.1.1",
     "lit-html": "^1.1.2",
     "n3": "^1.3.5",
-    "streamed-graph": "file:/home/drewp/projects/streamed-graph"
+    "streamed-graph": "file:/my/proj/streamed-graph"
   },
   "devDependencies": {
     "@rollup/plugin-commonjs": "^11.0.0",
     "@rollup/plugin-node-resolve": "^6.0.0",
+    "@rollup/plugin-replace": "^2.3.0",
     "@types/jest": "^24.0.25",
     "jest": "^24.9.0",
     "node-globals": "^0.1.5",
     "rollup": "^1.27.14",
+    "rollup-plugin-force-binding": "^1.0.6",
     "rollup-plugin-node-builtins": "^2.1.2",
     "rollup-plugin-typescript2": "^0.25.3",
     "ts-jest": "^24.2.0",
--- a/service/wifi/rollup.config.js	Tue Dec 31 02:45:25 2019 -0800
+++ b/service/wifi/rollup.config.js	Thu Jan 02 00:23:36 2020 -0800
@@ -1,26 +1,42 @@
 import builtins from "rollup-plugin-node-builtins";
-import commonjs from '@rollup/plugin-commonjs';
+import commonjs from "@rollup/plugin-commonjs";
 import resolve from "@rollup/plugin-node-resolve";
 import typescript from "rollup-plugin-typescript2";
+import replace from "@rollup/plugin-replace";
+
+const workaround_jsonld_module_system_picker = "process = {version: '1.0.0'}";
+const workaround_some_browser_detector = "global = window";
+
+// This makes <dom-module> element totally unavailable. I only meant to prune one of the
+// two, but of course why is streamed-graph's node_modules/**/dom-module.js file getting 
+// here in the first place?
+const duplicated_line_i_cant_prune =
+  "customElements.define('dom-module', DomModule);";
+const replacements = {};
+replacements[duplicated_line_i_cant_prune] = "";
 
 export default {
-    input: "src/index.ts",
-    output: {
-        file: "build/bundle.js",
-        format: "esm",
-       // intro: "const global = window;"
-    },
-    plugins: [
-        builtins(),
-        resolve({
-            extensions: [".js", ".ts"],
-            browser: true
-        }),
-        typescript(),
-        commonjs({
-            namedExports: {
-                'jsonld': ['expand'], // fixes "expand is not exported by node_modules/jsonld/lib/index.js"
-            }
-        }),
-    ]
+  input: "src/index.ts",
+  output: {
+    file: "build/bundle.js",
+    format: "esm",
+    intro: `const ${workaround_some_browser_detector}, ${workaround_jsonld_module_system_picker};`,
+  },
+  external: [
+    "dom-module", // don't want two of these in the bundle
+  ],
+  plugins: [
+    builtins(),
+    resolve({
+      extensions: [".js", ".ts"],
+      browser: true,
+    }),
+    typescript(),
+    commonjs({
+      namedExports: {
+        jsonld: ["expand"], // fixes "expand is not exported by node_modules/jsonld/lib/index.js"
+      },
+    }),
+    replace({ ...replacements, delimiters: ["", ""] }),
+  ],
 };
--- a/service/wifi/src/index.ts	Tue Dec 31 02:45:25 2019 -0800
+++ b/service/wifi/src/index.ts	Thu Jan 02 00:23:36 2020 -0800
@@ -1,28 +1,37 @@
-console.log('p-1');
-import { PolymerElement, html } from '@polymer/polymer';
-import { customElement, property, computed } from '@polymer/decorators';
-import { N3Store } from "n3"
+import { PolymerElement, html } from "@polymer/polymer";
+import {
+  customElement,
+  property,
+  computed,
+  observe,
+} from "@polymer/decorators";
+import { N3Store } from "n3";
 //import {* as wt} from './wifi-table';
 import { VersionedGraph, StreamedGraph } from "streamed-graph";
-export {DomBind} from '@polymer/polymer/lib/elements/dom-bind.js';
-console.log('p0');
-console.log('p1', StreamedGraph.name);
-@customElement('wifi-display')
+export { DomBind } from "@polymer/polymer/lib/elements/dom-bind.js";
+
+console.log("here is a real dependency on ", StreamedGraph.name);
+
+@customElement("wifi-display")
 class WifiDisplay extends PolymerElement {
+  @property({ type: Object, observer: WifiDisplay.prototype.onGraphChanged})
+  graph!: VersionedGraph;
 
-    @property({ type: Object })
-    graph!: StreamedGraph;
+
+  onGraphChanged() {
+    console.log("new graph", this.graph);
+  }
 
-    ready() {
-        super.ready();
-        console.log('p2');
-        // this.graph.addEventListener('change', this.redraw.bind(this));
-    }
-    // redraw() {
-    //     wt.render(this.graph.graph);
-    // }
-    static get template() {
-        return html`here`;
-    }
+  ready() {
+    super.ready();
+  }
+
+  // redraw() {
+  //     wt.render(this.graph.graph);
+  // }
+  static get template() {
+    return html`
+      here
+    `;
+  }
 }
-console.log('p3');
\ No newline at end of file
--- a/service/wifi/wifi.py	Tue Dec 31 02:45:25 2019 -0800
+++ b/service/wifi/wifi.py	Thu Jan 02 00:23:36 2020 -0800
@@ -250,7 +250,7 @@
         cyclone.web.Application(
             [
                 (r"/", Index),
-                (r"/build/(wifi\.bundle\.js)", cyclone.web.StaticFileHandler, {"path": 'build'}),
+                (r"/build/(bundle\.js)", cyclone.web.StaticFileHandler, {"path": 'build'}),
                 (r'/json', Json),
                 (r'/graph', CycloneGraphHandler, {'masterGraph': masterGraph}),
                 (r'/graph/events', CycloneGraphEventsHandler, {'masterGraph': masterGraph}),