Skip to content

Instantly share code, notes, and snippets.

@bigmistqke
bigmistqke / mutable.ts
Created January 5, 2025 22:57
custom mutable store
import { createSignal, batch } from "solid-js";
const $LENGTH = Symbol();
const PROXIES = new WeakMap();
function createMutable<T extends object>(root: T) {
function signal<T>(initialValue: T) {
const [get, set] = createSignal(initialValue);
return { get, set };
}
@bigmistqke
bigmistqke / createPatchProxy.ts
Last active January 2, 2025 02:16
createPatchProxy
type Patch = {
op: "add" | "update" | "delete";
path: string[];
value?: any;
};
const $PATCH = Symbol();
function createPatchProxy<T extends object>(
target: T,
// Generated by dts-bundle-generator v9.5.1
declare class AudioSampleEntry extends SampleEntry {
channel_count: number;
samplesize: number;
samplerate: number;
constructor(type: string, size?: number);
parse(stream: MultiBufferStream): void;
/** @bundle box-codecs.js */
isAudio(): boolean;
import { render } from "solid-js/web";
function format(source: string) {
if (source.endsWith("\n")) {
return source + "\n";
}
return source;
}
function unformat(source: string) {
if (source.endsWith("\n")) {
@bigmistqke
bigmistqke / source.tsx
Created September 25, 2024 12:06
repl @lume/element test
import { render } from "solid-js@1.8.22/web"
import h from "solid-js@1.8.22/h";
import { element, Element, stringAttribute } from "@lume/element"
import {createSignal} from "solid-js@1.8.22"
@element("repls-repl")
class ReplElement extends Element {
@stringAttribute value = "null"
template = () => <>{this.value}</>
}
@bigmistqke
bigmistqke / slots.tsx
Last active September 3, 2024 16:19
solid-slots
import {
children,
createRenderEffect,
type ParentProps,
onCleanup,
createMemo,
type JSX,
mergeProps,
} from "solid-js";
@bigmistqke
bigmistqke / struct.ts
Created August 29, 2024 23:25
struct utility
const s = {
int64: <T extends string>(key: T) => [key, 8] as const,
uint64: <T extends string>(key: T) => [key, 8] as const,
float32: <T extends string>(key: T) => [key, 4] as const,
float64: <T extends string>(key: T) => [key, 8] as const,
int8: <T extends string>(key: T) => [key, 1] as const,
int16: <T extends string>(key: T) => [key, 2] as const,
int32: <T extends string>(key: T) => [key, 4] as const,
uint8: <T extends string>(key: T) => [key, 1] as const,
uint8clamped: <T extends string>(key: T) => [key, 1] as const,
@bigmistqke
bigmistqke / format.ts
Last active August 28, 2024 19:52
format logs
import { type JSX } from "solid-js";
const LOG_SYMBOL = Symbol("log");
type Log = [source: string, ...styles: string[]] & {
[LOG_SYMBOL]: true;
};
type ValidValue = [string, JSX.CSSProperties?] | Log;
function fragment(array: Log[]): Log {
@bigmistqke
bigmistqke / index.d.ts
Last active July 9, 2024 22:38
fixed solid-nativescript types
import { Style, ViewBase } from "@nativescript/core";
import {
Document,
DOMEvent,
HTMLElementTagNameMap,
Node,
NSComponentsMap,
NSCustomComponentsMap,
PseudoElementsMap,
} from "dominative";
@bigmistqke
bigmistqke / process-props.tsx
Last active June 3, 2024 17:22
`processProps` and `defaultProps` utilities for solid-js
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)[],