Changeset - f9edd9819b7d
[Not reviewed]
default
9 1 9
drewp@bigasterisk.com - 20 months ago 2023-05-24 21:37:11
drewp@bigasterisk.com
move live/ out of web; it's just a normal (web-only) tool now
10 files changed with 17 insertions and 18 deletions:
0 comments (0 inline, 0 general)
bin/live
Show inline comments
 
#!/bin/zsh
 
pnpm exec vite -c light9/web/live/vite.config.ts &
 
wait
 
exec pnpm exec vite -c light9/live/vite.config.ts
light9/live/Effect.ts
Show inline comments
 
file renamed from light9/web/live/Effect.ts to light9/live/Effect.ts
 
import debug from "debug";
 
import { Literal, NamedNode, Quad_Object, Quad_Predicate, Quad_Subject, Term } from "n3";
 
import { some } from "underscore";
 
import { Patch, patchContainsPreds, patchUpdate } from "../patch";
 
import { SyncedGraph } from "../SyncedGraph";
 
import { shortShow } from "../show_specific";
 
import { Patch, patchContainsPreds, patchUpdate } from "../web/patch";
 
import { SyncedGraph } from "../web/SyncedGraph";
 
import { shortShow } from "../web/show_specific";
 

	
 
type Color = string;
 
export type ControlValue = number | Color | NamedNode;
 

	
 
const log = debug("effect");
 

	
 
function isUri(x: Term | number | string): x is NamedNode {
 
  return typeof x == "object" && x.termType == "NamedNode";
 
}
 

	
 
function valuePred(graph: SyncedGraph, attr: NamedNode): NamedNode {
 
  const U = graph.U();
 
  const scaledAttributeTypes = [U(":color"), U(":brightness"), U(":uv")];
 
  if (some(scaledAttributeTypes, (x: NamedNode) => attr.equals(x))) {
 
    return U(":scaledValue");
 
  } else {
 
    return U(":value");
 
  }
 
}
 

	
 
// effect settings data; r/w sync with the graph
 
export class Effect {
 
  private settings: Array<{ device: NamedNode; deviceAttr: NamedNode; setting: NamedNode; value: ControlValue }> = [];
 
  private ctxForEffect: NamedNode
light9/live/GraphToControls.ts
Show inline comments
 
file renamed from light9/web/live/GraphToControls.ts to light9/live/GraphToControls.ts
 
import debug from "debug";
 
import { NamedNode } from "n3";
 
import { SyncedGraph } from "../SyncedGraph";
 
import { SyncedGraph } from "../web/SyncedGraph";
 
import { ControlValue, Effect } from "./Effect";
 
const log = debug("g2c");
 

	
 
type NewValueCb = (newValue: ControlValue | null) => void;
 

	
 
// More efficient bridge between liveControl widgets and graph edits (inside Effect),
 
// as opposed to letting each widget scan the graph and push lots of
 
// tiny patches to it.
 
export class GraphToControls {
 
  // rename to PageControls?
 
  effect: Effect | null = null; // this uri should sync to the editchoice
 
  registeredWidgets: Map<NamedNode, Map<NamedNode, NewValueCb>> = new Map();
 
  constructor(public graph: SyncedGraph) {}
 

	
 
  setEffect(effect: NamedNode | null) {
 
    log(`setEffect ${effect?.value}`);
 
    this.effect = effect ? new Effect(this.graph, effect, this.onValuesChanged.bind(this)) : null;
 
  }
 

	
 
