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 { MergeProps, mergeProps, splitProps } from 'solid-js' | |
type KeyOfOptionals<T> = keyof { | |
[K in keyof T as T extends Record<K, T[K]> ? never : K]: T[K] | |
} | |
export function processProps< | |
TProps extends Record<string, any>, | |
TKey extends KeyOfOptionals<TProps>, | |
TSplit extends (keyof TProps)[], |
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 { Accessor } from 'solid-js' | |
/** | |
* Executes a callback with a value derived from an accessor if the value is truthy. | |
* | |
* @param accessor The value or function returning a value that is checked for truthiness. | |
* @param callback The callback function to be executed if the accessor's value is truthy. | |
* @returns The result of the callback if executed, otherwise undefined. | |
*/ | |
export function when< |
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 { Monaco } from '@monaco-editor/loader' | |
const regex = { | |
import: | |
/import\s+(?:type\s+)?(?:\{[^}]*\}|\* as [^\s]+|\w+\s*,\s*\{[^}]*\}|\w+)?\s+from\s*"(.+?)";?/gs, | |
export: | |
/export\s+(?:\{[^}]*\}|\* as [^\s]+|\*|\w+(?:,\s*\{[^}]*\})?|type \{[^}]*\})?\s+from\s*"(.+?)";?/gs, | |
require: /require\s*\(["']([^"']+)["']\)/g, | |
} | |
export class TypeRegistry { |
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
/** | |
* array extended with mutable/in-place array-methods | |
*/ | |
class ArrayInPlace<T = number> extends Array { | |
commands: Command<T>[] = []; | |
constructor(values: T[]) { | |
super(); | |
Array.prototype.push.apply(this, values); | |
} |
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
class ArrayInPlace<T = number> extends Array { | |
commands: Command<T>[] = []; | |
constructor(values: T[]) { | |
super(); | |
for (let i = 0; i < Math.floor(values.length / 100_000); i++) { | |
Array.prototype.push.apply( | |
this, | |
values.slice(i * 100_000, (i + 1) * 100_000), | |
); | |
} |
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 ts from 'typescript' | |
type Accessor<T> = () => T | |
const tsModules: Record<string, { content: string; version: number }> = {} | |
function modifyImportPaths(code: string) { | |
return code.replace(/import ([^"']+) from ["']([^"']+)["']/g, (match, varName, path) => { | |
if (path.startsWith('blob:') || path.startsWith('http:') || path.startsWith('https:') || path.startsWith('.')) { | |
return `import ${varName} from "${path}"` | |
} else { |
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 { | |
onCleanup, | |
createMemo, | |
createSignal, | |
type Accessor, | |
createEffect, | |
createResource, | |
} from "solid-js"; | |
function modifyImportPaths(code) { |
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 genPadding = (layer: number) => | |
new Array(layer).fill(" ").flat().join(""); | |
function genObject({object}: any, layer: number) { | |
const entries = Object.entries(object); | |
let result = "{\n"; | |
const padding = genPadding(layer); | |
for (const [key, value] of entries) { | |
result += padding; | |
result += `${key}: ${valibotToTs(value, layer + 1)},\n`; |
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 { Accessor } from 'solid-js' | |
export function when< | |
TAccessors extends Array<Accessor<any>>, | |
const TValues extends { [TKey in keyof TAccessors]: Exclude<ReturnType<TAccessors[TKey]>, null | undefined | false> } | |
>(...accessors: TAccessors) { | |
function callback<const TResult>(): TValues | undefined | |
function callback<const TResult>(callback: (...values: TValues) => TResult): TResult | undefined | |
function callback<const TResult>(callback?: (...values: TValues) => TResult) { | |
const values = new Array(accessors.length) |
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 { Vector } from '@ndbx/types'; | |
import { MouseEvent as MouseEventReact } from 'react'; | |
/** | |
* cursor | |
* | |
* @param e MouseEvent | |
* @param callback called every onMouseMove | |
* @returns Promise resolved onMouseUp | |
*/ |
NewerOlder