Move globals interfaces into browser project to share. API needs design
This commit is contained in:
parent
02f9c21a18
commit
59afb15a10
|
@ -0,0 +1,16 @@
|
|||
interface SequenceState {
|
||||
hash : string,
|
||||
name : string,
|
||||
progress : number
|
||||
}
|
||||
|
||||
interface State {
|
||||
width? : number,
|
||||
height? : number,
|
||||
sequence? : SequenceState
|
||||
}
|
||||
|
||||
interface Message {
|
||||
cmd? : string;
|
||||
state? : State;
|
||||
}
|
|
@ -1,15 +1,3 @@
|
|||
interface SequenceState {
|
||||
name : string,
|
||||
hash : string,
|
||||
progress : number
|
||||
}
|
||||
|
||||
interface State {
|
||||
width? : number,
|
||||
height? : number,
|
||||
sequence? : SequenceState
|
||||
}
|
||||
|
||||
class Client {
|
||||
private client : WebSocket;
|
||||
private connected : boolean = false;
|
||||
|
@ -24,9 +12,11 @@ class Client {
|
|||
}
|
||||
|
||||
private onMessage (event : any) {
|
||||
const state : State = JSON.parse(event.data) as State;
|
||||
if (typeof state.sequence !== 'undefined' && state.sequence !== null) {
|
||||
this.setSequence(state.sequence);
|
||||
const msg : Message = JSON.parse(event.data) as Message;
|
||||
if (typeof msg.state !== 'undefined' && msg.state.sequence !== null) {
|
||||
this.setSequence(msg.state.sequence);
|
||||
} else if (typeof msg.cmd !== 'undefined' && msg.cmd !== null) {
|
||||
this.cmd(msg.cmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,10 +31,25 @@ class Client {
|
|||
this.progress.innerText = `${Math.floor(percent)}%`;
|
||||
}
|
||||
|
||||
public cameraOpen () {
|
||||
console.log('camera open');
|
||||
private cmd (id : string) {
|
||||
switch (id) {
|
||||
case 'open' :
|
||||
this.receiveCameraOpen();
|
||||
break;
|
||||
default:
|
||||
console.warn(`No command ${id}`);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public sendCameraOpen () {
|
||||
console.log('send camera open');
|
||||
this.client.send(JSON.stringify({ cmd : 'open' }));
|
||||
}
|
||||
|
||||
private receiveCameraOpen () {
|
||||
console.log('got camera open');
|
||||
}
|
||||
}
|
||||
|
||||
const client : Client = new Client();
|
File diff suppressed because one or more lines are too long
|
@ -1,8 +1,3 @@
|
|||
interface SequenceState {
|
||||
hash: string;
|
||||
name: string;
|
||||
progress: number;
|
||||
}
|
||||
export declare class Sequence {
|
||||
private current;
|
||||
private running;
|
||||
|
@ -14,4 +9,3 @@ export declare class Sequence {
|
|||
isRunning(): boolean;
|
||||
getState(): SequenceState;
|
||||
}
|
||||
export type { SequenceState };
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sequence/index.ts"],"names":[],"mappings":";;;AAQA,MAAa,QAAQ;IAMpB;QALQ,YAAO,GAAoB,IAAI,CAAC;IAKxB,CAAC;IAEV,KAAK;QACX,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;IACrB,CAAC;IAEM,IAAI;QACV,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;IACtB,CAAC;IAEM,SAAS;QACf,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAEM,QAAQ;QACd,OAAO;YACN,IAAI,EAAG,IAAI,CAAC,OAAO,CAAC,IAAI;YACxB,IAAI,EAAG,IAAI,CAAC,OAAO,CAAC,IAAI;YACxB,QAAQ,EAAG,IAAI,CAAC,QAAQ;SACxB,CAAA;IACF,CAAC;CACD;AA3BD,4BA2BC"}
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sequence/index.ts"],"names":[],"mappings":";;;AAEA,MAAa,QAAQ;IAMpB;QALQ,YAAO,GAAoB,IAAI,CAAC;IAKxB,CAAC;IAEV,KAAK;QACX,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;IACrB,CAAC;IAEM,IAAI;QACV,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;IACtB,CAAC;IAEM,SAAS;QACf,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAEM,QAAQ;QACd,OAAO;YACN,IAAI,EAAG,IAAI,CAAC,OAAO,CAAC,IAAI;YACxB,IAAI,EAAG,IAAI,CAAC,OAAO,CAAC,IAAI;YACxB,QAAQ,EAAG,IAAI,CAAC,QAAQ;SACxB,CAAA;IACF,CAAC;CACD;AA3BD,4BA2BC"}
|
|
@ -5,7 +5,7 @@
|
|||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"compile": "npm run compile_node && npm run compile_browser",
|
||||
"compile": "bash ./scripts/compile.sh",
|
||||
"compile_node": "./node_modules/.bin/tsc -p tsconfig.json",
|
||||
"compile_browser": "./node_modules/.bin/tsc -p tsconfig-browser.json"
|
||||
},
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
cp src/globals.d.ts browser/globals.d.ts
|
||||
npm run compile_node
|
||||
npm run compile_browser
|
|
@ -0,0 +1,16 @@
|
|||
interface SequenceState {
|
||||
hash : string,
|
||||
name : string,
|
||||
progress : number
|
||||
}
|
||||
|
||||
interface State {
|
||||
width? : number,
|
||||
height? : number,
|
||||
sequence? : SequenceState
|
||||
}
|
||||
|
||||
interface Message {
|
||||
cmd? : string;
|
||||
state? : State;
|
||||
}
|
|
@ -51,10 +51,6 @@ interface WebSocketExtended extends WebSocket {
|
|||
session? : string
|
||||
}
|
||||
|
||||
interface Message {
|
||||
cmd? : string;
|
||||
}
|
||||
|
||||
async function createTemplate (filePath : string) : Promise<HandlebarsTemplateDelegate<any>> {
|
||||
let tmpl : string;
|
||||
try {
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
import type { SequenceObject } from '../files';
|
||||
|
||||
interface SequenceState {
|
||||
hash : string,
|
||||
name : string,
|
||||
progress : number
|
||||
}
|
||||
|
||||
export class Sequence {
|
||||
private current : SequenceObject = null;
|
||||
private running : boolean;
|
||||
|
@ -33,6 +27,4 @@ export class Sequence {
|
|||
progress : this.progress
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export type { SequenceState };
|
||||
}
|
|
@ -1,13 +1,3 @@
|
|||
interface SequenceState {
|
||||
name: string;
|
||||
hash: string;
|
||||
progress: number;
|
||||
}
|
||||
interface State {
|
||||
width?: number;
|
||||
height?: number;
|
||||
sequence?: SequenceState;
|
||||
}
|
||||
declare class Client {
|
||||
private client;
|
||||
private connected;
|
||||
|
@ -16,6 +6,8 @@ declare class Client {
|
|||
private onMessage;
|
||||
private onOpen;
|
||||
private setSequence;
|
||||
cameraOpen(): void;
|
||||
private cmd;
|
||||
sendCameraOpen(): void;
|
||||
private receiveCameraOpen;
|
||||
}
|
||||
declare const client: Client;
|
||||
|
|
|
@ -8,9 +8,12 @@ class Client {
|
|||
this.client.onmessage = this.onMessage.bind(this);
|
||||
}
|
||||
onMessage(event) {
|
||||
const state = JSON.parse(event.data);
|
||||
if (typeof state.sequence !== 'undefined' && state.sequence !== null) {
|
||||
this.setSequence(state.sequence);
|
||||
const msg = JSON.parse(event.data);
|
||||
if (typeof msg.state !== 'undefined' && msg.state.sequence !== null) {
|
||||
this.setSequence(msg.state.sequence);
|
||||
}
|
||||
else if (typeof msg.cmd !== 'undefined' && msg.cmd !== null) {
|
||||
this.cmd(msg.cmd);
|
||||
}
|
||||
}
|
||||
onOpen(event) {
|
||||
|
@ -22,10 +25,23 @@ class Client {
|
|||
this.progress.value = percent;
|
||||
this.progress.innerText = `${Math.floor(percent)}%`;
|
||||
}
|
||||
cameraOpen() {
|
||||
console.log('camera open');
|
||||
cmd(id) {
|
||||
switch (id) {
|
||||
case 'open':
|
||||
this.receiveCameraOpen();
|
||||
break;
|
||||
default:
|
||||
console.warn(`No command ${id}`);
|
||||
break;
|
||||
}
|
||||
}
|
||||
sendCameraOpen() {
|
||||
console.log('send camera open');
|
||||
this.client.send(JSON.stringify({ cmd: 'open' }));
|
||||
}
|
||||
receiveCameraOpen() {
|
||||
console.log('got camera open');
|
||||
}
|
||||
}
|
||||
const client = new Client();
|
||||
//# sourceMappingURL=index.js.map
|
|
@ -1 +1 @@
|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