This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// regexes to remove lines from thrown error stacktraces | |
const AT_NODE_INTERNAL_RE = /^\s*at.+node:internal.+/gm; | |
const AT_TYPES_INTERNAL_RE = /^\s*at.+\/types\/src\/.+/gm; | |
const AT_INVARIANT_RE = /^\s*(at|[^@]+@) (?:Object\.)?invariant.+/gm; | |
const AT_INVARIANT_MORE_RE = /^\s*at.+(?:invariant|asError|createErrorObj).+/gm; | |
const AT_TEST_HELPERS_RE = /^\s*(at|[^@]+@).+test\-helpers.+/gm; | |
// const AT_WEB_MODULES = /^\s*(at|[^@]+@).+(web_modules|\-[a-f0-9]{8}\.js).*/gm | |
const AT_ASSORTED_HELPERS_RE = | |
/^\s*(at|[^@]+@).+(debounce|invariant|iife)\.[tj]s.*/gm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Slot, component$ } from "@builder.io/qwik"; | |
import type { JSX } from "@builder.io/qwik/jsx-runtime"; | |
import { twMerge } from "tailwind-merge"; | |
/** Comes from {@link tw} template. */ | |
type TwString = string & { | |
_tw: true; | |
}; | |
/** This applies types to somethign like `tw.div` or `tw.h1`, which will leverage the types from `JSX.IntrinsicElements` */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import type { NoSerialize, Signal } from "@builder.io/qwik"; | |
import { noSerialize, useSignal, useVisibleTask$ } from "@builder.io/qwik"; | |
import type { IFuseOptions } from "fuse.js"; | |
import Fuse from "fuse.js"; | |
export function useFuseSearch<T>( | |
config: { | |
items: Signal<T[]> | T[]; | |
search: Signal<string> | string; | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class OpenPromise<T> implements PromiseLike<T> { | |
private inner: Promise<T> | |
private resolved?: [T] | |
public resolve = (item: T) => { | |
this.resolved = [item] | |
} | |
private rejected?: [any] | |
public reject = (error: any) => { | |
this.rejected = [error] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ( |