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 type { Readable } from "svelte/store"; | |
const UNSET = Symbol(); | |
export function read<T>(store: Readable<T>): T { | |
let value: T | typeof UNSET = UNSET; | |
store.subscribe((v) => (value = v))(); | |
if (UNSET === value) { | |
throw new Error("Readable did not react synchronously"); | |
} | |
return value; |
export class ChangeNotifier { | |
callbacks: Array<() => void> = []; | |
onChange(callback: () => void) { | |
this.callbacks.push(callback); | |
return () => { | |
const index = this.callbacks.indexOf(callback); | |
if (index >= 0) { | |
this.callbacks.splice(index, 1); | |
} | |
}; |
export interface IDisposable { | |
dispose(): void; | |
} | |
export class DisposePool implements IDisposable { | |
#fns: null | (() => void)[] = []; | |
#pool: null | IDisposable[] = []; | |
get disposed() { | |
return this.#pool === null; | |
} |
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( |