  newEffect(): NamedNode {
 
    // wrong- this should be our editor's scratch effect, promoted to a
 
    // real one when you name it.
 
    const uri = this.graph.nextNumberedResource(this.graph.Uri("http://light9.bigasterisk.com/effect/effect"));
 

	
light9/live/Light9DeviceControl.ts
Show inline comments
 
file renamed from light9/web/live/Light9DeviceControl.ts to light9/live/Light9DeviceControl.ts
 
import debug from "debug";
 
import { css, html, LitElement } from "lit";
 
import { customElement, property } from "lit/decorators.js";
 
import { NamedNode } from "n3";
 
import { unique } from "underscore";
 
import { Patch, patchContainsPreds } from "../patch";
 
import { getTopGraph } from "../RdfdbSyncedGraph";
 
import { SyncedGraph } from "../SyncedGraph";
 
import { Patch, patchContainsPreds } from "../web/patch";
 
import { getTopGraph } from "../web/RdfdbSyncedGraph";
 
import { SyncedGraph } from "../web/SyncedGraph";
 
import { GraphToControls } from "./GraphToControls";
 
import { Choice } from "./Light9Listbox";
 
import { Light9LiveControl } from "./Light9LiveControl";
 
export { ResourceDisplay } from "../ResourceDisplay";
 
export { ResourceDisplay } from "../web/ResourceDisplay";
 
export { Light9LiveControl };
 
const log = debug("devcontrol");
 

	
 
export interface DeviceAttrRow {
 
  uri: NamedNode; //devattr
 
  attrClasses: string; // the css kind
 
  dataType: NamedNode;
 
  showColorPicker: boolean;
 
  useColor: boolean;
 
  useChoice: boolean;
 
  choices: Choice[];
 
  choiceSize: number;
 
  useSlider: boolean;
 
  max: number;
 
}
 

	
 
@customElement("light9-device-control")
 
export class Light9DeviceControl extends LitElement {
 
  graph!: SyncedGraph;
 
  static styles = [
 
    css`
 
      :host {
 
        display: inline-block;
 
      }
light9/live/Light9Listbox.ts
Show inline comments
 
file renamed from light9/web/live/Light9Listbox.ts to light9/live/Light9Listbox.ts
light9/live/Light9LiveControl.ts
Show inline comments
 
file renamed from light9/web/live/Light9LiveControl.ts to light9/live/Light9LiveControl.ts
 
import debug from "debug";
 
const log = debug("control");
 
import { css, html, LitElement, PropertyPart, PropertyValues } from "lit";
 
import { customElement, property } from "lit/decorators.js";
 
import { NamedNode } from "n3";
 
import { getTopGraph } from "../RdfdbSyncedGraph";
 
import { SyncedGraph } from "../SyncedGraph";
 
import { getTopGraph } from "../web/RdfdbSyncedGraph";
 
import { SyncedGraph } from "../web/SyncedGraph";
 
import { ControlValue } from "./Effect";
 
import { GraphToControls } from "./GraphToControls";
 
import { DeviceAttrRow } from "./Light9DeviceControl";
 
import { Choice } from "./Light9Listbox";
 
export { Slider } from "@material/mwc-slider";
 
@customElement("light9-live-control")
 
export class Light9LiveControl extends LitElement {
 
  graph!: SyncedGraph;
 

	
 
  static styles = [
 
    css`
 
      #colorControls {
 
        display: flex;
 
        align-items: center;
 
      }
 
      #colorControls > * {
 
        margin: 0 3px;
 
      }
 
      #colorControls paper-slider {
 
      }
 
      paper-slider {
 
        width: 100%;
 
        height: 25px;
 
      }
light9/live/Light9LiveControls.ts
Show inline comments
 
file renamed from light9/web/live/Light9LiveControls.ts to light9/live/Light9LiveControls.ts
 
import debug from "debug";
 
import { css, html, LitElement, PropertyValues } from "lit";
 
import { customElement, property } from "lit/decorators.js";
 
import { NamedNode } from "n3";
 
import { sortBy, uniq } from "underscore";
 
import { Patch, patchContainsPreds } from "../patch";
 
import { getTopGraph } from "../RdfdbSyncedGraph";
 
import { SyncedGraph } from "../SyncedGraph";
 
import { Patch, patchContainsPreds } from "../web/patch";
 
import { getTopGraph } from "../web/RdfdbSyncedGraph";
 
import { SyncedGraph } from "../web/SyncedGraph";
 
import { GraphToControls } from "./GraphToControls";
 
export { EditChoice } from "../EditChoice";
 
export { EditChoice } from "../web/EditChoice";
 
export { Light9DeviceControl as Light9LiveDeviceControl } from "./Light9DeviceControl";
 
const log = debug("controls");
 

	
 
@customElement("light9-live-controls")
 
export class Light9LiveControls extends LitElement {
 
  graph!: SyncedGraph;
 

	
 
  static styles = [
 
    css`
 
      :host {
 
        display: flex;
 
        flex-direction: column;
 
      }
 
      #preview {
 
        width: 100%;
 
      }
 
      #deviceControls {
 
        flex-grow: 1;
 
        position: relative;
 
        width: 100%;
 
        overflow-y: auto;
 
      }
 

	
 
      light9-live-device-control > div {
light9/live/README.md
Show inline comments
 
file renamed from light9/web/live/README.md to light9/live/README.md
light9/live/index.html
Show inline comments
 
file renamed from light9/web/live/index.html to light9/live/index.html
light9/live/vite.config.ts
Show inline comments
 
file renamed from light9/web/live/vite.config.ts to light9/live/vite.config.ts
 
import { defineConfig } from "vite";
 

	
 
const servicePort = 8217;
 
export default defineConfig({
 
  base: "/live/",
 
  root: "./light9/web/live",
 
  publicDir: "../web",
 
  root: "./light9/live",
 
  publicDir: "../..",
 
  server: {
 
    host: "0.0.0.0",
 
    strictPort: true,
 
    port: servicePort + 100,
 
    hmr: {
 
      port: servicePort + 200,
 
    },
 
  },
 
  clearScreen: false,
 
  define: {
 
    global: {},
 
  },
 
});
0 comments (0 inline, 0 general)