Worst possible approach:
- Run plugins all in the same vm context on server side Bad approach:
- Run plugins in the same vm context on browser side
Ish:
- Run plugins in browser side web workers
import { | |
Object3D, PerspectiveCamera, Scene, | |
WebGLRenderer | |
} from "three"; | |
import { CleanupFn } from "./CleanupFn"; | |
import { DisposePool, isDisposable } from "./DisposePool"; | |
import { merge } from "./merge"; | |
import { ISheet } from "@theatre/core"; | |
import { TheatreMergeable, theatreMerge } from "./theatreMerge"; | |
import { EventsPool } from "./EventsPool"; |
function jsReplacer() { | |
const seen = new WeakSet(); | |
return (key: string, value: any) => { | |
if (typeof value === "object" && value !== null) { | |
if (seen.has(value)) return "[Circular]"; | |
seen.add(value); | |
} | |
if (value instanceof RegExp) return { regexp: value.toString() }; | |
if (value instanceof Function) return { function: value.toString() }; | |
if (value instanceof Error) return { error: value.toString() }; |
const ignore: string[] = [ | |
// "ui/generated.slint" | |
]; | |
const dirs = { ui: "ui" }; | |
const whitespaceRE = /^(\s*)(.*?)(\/*|\/\/)?(.*)$/; | |
const indentBy = " "; | |
file: for await (const file of Deno.readDir(dirs.ui)) { | |
if ( |
import { | |
AttributeSpec, | |
DOMOutputSpec, | |
Fragment, | |
Mark, | |
Node as PMNode, | |
NodeSpec, | |
NodeType, | |
ParseRule, | |
} from "prosemirror-model"; |
/** | |
* Generate a fragile object that will throw error at any operation. | |
*/ | |
export function createErrorObj<T = any>(error: string): T { | |
return new Proxy( | |
{}, | |
{ | |
get(target, prop, receiver: unknown) { | |
throw new Error( |
#SingleInstance Force | |
; Debugging | |
; https://www.autohotkey.com/scite4ahk/pages/debugger.htm | |
; Map Capslock to control (macOS is Capslock as Command, so most keybindings feel similar) | |
CapsLock::RControl | |
; Left Ctrl Tab -> Left Alt Tab | |
<^Tab::>!Tab |
/** Memory-volatile multi-key cache with a root weak key */ | |
export class WeakCache { | |
private wm = new WeakMap<object, Map<string | number, unknown>>(); | |
/** It's very important to not call this with the same keys and expect a different result. */ | |
getOrPut<R>(weakKey: object, keys: CacheKeys, fn: () => R): R { | |
let found = this.wm.get(weakKey); | |
const innerKey = typeof keys === "object" ? JSON.stringify(keys) : keys; | |
if (!found) { | |
const computed = fn(); | |
found = new Map([[innerKey, computed]]); |
// eslint-disable-next-line @typescript-eslint/no-explicit-any | |
type $IntentionalAny = any; | |
/** | |
* This special type can help generate pattern matchers for you! | |
* Just use it as so: | |
* // enum-ts | |
* type Result<Ok, Err> = Enum<{ | |
* Ok: Ok, | |
* Err: Err, |