Start with strongly typed Socket-Client
/** WS Client type */
type Client = {
id: string;
name: string;
socket: WebSocket;
import { activeNodes } from '../render/activeNodes.ts' | |
import { Host, ctx, dwmWindow, hasVisiblePopup } from '../render/renderContext.ts' | |
import type { View } from '../types.ts'; | |
import { events } from './eventBus.ts' | |
//==================================================== | |
// Sytem Events Module | |
// Watch for all host window generated events. |
Marvin;
When I came to Deno, I was a developer that had retired young in 2000 (I'm 75).
I avoided tech for many years, and took up wood-working as a hobby.
My only computer use was browsing for tools, materials and woodworking articles.
Sometime In 2014, I was approached to do a project for a California NGO working in Cambodia.
One of their engineers had seen one of my graphical real-time desktop apps running in a Toyota plant.
They needed something similar for the detection of underground Unexploded Ordnance (UXO).
I volunteered, and suggested the use of a three-tiered solution.
// Import GFM (GitHub Flavored Markdown rendering for Deno) | |
import { CSS, render } from "https://deno.land/x/[email protected]/mod.ts"; | |
// Add prism - syntax highlighter for TypeScript, Bash, and Rust | |
import "https://esm.sh/[email protected]/components/prism-typescript?no-check"; | |
/** | |
* Export an html doc file builder (builds html from markdown) | |
*/ | |
export function buildHtml( markdownName: string, srcFolder: string ) { |
//====================================== | |
// server.ts | |
//====================================== | |
import { inject } from './injector.ts' // SEE BELOW | |
import { registerWatcher } from './watcher.ts' | |
// in your server request handler ... |
/** A resizable buffer */ | |
export let accumulator = new Uint8Array( 1 << 14 ) // 16384 | |
/** CodecBuffer class */ | |
export class CodecBuffer { | |
/** The next available byte (tail-pointer) */ | |
nextByte = 0 |
import { TextLine, ctx , logThis, Events } from '../deps.ts' | |
import { PLACEHOLDER } from './constants.ts' | |
/** | |
* splits a string into lines that will fit in a container | |
* Will attempt to split at word boundries. | |
*/ | |
export function getLines(text: string, width: number) { | |
let lines: string[] = [] | |
let maxWidth = width |
/** | |
* type for generic Event-Handler callbacks | |
*/ | |
export type EventHandler<T = any> = (data: T) => void; | |
/** | |
* validate each Event Types callback parameters | |
*/ | |
export type EventContract<T> = { [K in keyof T]: T[K] } |
import { | |
Size, | |
WindowKeyboardEvent, | |
WindowInputEvent | |
} from "../mod.ts" | |
import { TextLine } from "../types.ts"; | |
export type {Rect} from "../mod.ts" |
import type {CoreEvents} from './coreEventTypes.ts' | |
import type { | |
EventBus, | |
EventContract, | |
EventHandler | |
} from '../types.ts' | |
/** | |
* A factory function that returns a generic strongly-typed EventBus instance |