Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
chore(fe): remove dead code in /core (#6213)
Seamus2afb675a71a9
diff --git a/apps/web/src/components/app/split-layout/componentRegistry.tsx b/apps/web/src/components/app/split-layout/componentRegistry.tsxindex 4bf7823555..5fde403214 100644--- a/apps/web/src/components/app/split-layout/componentRegistry.tsx+++ b/apps/web/src/components/app/split-layout/componentRegistry.tsx@@ -735,14 +735,6 @@ if (LOCAL_ONLY) {'data',lazy(() => import('@core/internal/DataDebug')));- registerComponent(- 'noise',- lazy(() => import('@core/internal/PcNoiseGridDemo'))- );- registerComponent(- 'svg-noise',- lazy(() => import('@core/internal/SvgNoiseGridDemo'))- );registerComponent('chat',lazy(() => import('@core/component/AI/component/debug/Component'))@@ -843,11 +835,6 @@ if (DEV_MODE_ENV) {));- // NOTE (seamus) : putting pixel icons on dev/staging for aidan- registerComponent(- 'pixel-icon',- lazy(() => import('@core/internal/PixelArtIconDemo'))- );registerComponent('md-parse',lazy(diff --git a/apps/web/src/features/auth/mobile-onboarding/MobileAuthWelcome.tsx b/apps/web/src/features/auth/mobile-onboarding/MobileAuthWelcome.tsxindex 3e78560daa..6a71ca4cb2 100644--- a/apps/web/src/features/auth/mobile-onboarding/MobileAuthWelcome.tsx+++ b/apps/web/src/features/auth/mobile-onboarding/MobileAuthWelcome.tsx@@ -1,5 +1,4 @@import { useAnalytics } from '@app/lib/analytics/analytics-context';-import { PcNoiseGrid } from '@core/component/PcNoiseGrid';import LogoIcon from '@icon/macro-logo.svg';import { useNavigate } from '@solidjs/router';import { Button, Surface } from '@ui';@@ -20,20 +19,6 @@ export function MobileAuthWelcome() {return (<div class="flex items-center justify-center size-full p-8 overflow-hidden relative">- <div class="inset-0 absolute text-edge bg-surface opacity-10 -z-1">- <PcNoiseGrid- cellSize={30}- warp={0}- crunch={0.2}- freq={0.001}- size={[0, 0.3]}- rounding={0}- fill={0}- stroke={1}- speed={[0.017, 0.209]}- />- </div>-<div class="w-full max-w-105"><Surface depth={1}><div class="flex flex-col items-center gap-2 py-10">diff --git a/apps/web/src/features/auth/mobile-onboarding/MobileOnboarding.tsx b/apps/web/src/features/auth/mobile-onboarding/MobileOnboarding.tsxindex c97539154f..4178b2441b 100644--- a/apps/web/src/features/auth/mobile-onboarding/MobileOnboarding.tsx+++ b/apps/web/src/features/auth/mobile-onboarding/MobileOnboarding.tsx@@ -1,5 +1,4 @@import { useAnalytics } from '@app/lib/analytics/analytics-context';-import { PcNoiseGrid } from '@core/component/PcNoiseGrid';import { useIsAuthenticated } from '@core/context/user';import LogoIcon from '@icon/macro-logo.svg';import { useNavigate } from '@solidjs/router';@@ -68,20 +67,6 @@ export function MobileOnboarding() {return (<div class="relative flex size-full overflow-hidden px-4 pt-[calc(var(--safe-top)+2rem)] pb-[calc(var(--safe-bottom)+2rem)]">- <div class="inset-0 absolute text-edge bg-surface opacity-10 -z-1">- <PcNoiseGrid- cellSize={30}- warp={0}- crunch={0.2}- freq={0.001}- size={[0, 0.3]}- rounding={0}- fill={0}- stroke={1}- speed={[0.017, 0.209]}- />- </div>-<Surface depth={1} class="flex flex-col mt-(--mobile-content-inset-top)"><div class="flex shrink-0 items-center justify-center pt-8 pb-4"><LogoIcon class="size-16 text-ink" />diff --git a/apps/web/src/features/channel-invitations/ChannelInviteAcceptance.test.tsx b/apps/web/src/features/channel-invitations/ChannelInviteAcceptance.test.tsxindex 8c8637f35a..2c8deb8e24 100644--- a/apps/web/src/features/channel-invitations/ChannelInviteAcceptance.test.tsx+++ b/apps/web/src/features/channel-invitations/ChannelInviteAcceptance.test.tsx@@ -65,10 +65,6 @@ vi.mock('@core/component/LoadingBlock', () => ({LoadingBlock: () => <div>Joining channel…</div>,}));-vi.mock('@core/component/PcNoiseGrid', () => ({- PcNoiseGrid: () => null,-}));-import { ChannelInviteAcceptance } from './ChannelInviteAcceptance';let dispose: (() => void) | undefined;diff --git a/apps/web/src/features/channel-invitations/ChannelInviteAcceptance.tsx b/apps/web/src/features/channel-invitations/ChannelInviteAcceptance.tsxindex dea96637a7..3d4812bf10 100644--- a/apps/web/src/features/channel-invitations/ChannelInviteAcceptance.tsx+++ b/apps/web/src/features/channel-invitations/ChannelInviteAcceptance.tsx@@ -1,5 +1,4 @@import { LoadingBlock } from '@core/component/LoadingBlock';-import { PcNoiseGrid } from '@core/component/PcNoiseGrid';import { ThrownResultError } from '@core/util/result';import LogoIcon from '@icon/macro-logo.svg';import UsersThreeIcon from '@phosphor/users-three.svg';@@ -45,20 +44,6 @@ export function ChannelInviteAcceptance() {return (<div class="flex items-center justify-center size-full p-8 overflow-hidden relative">- <div class="inset-0 absolute text-edge bg-surface opacity-10 -z-1">- <PcNoiseGrid- cellSize={30}- warp={0}- crunch={0.2}- freq={0.001}- size={[0, 0.3]}- rounding={0}- fill={0}- stroke={1}- speed={[0.017, 0.209]}- />- </div>-<div class="w-full max-w-105"><Surface><div class="flex flex-col gap-6 p-6">diff --git a/apps/web/src/features/onboarding/MobileWebSignupSent.tsx b/apps/web/src/features/onboarding/MobileWebSignupSent.tsxindex 069e9aebb5..1aacd4ecba 100644--- a/apps/web/src/features/onboarding/MobileWebSignupSent.tsx+++ b/apps/web/src/features/onboarding/MobileWebSignupSent.tsx@@ -1,6 +1,5 @@import { useAnalytics } from '@app/lib/analytics/analytics-context';import { MOBILE_WEB_SIGNUP_LEAD_VALUE } from '@app/lib/analytics/leadValues';-import { PcNoiseGrid } from '@core/component/PcNoiseGrid';import { getWebOrigin } from '@core/util/webOrigin';import LogoIcon from '@icon/macro-logo.svg';import { onMount } from 'solid-js';@@ -34,20 +33,6 @@ export default function MobileWebSignupSent(props: Props) {return (<div class="flex flex-col size-full p-6 overflow-hidden relative">- <div class="inset-0 absolute text-edge bg-surface opacity-10 -z-1">- <PcNoiseGrid- cellSize={30}- warp={0}- crunch={0.2}- freq={0.001}- size={[0, 0.3]}- rounding={0}- fill={0}- stroke={1}- speed={[0.017, 0.209]}- />- </div>-<div class="flex flex-col items-start gap-4 w-full max-w-md mx-auto mt-6"><LogoIcon class="size-16 text-accent self-center" /><h2 class="text-3xl font-semibold text-ink mt-3">diff --git a/apps/web/src/features/onboarding/MobileWebWelcome.tsx b/apps/web/src/features/onboarding/MobileWebWelcome.tsxindex e0a8ecf668..5a27a87bb7 100644--- a/apps/web/src/features/onboarding/MobileWebWelcome.tsx+++ b/apps/web/src/features/onboarding/MobileWebWelcome.tsx@@ -1,5 +1,4 @@import { useAnalytics } from '@app/lib/analytics/analytics-context';-import { PcNoiseGrid } from '@core/component/PcNoiseGrid';import LogoIcon from '@icon/macro-logo.svg';import { A } from '@solidjs/router';import { createSignal, onMount } from 'solid-js';@@ -22,20 +21,6 @@ export default function MobileWebWelcome(props: MobileWebWelcomeProps) {return (<div class="flex flex-col size-full p-6 overflow-hidden relative">- <div class="inset-0 absolute text-edge bg-surface opacity-10 -z-1">- <PcNoiseGrid- cellSize={30}- warp={0}- crunch={0.2}- freq={0.001}- size={[0, 0.3]}- rounding={0}- fill={0}- stroke={1}- speed={[0.017, 0.209]}- />- </div>-<div class="flex flex-col items-start gap-4 w-full max-w-md mx-auto mt-6"><LogoIcon class="size-16 text-accent self-center" /><h2 class="text-3xl font-semibold text-ink mt-3">Welcome to Macro.</h2>diff --git a/apps/web/src/features/team-invitations/TeamInviteAcceptance.tsx b/apps/web/src/features/team-invitations/TeamInviteAcceptance.tsxindex 99d8bf6278..de4f8440e3 100644--- a/apps/web/src/features/team-invitations/TeamInviteAcceptance.tsx+++ b/apps/web/src/features/team-invitations/TeamInviteAcceptance.tsx@@ -1,5 +1,4 @@import { LoadingBlock } from '@core/component/LoadingBlock';-import { PcNoiseGrid } from '@core/component/PcNoiseGrid';import { getDisplayName, tryMacroId } from '@core/user';import LogoIcon from '@icon/macro-logo.svg';import EnvelopeIcon from '@phosphor/envelope.svg';@@ -96,20 +95,6 @@ export function TeamInviteAcceptance() {}`}</style>- <div class="inset-0 absolute text-edge bg-surface opacity-10 -z-1">- <PcNoiseGrid- cellSize={30}- warp={0}- crunch={0.2}- freq={0.001}- size={[0, 0.3]}- rounding={0}- fill={0}- stroke={1}- speed={[0.017, 0.209]}- />- </div>-<div class="w-full max-w-105 invite-card"><Surface><div class="flex flex-col gap-6 p-6">diff --git a/apps/web/src/lib/baby-gl/glsl.ts b/apps/web/src/lib/baby-gl/glsl.tsdeleted file mode 100644index dcb5b27fad..0000000000--- a/apps/web/src/lib/baby-gl/glsl.ts+++ /dev/null@@ -1,44 +0,0 @@-type StringLike =- | string- | number- | boolean- | null- | undefined- | { toString(): string };--const toStr = (x: StringLike) =>- x == null ? '' : Array.isArray(x) ? x.join('') : String(x);--/**- * Glsl tagged templates. Trims outer blank lines, normalizes EOLs, and dedents- * to minimal indent.- *- * @example- * const shader = glsl`- * precision mediump float;- *- * void main() {- * gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);- * }- * `;- */-export function glsl(- strings: TemplateStringsArray,- ...exprs: StringLike[]-): string {- let out = '';- for (let i = 0; i < strings.length; i++) {- out += strings[i];- if (i < exprs.length) out += toStr(exprs[i]);- }-- out = out.replace(/\r\n?/g, '\n');-- // trim leading and trailing blank line- out = out.replace(/^\s*\n/, '').replace(/\n\s*$/, '');-- const matches = out.match(/^[ \t]*(?=\S)/gm);- const min = matches ? Math.min(...matches.map((s) => s.length)) : 0;- if (min > 0) out = out.replace(new RegExp(`^[ \\t]{${min}}`, 'gm'), '');- return out;-}diff --git a/apps/web/src/lib/baby-gl/index.ts b/apps/web/src/lib/baby-gl/index.tsdeleted file mode 100644index 55d68d33dd..0000000000--- a/apps/web/src/lib/baby-gl/index.ts+++ /dev/null@@ -1,3 +0,0 @@-export * from './glsl.js';-export * from './lib.js';-export * from './shaders/index.js';diff --git a/apps/web/src/lib/baby-gl/lib.ts b/apps/web/src/lib/baby-gl/lib.tsdeleted file mode 100644index fe0e6e2847..0000000000--- a/apps/web/src/lib/baby-gl/lib.ts+++ /dev/null@@ -1,316 +0,0 @@-export type ShaderKind = 'vertex' | 'fragment';-export type UniformKind = 'float' | 'vec2' | 'vec3' | 'vec4';--export type Vec2 = readonly [number, number];-export type Vec3 = readonly [number, number, number];-export type Vec4 = readonly [number, number, number, number];--export const vec2 = (x: number, y: number): Vec2 => [x, y];-export const vec3 = (x: number, y: number, z: number): Vec3 => [x, y, z];-export const vec4 = (x: number, y: number, z: number, w: number): Vec4 => [- x,- y,- z,- w,-];--export type ValueMap = {- float: number;- vec2: Vec2 | Float32Array;- vec3: Vec3 | Float32Array;- vec4: Vec4 | Float32Array;-};--export type UniformDef<T extends UniformKind = UniformKind> = {- type: T;- default: ValueMap[T];-};--export type UniformConfig = Record<string, UniformDef>;--export type UniformSchema = Record<string, UniformKind>;--export type UniformSetters<T extends UniformSchema> = {- [K in keyof T]: (value: ValueMap[T[K]]) => void;-};--export type UniformValues<T extends UniformSchema> = {- [K in keyof T]: ValueMap[T[K]];-};--type Meta = {- location: WebGLUniformLocation;- kind: UniformKind;-};--/**- * Format shader source with line numbers and error highlighting- */-function formatShaderWithLineNumbers(- source: string,- errorLine?: number-): string {- const lines = source.split('\n');- return lines- .map((line, index) => {- const lineNum = index + 1;- const prefix = lineNum.toString().padStart(3, ' ') + ': ';- const isErrorLine = errorLine && lineNum === errorLine;- return isErrorLine ? `>>> ${prefix}${line} <<<` : ` ${prefix}${line}`;- })- .join('\n');-}--function parseErrorLine(errorLog: string): number | undefined {- const match = errorLog.match(/ERROR:\s*\d+:(\d+):/);- return match ? parseInt(match[1], 10) : undefined;-}--function shaderError(- message: string,- source?: string,- type?: ShaderKind-): never {- let errorMessage = `Shader Error: ${message}`;- if (source) {- const errorLine = parseErrorLine(message);- errorMessage += `\n\n${type?.toUpperCase()} SHADER SOURCE:\n`;- errorMessage += formatShaderWithLineNumbers(source, errorLine);- }- throw new Error(errorMessage);-}--/**- * Compile a shader from source code.- * @param gl - The WebGL2RenderingContext.- * @param type - The type of shader to compile.- * @param src - The source code of the shader.- */-export function compileShader(- gl: WebGL2RenderingContext,- type: ShaderKind,- src: string-) {- const shader = gl.createShader(- type === 'vertex' ? gl.VERTEX_SHADER : gl.FRAGMENT_SHADER- );- if (!shader) {- throw new Error('failed to create shader');- }- gl.shaderSource(shader, src);- gl.compileShader(shader);- if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {- const errorLog = gl.getShaderInfoLog(shader) || 'Unknown compilation error';- shaderError(`failed to compile ${type} shader: ${errorLog}`, src, type);- }- return shader;-}--/**- * Create, link and validate a program from vertex and fragment shaders.- * @param gl - The WebGL2RenderingContext.- * @param vertexShader - The vertex shader.- * @param fragmentShader - The fragment shader.- * @returns- */-export function createProgram(- gl: WebGL2RenderingContext,- vertexShader: WebGLShader,- fragmentShader: WebGLShader-) {- const program = gl.createProgram();- if (!program) {- throw new Error('failed to create program');- }- gl.attachShader(program, vertexShader);- gl.attachShader(program, fragmentShader);- gl.linkProgram(program);- if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {- shaderError(`failed to link program: ${gl.getProgramInfoLog(program)}`);- }- gl.useProgram(program);- return program;-}--function ensureProgram(gl: WebGL2RenderingContext, program: WebGLProgram) {- if (- (gl.getParameter(gl.CURRENT_PROGRAM) as WebGLProgram | null) !== program- ) {- gl.useProgram(program);- }-}--/**- * Get a typed uniform setter for a given program and config. This will log- * errors to the console if the uniform config/schema does not match the- * the shader program.- * @param gl - WebGL2RenderingContext- * @param program - WebGLProgram- * @param config - A custom uniform config object.- * @returns A object with a use utility for setting uniforms.- * @example- * const uniformsSchema = {- * uParam: {type: 'float', default: 0.5},- * uColor: {type: 'vec3', default: vec3(0, 1, 0)},- * };- * const { set, uniforms } = bindUniforms(gl, program, uniformsSchema);- *- * // this will work- * set({- * uParam: 0.7,- * uColor: vec3(1, 0, 0),- * });- *- * // so will- * uniforms.uColor(vec3(1, 0, 1));- */-export function bindUniforms<T extends UniformConfig>(- gl: WebGL2RenderingContext,- program: WebGLProgram,- config: T-) {- const meta: Record<string, Meta> = {};-- const schema: Record<string, UniformKind> = {};- const defaults: Record<string, any> = {};-- for (const [name, def] of Object.entries(config)) {- schema[name] = def.type;- defaults[name] = def.default;- }-- for (const [name, kind] of Object.entries(schema)) {- const loc = gl.getUniformLocation(program, name);- if (!loc) {- console.error(`Uniform "${name}" not found on program`);- continue;- }- meta[name] = { location: loc, kind };- }-- const use = () => {- ensureProgram(gl, program);- };-- function setOne(m: Meta, v: any) {- switch (m.kind) {- case 'float':- gl.uniform1f(m.location, v as number);- break;- case 'vec2':- gl.uniform2fv(m.location, v as Vec2 | Float32Array);- break;- case 'vec3':- gl.uniform3fv(m.location, v as Vec3 | Float32Array);- break;- case 'vec4':- gl.uniform4fv(m.location, v as Vec4 | Float32Array);- break;- }- }-- const uniforms = {} as UniformSetters<- T extends UniformConfig ? { [K in keyof T]: T[K]['type'] } : never- >;- for (const [name, m] of Object.entries(meta)) {- uniforms[name as keyof typeof uniforms] = (value: any) => {- use();- setOne(m, value);- };- }-- function set(- values: Partial<- UniformValues<- T extends UniformConfig ? { [K in keyof T]: T[K]['type'] } : never- >- >- ) {- use();- for (const k in values) {- const m = meta[k];- if (!m) continue;- setOne(m, values[k as keyof typeof values]);- }- }-- // Apply defaults immediately- use();- for (const [name, value] of Object.entries(defaults)) {- const m = meta[name];- if (m) setOne(m, value);- }-- return { use: () => ensureProgram(gl, program), uniforms, set };-}--export type Drawable = {- draw: (options?: { bind?: boolean }) => void;- bind: () => void;- delete: () => void;-};--/**- * Create a full-screen quad drawable (fills the screen in clip space)- * @param gl- * @param program- * @param positionAttribName is the name of the attribute in the shader that should- * receive the position data. Throws an ERROR if the attribute is not found.- * @returns- */-export function fullScreenQuad(- gl: WebGL2RenderingContext,- program: WebGLProgram,- positionAttribName: string-): Drawable {- const aPosition = gl.getAttribLocation(program, positionAttribName);- if (aPosition === -1) {- throw new Error(`Attribute ${positionAttribName} not found`);- }-- const vao = gl.createVertexArray();- gl.bindVertexArray(vao);-- const quad = gl.createBuffer();- gl.bindBuffer(gl.ARRAY_BUFFER, quad);- // TRIANGLE_STRIP positions for a full-screen quad.- gl.bufferData(- gl.ARRAY_BUFFER,- new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]),- gl.STATIC_DRAW- );- gl.vertexAttribPointer(aPosition, 2, gl.FLOAT, false, 0, 0);- gl.enableVertexAttribArray(aPosition);-- gl.bindVertexArray(null);-- return {- draw: (options = { bind: true }) => {- if (options.bind !== false) {- gl.bindVertexArray(vao);- }- gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);- },- bind: () => {- gl.bindVertexArray(vao);- },- delete: () => {- gl.deleteVertexArray(vao);- gl.deleteBuffer(quad);- },- };-}--/**- * Measure the css pixel size of a canvas element.- * @param canvas- * @returns A width, height tuple.- */-export function getCanvasSize(canvas: HTMLCanvasElement) {- const dpr = window.devicePixelRatio || 1;- const cssW = canvas.clientWidth || 1;- const cssH = canvas.clientHeight || 1;- const w = Math.max(1, Math.floor(cssW * dpr));- const h = Math.max(1, Math.floor(cssH * dpr));- return [w, h] as Vec2;-}diff --git a/apps/web/src/lib/baby-gl/shaders/boxSdf.ts b/apps/web/src/lib/baby-gl/shaders/boxSdf.tsdeleted file mode 100644index acf0968183..0000000000--- a/apps/web/src/lib/baby-gl/shaders/boxSdf.ts+++ /dev/null@@ -1,6 +0,0 @@-export const boxSdf = `- float box(vec2 position, vec2 halfSize, float cornerRadius) {- position = abs(position) - halfSize + cornerRadius;- return length(max(position, 0.0)) + min(max(position.x, position.y), 0.0) - cornerRadius;- }-`;diff --git a/apps/web/src/lib/baby-gl/shaders/index.ts b/apps/web/src/lib/baby-gl/shaders/index.tsdeleted file mode 100644index 5be073ea19..0000000000--- a/apps/web/src/lib/baby-gl/shaders/index.ts+++ /dev/null@@ -1,4 +0,0 @@-// Re-export all shader constants for easy importing-export { boxSdf } from './boxSdf.js';-export { simplexNoise2d } from './simplexNoise2d.js';-export { simplexNoise3d } from './simplexNoise3d.js';diff --git a/apps/web/src/lib/baby-gl/shaders/simplexNoise2d.ts b/apps/web/src/lib/baby-gl/shaders/simplexNoise2d.tsdeleted file mode 100644index eef4252347..0000000000--- a/apps/web/src/lib/baby-gl/shaders/simplexNoise2d.ts+++ /dev/null@@ -1,66 +0,0 @@-export const simplexNoise2d = `- // Description : Array and textureless GLSL 2D simplex noise function.- // Author : Ian McEwan, Ashima Arts.- // Maintainer : stegu- // Lastmod : 20110822 (ijm)- // License : Copyright (C) 2011 Ashima Arts. All rights reserved.- // Distributed under the MIT License. See LICENSE file.- // https://github.com/ashima/webgl-noise- // https://github.com/stegu/webgl-noise- //-- vec3 mod289(vec3 x) {- return x - floor(x * (1.0 / 289.0)) * 289.0;- }-- vec2 mod289(vec2 x) {- return x - floor(x * (1.0 / 289.0)) * 289.0;- }-- vec3 permute(vec3 x) {- return mod289(((x*34.0)+10.0)*x);- }-- float snoise(vec2 v) {- const vec4 C = vec4(0.211324865405187, // (3.0-sqrt(3.0))/6.0- 0.366025403784439, // 0.5*(sqrt(3.0)-1.0)- -0.577350269189626, // -1.0 + 2.0 * C.x- 0.024390243902439); // 1.0 / 41.0- // First corner- vec2 i = floor(v + dot(v, C.yy) );- vec2 x0 = v - i + dot(i, C.xx);-- // Other corners- vec2 i1;- i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);- vec4 x12 = x0.xyxy + C.xxzz;- x12.xy -= i1;-- // Permutations- i = mod289(i); // Avoid truncation effects in permutation- vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 ))- + i.x + vec3(0.0, i1.x, 1.0 ));-- vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0);- m = m*m ;- m = m*m ;-- // Gradients: 41 points uniformly over a line, mapped onto a diamond.- // The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287)-- vec3 x = 2.0 * fract(p * C.www) - 1.0;- vec3 h = abs(x) - 0.5;- vec3 ox = floor(x + 0.5);- vec3 a0 = x - ox;-- // Normalise gradients implicitly by scaling m- // Approximation of: m *= inversesqrt( a0*a0 + h*h );- m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h );-- // Compute final noise value at P- vec3 g;- g.x = a0.x * x0.x + h.x * x0.y;- g.yz = a0.yz * x12.xz + h.yz * x12.yw;- return 130.0 * dot(m, g);- }-`;diff --git a/apps/web/src/lib/baby-gl/shaders/simplexNoise3d.ts b/apps/web/src/lib/baby-gl/shaders/simplexNoise3d.tsdeleted file mode 100644index 0293fbc044..0000000000--- a/apps/web/src/lib/baby-gl/shaders/simplexNoise3d.ts+++ /dev/null@@ -1,102 +0,0 @@-export const simplexNoise3d = `- //- // Description : Array and textureless GLSL 2D/3D/4D simplex- // noise functions.- // Author : Ian McEwan, Ashima Arts.- // Maintainer : ijm- // Lastmod : 20110822 (ijm)- // License : Copyright (C) 2011 Ashima Arts. All rights reserved.- // Distributed under the MIT License. See LICENSE file.- // https://github.com/ashima/webgl-noise- //-- vec3 mod289(vec3 x) {- return x - floor(x * (1.0 / 289.0)) * 289.0;- }-- vec4 mod289(vec4 x) {- return x - floor(x * (1.0 / 289.0)) * 289.0;- }-- vec4 permute(vec4 x) {- return mod289(((x*34.0)+1.0)*x);- }-- vec4 taylorInvSqrt(vec4 r) {- return 1.79284291400159 - 0.85373472095314 * r;- }-- float snoise(vec3 v) {- const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;- const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);-- // First corner- vec3 i = floor(v + dot(v, C.yyy) );- vec3 x0 = v - i + dot(i, C.xxx) ;-- // Other corners- vec3 g = step(x0.yzx, x0.xyz);- vec3 l = 1.0 - g;- vec3 i1 = min( g.xyz, l.zxy );- vec3 i2 = max( g.xyz, l.zxy );-- // x0 = x0 - 0.0 + 0.0 * C.xxx;- // x1 = x0 - i1 + 1.0 * C.xxx;- // x2 = x0 - i2 + 2.0 * C.xxx;- // x3 = x0 - 1.0 + 3.0 * C.xxx;- vec3 x1 = x0 - i1 + C.xxx;- vec3 x2 = x0 - i2 + C.yyy; // 2.0*C.x = 1/3 = C.y- vec3 x3 = x0 - D.yyy; // -1.0+3.0*C.x = -0.5 = -D.y-- // Permutations- i = mod289(i);- vec4 p = permute( permute( permute(- i.z + vec4(0.0, i1.z, i2.z, 1.0 ))- + i.y + vec4(0.0, i1.y, i2.y, 1.0 ))- + i.x + vec4(0.0, i1.x, i2.x, 1.0 ));-- // Gradients: 7x7 points over a square, mapped onto an octahedron.- // The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294)- float n_ = 0.142857142857; // 1.0/7.0- vec3 ns = n_ * D.wyz - D.xzx;-- vec4 j = p - 49.0 * floor(p * ns.z * ns.z); // mod(p,7*7)-- vec4 x_ = floor(j * ns.z);- vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N)-- vec4 x = x_ *ns.x + ns.yyyy;- vec4 y = y_ *ns.x + ns.yyyy;- vec4 h = 1.0 - abs(x) - abs(y);-- vec4 b0 = vec4( x.xy, y.xy );- vec4 b1 = vec4( x.zw, y.zw );-- // vec4 s0 = vec4(lessThan(b0,0.0))*2.0 - 1.0;- // vec4 s1 = vec4(lessThan(b1,0.0))*2.0 - 1.0;- vec4 s0 = floor(b0)*2.0 + 1.0;- vec4 s1 = floor(b1)*2.0 + 1.0;- vec4 sh = -step(h, vec4(0.0));-- vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy;- vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww;-- vec3 p0 = vec3(a0.xy,h.x);- vec3 p1 = vec3(a0.zw,h.y);- vec3 p2 = vec3(a1.xy,h.z);- vec3 p3 = vec3(a1.zw,h.w);-- // Normalise gradients- vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));- p0 *= norm.x;- p1 *= norm.y;- p2 *= norm.z;- p3 *= norm.w;-- // Mix final noise value- vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);- m = m * m;- return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),- dot(p2,x2), dot(p3,x3) ) );- }-`;diff --git a/apps/web/src/lib/core/component/ContextMenu.tsx b/apps/web/src/lib/core/component/ContextMenu.tsxindex a62af40040..fd4e0a5a8b 100644--- a/apps/web/src/lib/core/component/ContextMenu.tsx+++ b/apps/web/src/lib/core/component/ContextMenu.tsx@@ -272,16 +272,6 @@ export function MenuGroup(props: { children: JSX.Element; class?: string }) {);}-export function GroupLabel(props: { children: JSX.Element }) {- return (- <ContextMenu.GroupLabel- class={cn(MENU_ITEM_CLASS, 'text-xs! text-ink-extra-muted')}- >- {props.children}- </ContextMenu.GroupLabel>- );-}-export function MenuSeparator() {return (<ContextMenu.Separator class="my-1.5 -mx-1.5 w-[calc(100%+0.75rem)] border-t border-edge" />diff --git a/apps/web/src/lib/core/component/PcNoiseGrid.tsx b/apps/web/src/lib/core/component/PcNoiseGrid.tsxdeleted file mode 100644index c06fa9cbbd..0000000000--- a/apps/web/src/lib/core/component/PcNoiseGrid.tsx+++ /dev/null@@ -1,210 +0,0 @@-import {- bindUniforms,- boxSdf,- compileShader,- createProgram,- fullScreenQuad,- getCanvasSize,- glsl,- simplexNoise3d,- type Vec3,- vec2,- vec3,-} from '@baby-gl';-import { oklchToRgb } from '@core/util/oklchToRgb';-import { withRecall } from '@core/util/withRecall';-import { createEffect, onCleanup, onMount } from 'solid-js';--const vert = glsl`- precision mediump float;- attribute vec2 aPos;-- varying vec2 vUv;-- void main() {- vUv = aPos * 0.5 + 0.5;- gl_Position = vec4(aPos, 0.0, 1.0);- }-`;--const frag = glsl`- precision mediump float;-- varying vec2 vUv;-- uniform float uTime;- uniform float uCellSize;- uniform float uWarp;- uniform float uCrunch;- uniform float uRounding;- uniform float uFreq;- uniform float uFill;- uniform float uStroke;- uniform float uCircleMask;-- uniform vec2 uSize;- uniform vec2 uSpeed;-- uniform vec3 uBg;- uniform vec3 uFg;-- ${boxSdf}- ${simplexNoise3d}-- void main() {- vec2 p = gl_FragCoord.xy;- vec2 cellIndex = floor(p / uCellSize);- vec2 cellOrigin = cellIndex * uCellSize;- vec2 cellCenter = cellOrigin + 0.5 * uCellSize;-- // Local coords in pixels centered at cell center- vec2 local = p - cellCenter;- vec2 offset = uTime * uSpeed;-- vec2 sampleCoord = cellCenter * uFreq;- float noiseOffsetX = snoise(vec3( sampleCoord.x, sampleCoord.y, uTime * uSpeed + 400.0 ));- float noiseOffsetY = snoise(vec3( sampleCoord.y, sampleCoord.y, uTime * uSpeed + 100.0 ));-- vec2 distortedSampleCoord = mix(sampleCoord, sampleCoord + vec2(noiseOffsetX, noiseOffsetY), uWarp);-- float sample = snoise(vec3( distortedSampleCoord.x, distortedSampleCoord.y, uTime * uSpeed ));- sample = 0.5 + 0.5 * sample; // Remap noise to [0,1]- sample = smoothstep(uCrunch, 1.0 - uCrunch, sample);-- // Apply circle mask- vec2 screenCenter = vUv - 0.5;- float circleDist = length(screenCenter);- float circleRadius = 0.5;- float circleMask = 1.0 - smoothstep(circleRadius * (1.0 - uCircleMask), circleRadius, circleDist);- sample *= mix(1.0, circleMask, step(0.001, uCircleMask));-- float halfMin = uSize.x * uCellSize;- float halfMax = uSize.y * uCellSize;- float halfSize = mix(halfMin, halfMax, sample);-- float d = box(local, vec2(halfSize), min(uRounding, halfSize));- float fill = smoothstep(0.0, 0.1, d);- float stroke = smoothstep(0.9, 1.0, abs(abs(d) - 0.5));- float factor = 1.0 - clamp(fill * uFill + stroke * uStroke, 0.0, 1.0);-- vec3 col = mix(uBg, uFg, factor);- gl_FragColor = vec4(col, 1.0);- }-`;--const uniformConfig = {- uTime: { type: 'float' as const, default: 0 },- uCellSize: { type: 'float' as const, default: 100 },- uWarp: { type: 'float' as const, default: 0.2 },- uCrunch: { type: 'float' as const, default: 0.0 },- uFreq: { type: 'float' as const, default: 0.0002 },- uSpeed: { type: 'vec2' as const, default: vec2(0.4, 0.4) },- uSize: { type: 'vec2' as const, default: vec2(0.05, 0.45) },- uRounding: { type: 'float' as const, default: 5 },- uBg: { type: 'vec3' as const, default: vec3(0, 0, 0) },- uFg: { type: 'vec3' as const, default: vec3(1, 1, 1) },- uFill: { type: 'float' as const, default: 1 },- uStroke: { type: 'float' as const, default: 0 },- uCircleMask: { type: 'float' as const, default: 0 },-};--export function PcNoiseGrid(props: {- cellSize?: number;- warp?: number;- crunch?: number;- freq?: number;- size?: [number, number];- rounding?: number;- fill?: number;- stroke?: number;- speed?: [number, number];- circleMask?: number;-}) {- let canvas!: HTMLCanvasElement;- let animationId: number;-- const getRgbFromOklch = withRecall((oklch: string) =>- oklchToRgb(oklch, { gammaCorrect: true, normalized: true })- );- onCleanup(() => {- getRgbFromOklch.clear();- });-- onMount(() => {- try {- const gl = canvas.getContext('webgl2');- if (!gl) {- throw new Error('WebGL2 not supported');- }-- const extractColors = () => {- const computedStyle = getComputedStyle(canvas);- const bgValue = computedStyle- .getPropertyValue('background-color')- .trim();- const fgValue = computedStyle.getPropertyValue('color').trim();- const bg = (getRgbFromOklch(bgValue) || [0, 0, 0]) as any as Vec3;- const fg = (getRgbFromOklch(fgValue) || [1, 1, 1]) as any as Vec3;- return { fg, bg };- };-- const vs = compileShader(gl, 'vertex', vert);- const fs = compileShader(gl, 'fragment', frag);- const program = createProgram(gl, vs, fs);- const quad = fullScreenQuad(gl, program, 'aPos');-- const { set } = bindUniforms(gl, program, uniformConfig);-- const animate = () => {- const currentTime = performance.now() / 1000;- const [w, h] = getCanvasSize(canvas);- if (canvas.width !== w || canvas.height !== h) {- canvas.width = w;- canvas.height = h;- }- gl.viewport(0, 0, w, h);- set({ uTime: currentTime });- const { fg, bg } = extractColors();- set({ uFg: fg, uBg: bg });- quad.draw();- animationId = requestAnimationFrame(animate);- };-- // Start animation loop- animate();-- onCleanup(() => {- if (animationId) {- cancelAnimationFrame(animationId);- }- quad.delete();- gl.deleteProgram(program);- gl.deleteShader(vs);- gl.deleteShader(fs);- });-- createEffect(() => {- if (props.cellSize !== undefined) set({ uCellSize: props.cellSize });- if (props.circleMask !== undefined)- set({ uCircleMask: props.circleMask });- if (props.crunch !== undefined) set({ uCrunch: props.crunch });- if (props.fill !== undefined) set({ uFill: props.fill });- if (props.freq !== undefined) set({ uFreq: props.freq });- if (props.rounding !== undefined) set({ uRounding: props.rounding });- if (props.size !== undefined) set({ uSize: props.size });- if (props.speed !== undefined) set({ uSpeed: props.speed });- if (props.stroke !== undefined) set({ uStroke: props.stroke });- if (props.warp !== undefined) set({ uWarp: props.warp });- });- } catch (error) {- console.error(error);- }- });-- return (- <canvas- ref={canvas}- class="pointer-events-none bg-inherit size-full block"- />- );-}diff --git a/apps/web/src/lib/core/component/Slider.tsx b/apps/web/src/lib/core/component/Slider.tsxdeleted file mode 100644index 1d97ca723e..0000000000--- a/apps/web/src/lib/core/component/Slider.tsx+++ /dev/null@@ -1,152 +0,0 @@-import { createSignal } from 'solid-js';--interface SliderProps {- label: string;- value: number;- onChange: (value: number) => void;- min?: number;- max?: number;- step?: number;- decimals?: number;- class?: string;-}--export function DebugSlider(props: SliderProps) {- const min = () => props.min ?? 0;- const max = () => props.max ?? 100;- const step = () => props.step ?? 1;- const decimals = () => props.decimals ?? (step() < 1 ? 3 : 0);-- let sliderRef!: HTMLDivElement;- const [isDragging, setIsDragging] = createSignal(false);-- const percentage = () => {- const range = max() - min();- return range === 0 ? 0 : ((props.value - min()) / range) * 100;- };-- const formatValue = (value: number) => {- return decimals() > 0 ? value.toFixed(decimals()) : value.toString();- };-- const clampValue = (value: number) => {- const clamped = Math.max(min(), Math.min(max(), value));- if (step() > 0) {- return Math.round(clamped / step()) * step();- }- return clamped;- };-- const handleInputChange = (e: Event) => {- const target = e.target as HTMLInputElement;- const value = parseFloat(target.value);- if (!isNaN(value)) {- props.onChange(clampValue(value));- }- };-- const handleSliderMouseDown = (e: MouseEvent) => {- e.preventDefault();- setIsDragging(true);- updateValueFromMouse(e);- sliderRef.focus();-- const handleMouseMove = (e: MouseEvent) => {- if (isDragging()) {- updateValueFromMouse(e);- }- };-- const handleMouseUp = () => {- setIsDragging(false);- document.removeEventListener('mousemove', handleMouseMove);- document.removeEventListener('mouseup', handleMouseUp);- };-- document.addEventListener('mousemove', handleMouseMove);- document.addEventListener('mouseup', handleMouseUp);- };-- const updateValueFromMouse = (e: MouseEvent) => {- const rect = sliderRef.getBoundingClientRect();- const x = e.clientX - rect.left;- const percent = Math.max(0, Math.min(1, x / rect.width));- const range = max() - min();- const newValue = min() + percent * range;- props.onChange(clampValue(newValue));- };-- const handleKeyDown = (e: KeyboardEvent) => {- const stepSize = e.shiftKey ? step() * 10 : step();- let newValue = props.value;-- switch (e.key) {- case 'ArrowLeft':- case 'ArrowDown':- e.preventDefault();- newValue = props.value - stepSize;- break;- case 'ArrowRight':- case 'ArrowUp':- e.preventDefault();- newValue = props.value + stepSize;- break;- case 'Home':- e.preventDefault();- newValue = min();- break;- case 'End':- e.preventDefault();- newValue = max();- break;- default:- return;- }-- props.onChange(clampValue(newValue));- };-- return (- <div class="flex flex-row items-center w-full justify-between gap-1">- <label class="text-xs font-mono text-ink-muted min-w-18 max-w-54 w-[30%] shrink-0 truncate pr-2">- {props.label}- </label>-- <div class="w-full shrink">- <div- ref={sliderRef}- class="relative h-6 bg-message select-none w-full focus:ring focus:ring-edge"- onMouseDown={handleSliderMouseDown}- onKeyDown={handleKeyDown}- tabIndex={0}- role="slider"- aria-label={props.label}- aria-valuemin={min()}- aria-valuemax={max()}- aria-valuenow={props.value}- >- {/* Fill */}- <div- class="absolute inset-y-0 left-0 bg-accent pointer-events-none"- style={{ width: `${percentage()}%` }}- />- </div>-- {/* Range indicators */}- {/*<div class="flex flex-row justify-between text-xs text-ink-muted/60 mt-1 h-3">- <span>{formatValue(min())}</span>- <span>{formatValue(max())}</span>- </div>*/}- </div>- <input- type="number"- value={formatValue(props.value)}- onInput={handleInputChange}- min={min()}- max={max()}- step={step()}- class="px-2 h-6 text-xs bg-message text-ink text-right rounded-xs font-mono w-18 shrink-0 focus:ring focus:ring-edge"- />- </div>- );-}diff --git a/apps/web/src/lib/core/internal/PcNoiseGridDemo.tsx b/apps/web/src/lib/core/internal/PcNoiseGridDemo.tsxdeleted file mode 100644index e93c688a6a..0000000000--- a/apps/web/src/lib/core/internal/PcNoiseGridDemo.tsx+++ /dev/null@@ -1,215 +0,0 @@-import { PcNoiseGrid } from '@core/component/PcNoiseGrid';-import { DebugSlider } from '@core/component/Slider';-import { Bar } from '@core/component/TopBar/Bar';-import { createSignal } from 'solid-js';--export default function PcNoiseGridDemo() {- const [cellSize, setCellSize] = createSignal(50);- const [warp, setWarp] = createSignal(0.2);- const [crunch, setCrunch] = createSignal(0.0);- const [freq, setFreq] = createSignal(0.0002);- const [sizeMin, setSizeMin] = createSignal(0.05);- const [sizeMax, setSizeMax] = createSignal(0.45);- const [rounding, setRounding] = createSignal(5);- const [fill, setFill] = createSignal(1);- const [stroke, setStroke] = createSignal(0);- const [speedX, setSpeedX] = createSignal(0.4);- const [speedY, setSpeedY] = createSignal(0.4);- const [circleMask, setCircleMask] = createSignal(0);-- const generateComponentCode = () => {- const props = [];- if (cellSize() !== 100) props.push(`cellSize={${cellSize()}}`);- if (warp() !== 0.2) props.push(`warp={${warp()}}`);- if (crunch() !== 0.0) props.push(`crunch={${crunch()}}`);- if (freq() !== 0.0002) props.push(`freq={${freq()}}`);- if (sizeMin() !== 0.05 || sizeMax() !== 0.45)- props.push(`size={[${sizeMin()}, ${sizeMax()}]}`);- if (rounding() !== 5) props.push(`rounding={${rounding()}}`);- if (fill() !== 1) props.push(`fill={${fill()}}`);- if (stroke() !== 0) props.push(`stroke={${stroke()}}`);- if (speedX() !== 0.4 || speedY() !== 0.4)- props.push(`speed={[${speedX()}, ${speedY()}]}`);- if (circleMask() !== 0) props.push(`circleMask={${circleMask()}}`);-- return `<PcNoiseGrid${props.length > 0 ? '\n ' + props.join('\n ') + '\n' : ''} />`;- };-- return (- <div class="flex flex-col size-full">- <Bar- left={<div class="p-2 text-sm w-2xl truncate">PcNoiseGrid</div>}- center={<div></div>}- ></Bar>- <div class="flex flex-row size-full">- {/* Left side - PcNoiseGrid preview */}- <div class="flex-1 relative bg-surface flex items-center justify-center p-4">- <div class="size-full flex items-center justify-center border border-edge">- <div class="size-full relative bg-surface text-accent">- <PcNoiseGrid- cellSize={cellSize()}- warp={warp()}- crunch={crunch()}- freq={freq()}- size={[sizeMin(), sizeMax()]}- rounding={rounding()}- fill={fill()}- stroke={stroke()}- speed={[speedX(), speedY()]}- circleMask={circleMask()}- />- </div>- </div>- </div>-- {/* Right side - Controls */}- <div class="w-[50%] max-w-lg bg-surface p-4 overflow-y-auto border-l border-edge border-dashed">- <h2 class="font-mono mb-6">PcNoiseGrid Generator</h2>-- <div class="space-y-6">- <DebugSlider- label="Cell Size"- value={cellSize()}- onChange={setCellSize}- min={20}- max={200}- step={1}- />-- <DebugSlider- label="Warp"- value={warp()}- onChange={setWarp}- min={0}- max={10}- step={0.001}- decimals={3}- />-- <DebugSlider- label="Crunch"- value={crunch()}- onChange={setCrunch}- min={0}- max={0.5}- step={0.001}- decimals={3}- />-- <DebugSlider- label="Frequency"- value={freq()}- onChange={setFreq}- min={0.00001}- max={0.001}- step={0.00001}- decimals={6}- />-- <DebugSlider- label="Size Min"- value={sizeMin()}- onChange={setSizeMin}- min={0}- max={1}- step={0.001}- decimals={3}- />-- <DebugSlider- label="Size Max"- value={sizeMax()}- onChange={setSizeMax}- min={0}- max={1}- step={0.001}- decimals={3}- />-- <DebugSlider- label="Rounding"- value={rounding()}- onChange={setRounding}- min={0}- max={50}- step={0.1}- decimals={1}- />-- <DebugSlider- label="Fill"- value={fill()}- onChange={setFill}- min={0}- max={1}- step={0.001}- decimals={3}- />-- <DebugSlider- label="Stroke"- value={stroke()}- onChange={setStroke}- min={0}- max={1}- step={0.001}- decimals={3}- />-- <DebugSlider- label="Speed X"- value={speedX()}- onChange={setSpeedX}- min={0}- max={1}- step={0.001}- decimals={3}- />-- <DebugSlider- label="Speed Y"- value={speedY()}- onChange={setSpeedY}- min={0}- max={1}- step={0.001}- decimals={3}- />-- <DebugSlider- label="Circle Mask"- value={circleMask()}- onChange={setCircleMask}- min={0}- max={1}- step={0.001}- decimals={3}- />- </div>-- {/* Actions */}- <div class="mt-8 space-y-3">- <button- onClick={() =>- navigator.clipboard.writeText(generateComponentCode())- }- class="w-full px-4 py-2 bg-ink-extra-muted text-surface font-medium"- >- Copy Component Code- </button>- </div>-- {/* Generated Code */}- <div class="mt-8">- <h3 class="font-mono text-ink-muted mb-3">Generated Code</h3>- <div class="p-4 rounded-xs bg-message overflow-x-auto max-h-96">- <pre class="text-xs font-mono whitespace-pre-wrap text-ink-muted">- {generateComponentCode()}- </pre>- </div>- </div>- </div>- </div>- </div>- );-}diff --git a/apps/web/src/lib/core/internal/PixelArtIconDemo.tsx b/apps/web/src/lib/core/internal/PixelArtIconDemo.tsxdeleted file mode 100644index 4d6c665dee..0000000000--- a/apps/web/src/lib/core/internal/PixelArtIconDemo.tsx+++ /dev/null@@ -1,1451 +0,0 @@-import { DebugSlider } from '@core/component/Slider';-import { Bar } from '@core/component/TopBar/Bar';-import clickOutside from '@core/directive/clickOutside';-import Rotate from '@phosphor/arrow-counter-clockwise.svg';-import Upload from '@phosphor/arrow-square-in.svg';-import Copy from '@phosphor/copy.svg';-import Download from '@phosphor/download.svg';-import Erase from '@phosphor/eraser.svg';-import MirrorX from '@phosphor/flip-horizontal.svg';-import MirrorY from '@phosphor/flip-vertical.svg';-import Fill from '@phosphor/paint-bucket.svg';-import Pencil from '@phosphor/pencil.svg';-import Plus from '@phosphor/plus.svg';-import Trash from '@phosphor/trash.svg';-import X from '@phosphor/x.svg';-import { createElementSize } from '@solid-primitives/resize-observer';-import { Button, ToggleSwitch } from '@ui';-import {- createEffect,- createMemo,- createResource,- createSignal,- For,- type JSX,- onCleanup,- onMount,- Show,-} from 'solid-js';-import { render } from 'solid-js/web';--false && clickOutside;--const BASE_PX_SIZE = 10;--/** Mirror a grid horizontally (flip left-right) */-function mirrorX(grid: boolean[][]): boolean[][] {- return grid.map((row) => [...row].reverse());-}--/** Mirror a grid vertically (flip top-bottom) */-function mirrorY(grid: boolean[][]): boolean[][] {- return [...grid].reverse();-}--/** Rotate a grid 90 degrees counter-clockwise */-function rotate90CC(grid: boolean[][]): boolean[][] {- const rows = grid.length;- const cols = grid[0]?.length || 0;-- if (rows === 0 || cols === 0) return grid;-- // For counter-clockwise: new[cols-1-j][i] = old[i][j]- const rotated: boolean[][] = Array(cols)- .fill(null)- .map(() => Array(rows).fill(false));-- for (let i = 0; i < rows; i++) {- for (let j = 0; j < cols; j++) {- rotated[cols - 1 - j][i] = grid[i][j];- }- }-- return rotated;-}--/** Uint8Array -> base64 string */-function toBase64(u8: Uint8Array): string {- if (typeof Buffer !== 'undefined') return Buffer.from(u8).toString('base64'); // Node- let s = '';- for (let i = 0; i < u8.length; i++) s += String.fromCharCode(u8[i]); // Browser- return btoa(s);-}--/** base64 string -> Uint8Array */-function fromBase64(b64: string): Uint8Array {- if (typeof Buffer !== 'undefined')- return new Uint8Array(Buffer.from(b64, 'base64')); // Node- const s = atob(b64);- const out = new Uint8Array(s.length);- for (let i = 0; i < s.length; i++) out[i] = s.charCodeAt(i);- return out;-}--/** bool grid to string */-function encodeGrid(grid: boolean[][]): string {- if (!Array.isArray(grid)) {- throw new Error('Encode Grid: grid must be an array');- }-- const rows = grid.length;- const cols = rows ? grid[0].length : 0;-- if (rows === 0 || cols === 0) {- throw new Error('Encode Grid: grid cannot be empty');- }-- for (let r = 1; r < rows; r++) {- if (!Array.isArray(grid[r]) || grid[r].length !== cols)- throw new Error('Encode Grid: Non-rectangular grid');- }- if (rows > 255 || cols > 255)- throw new Error('Encode Grid: rows/cols must be ≤ 255');-- const bits: boolean[] = [];- for (let r = 0; r < rows; r++) {- for (let c = 0; c < cols; c++) {- bits.push(!!grid[r][c]);- }- }-- const bytes = new Uint8Array(2 + Math.ceil(bits.length / 8));- bytes[0] = rows;- bytes[1] = cols;-- for (let i = 0; i < bits.length; i++) {- if (bits[i]) {- const byteIndex = 2 + (i >> 3);- const bitPos = 7 - (i & 7);- bytes[byteIndex] |= 1 << bitPos;- }- }-- return toBase64(bytes);-}--/** get bool grid from string */-function decodeGrid(data: string): boolean[][] {- if (!data || typeof data !== 'string') {- throw new Error('Decode Grid: data must be a non-empty string');- }-- let bytes: Uint8Array;- try {- bytes = fromBase64(data);- } catch {- throw new Error('Decode Grid: invalid base64 data');- }-- if (bytes.length < 2) throw new Error('Decode Grid: not enough byte data');- const rows = bytes[0];- const cols = bytes[1];-- if (rows === 0 || cols === 0) {- throw new Error('Decode Grid: invalid grid dimensions');- }-- const totalBits = rows * cols;-- const bits: boolean[] = new Array(totalBits);- let k = 0;- for (let i = 2; i < bytes.length && k < totalBits; i++) {- const b = bytes[i];- for (let bit = 7; bit >= 0 && k < totalBits; bit--) {- bits[k++] = !!(b & (1 << bit));- }- }- if (k !== totalBits) throw new Error('Decode Grid: truncated data');-- const grid: boolean[][] = [];- for (let r = 0; r < rows; r++) {- const row: boolean[] = [];- for (let c = 0; c < cols; c++) row.push(bits[r * cols + c]);- grid.push(row);- }- return grid;-}--/** render svg to a string */-export async function svgToString<T extends Record<string, any>>(- Component: (p: T) => JSX.Element,- props: T-): Promise<string> {- const host = document.createElement('div');- const dispose = render(() => <Component {...props} />, host);-- await Promise.resolve();-- const svgEl = host.querySelector('svg');- if (!svgEl) {- dispose();- throw new Error('Component did not render an <svg> element.');- }-- const xml = new XMLSerializer().serializeToString(svgEl);-- dispose();- host.remove();- return xml;-}--interface PixelIconProps {- gridSize: number;- iconSize: number;- pixelSize: number;- cornerRadius: number;- pixels: boolean[][];- title: string;-}--function PixelIcon(props: PixelIconProps) {- const cellSize = createMemo(() => props.iconSize / props.gridSize);- const offset = createMemo(() => (cellSize() - props.pixelSize) / 2);- const activePixels = createMemo(() => {- const activePixels: Array<{ x: number; y: number }> = [];- for (let row = 0; row < props.gridSize; row++) {- for (let col = 0; col < props.gridSize; col++) {- if (props.pixels[row] && props.pixels[row][col]) {- const x = col * cellSize() + offset();- const y = row * cellSize() + offset();- activePixels.push({- x: Math.round(x * 100) / 100,- y: Math.round(y * 100) / 100,- });- }- }- }- return activePixels;- });-- return (- <svg- xmlns="http://www.w3.org/2000/svg"- width="100%"- height="100%"- viewBox={`0 0 ${props.iconSize} ${props.iconSize}`}- id={props.title}- >- <style>{'.pixel { fill: currentColor}'}</style>- <For each={activePixels()}>- {(pixel) => (- <rect- class="pixel"- x={pixel.x}- y={pixel.y}- width={props.pixelSize}- height={props.pixelSize}- rx={props.cornerRadius}- ry={props.cornerRadius}- />- )}- </For>- </svg>- );-}--interface Glyph {- name: string;- data: string;-}--interface EditableLabelProps {- value: string;- onSave: (newValue: string) => void;- class?: string;- style?: string | JSX.CSSProperties;-}--function EditableLabel(props: EditableLabelProps) {- const [isEditing, setIsEditing] = createSignal(false);- const [editValue, setEditValue] = createSignal('');-- const handleStartEdit = () => {- setIsEditing(true);- setEditValue(props.value);- };-- const handleSave = () => {- const newValue = editValue().trim();- if (newValue && newValue !== props.value) {- props.onSave(newValue);- }- setIsEditing(false);- setEditValue('');- };-- const handleCancel = () => {- setIsEditing(false);- setEditValue('');- };-- return (- <div class={`relative ${props.class || ''}`} style={props.style}>- <Show- when={isEditing()}- fallback={- <div- onClick={handleStartEdit}- class="hover:bg-edge px-1 py-0.5 size-full flex items-center"- style="min-height: 20px;"- >- {props.value}- </div>- }- >- <input- type="text"- value={editValue()}- onInput={(e) => setEditValue(e.currentTarget.value)}- onBlur={handleSave}- onKeyDown={(e) => {- e.stopPropagation();- if (e.key === 'Enter') {- handleSave();- } else if (e.key === 'Escape') {- handleCancel();- }- }}- class="w-full bg-transparent border-none outline-none px-1 py-0.5"- style="min-height: 20px;"- ref={(el) => {- setTimeout(() => {- el.focus();- el.select();- }, 0);- }}- />- </Show>- </div>- );-}--interface GlyphGridProps {- glyphs: Glyph[];- onGlyphSelect: (glyph: Glyph) => void;- onNewGlyph: () => void;- onEditGlyph: (glyph: Glyph) => void;- onDeleteGlyph: (glyph: Glyph) => void;- onGlyphRename: (glyph: Glyph, newName: string) => void;- pixelSize: number;- ignoreKeys: () => boolean;- cornerRadius: number;- sortAlphabetically: () => void;-}--function GlyphGrid(props: GlyphGridProps) {- const [selectedIndex, setSelectedIndex] = createSignal(0);-- const handleKeyDown = (e: KeyboardEvent) => {- if (props.ignoreKeys()) return;- const len = props.glyphs.length;- if (len === 0) return;-- const activeElement = document.activeElement;- if (- activeElement &&- (activeElement.tagName === 'INPUT' ||- activeElement.tagName === 'TEXTAREA' ||- (activeElement as HTMLElement).isContentEditable ||- document.querySelector('[role="dialog"]'))- ) {- return;- }-- if (e.key === 'ArrowLeft') {- e.preventDefault();- setSelectedIndex((prev) => {- const newIndex = prev <= 0 ? len - 1 : prev - 1;- props.onGlyphSelect(props.glyphs[newIndex]);- return newIndex;- });- } else if (e.key === 'ArrowRight') {- e.preventDefault();- setSelectedIndex((prev) => {- const newIndex = prev >= len - 1 ? 0 : prev + 1;- props.onGlyphSelect(props.glyphs[newIndex]);- return newIndex;- });- } else if (e.key === 'ArrowUp') {- e.preventDefault();- setSelectedIndex((prev) => {- const newIndex = prev - columns();- if (newIndex < 0) {- const rows = Math.ceil(len / columns());- const total = rows * columns();- const wrapped = (newIndex + total) % total;- if (wrapped >= len) return wrapped - columns();- return wrapped;- }- return newIndex;- });- } else if (e.key === 'ArrowDown') {- e.preventDefault();- setSelectedIndex((prev) => {- const newIndex = prev + columns();- const rows = Math.ceil(len / columns());- const row = Math.floor(newIndex / columns());- if (row > rows - 1) return newIndex % (columns() * rows);- if (newIndex >= len) return (newIndex + columns()) % (rows * columns());- return newIndex;- });- }- if (e.key === 'Delete') {- e.preventDefault();- props.onDeleteGlyph(props.glyphs[selectedIndex()]);- } else if (e.key === 'Enter') {- e.preventDefault();- const ndx = selectedIndex();- setTimeout(() => {- props.onEditGlyph(props.glyphs[ndx]);- });- }- };-- onMount(() => {- document.addEventListener('keydown', handleKeyDown);- });-- onCleanup(() => {- document.removeEventListener('keydown', handleKeyDown);- });-- const [gridRef, setGridRef] = createSignal<HTMLDivElement>();- const gridSize = createElementSize(gridRef);- const width = () => gridSize.width ?? 0;-- const [columns, setColumns] = createSignal(Math.floor(width() / (32 * 4)));- createEffect(() => {- setColumns(Math.floor(width() / (32 * 4)));- });-- return (- <div class="grow">- <div class="flex items-center justify-between mb-6 p-2">- <div class="flex item-center gap-4">- <h2 class="font-mono text-xs">Icons [ {props.glyphs.length} ]</h2>- <button- class="font-mono text-xs underline"- onClick={props.sortAlphabetically}- >- Sort Alhpa- </button>- </div>- <Button- variant="outline"- onClick={() => {- props.onNewGlyph();- }}- >- <Plus /> New Icon- </Button>- </div>-- <Show- when={props.glyphs.length > 0}- fallback={- <div class="flex flex-col items-center justify-center h-64 text-ink-muted">- <div class="text-sm mb-2">No icons yet</div>- <div class="text-sm">Click "New Icon" to create your first one</div>- </div>- }- >- <div- class="grid gap-2 px-2 h-full overflow-y-auto pb-64"- ref={setGridRef}- style={{- 'grid-template-columns': `repeat(${columns()}, minmax(0, 1fr))`,- 'grid-auto-rows': 'minmax(min-content, max-content)',- }}- >- <For each={props.glyphs}>- {(glyph, index) => {- const pixels = createMemo(() => {- try {- if (!glyph.data) {- console.warn('Glyph has no data:', glyph.name);- return [];- }- return decodeGrid(glyph.data);- } catch (error) {- console.warn(- 'Failed to decode glyph data for:',- glyph.name,- error- );- return [];- }- });-- const gridSize = createMemo(() => pixels().length);- const isSelected = createMemo(() => selectedIndex() === index());-- return (- <div- onClick={() => {- setSelectedIndex(index());- props.onGlyphSelect(glyph);- }}- tabIndex={0}- onDblClick={() => props.onEditGlyph(glyph)}- class="items-center border relative group transition-colors justify-self-stretch"- classList={{- 'border-edge bg-edge': isSelected(),- 'border-edge bg-surface hover:bg-edge': !isSelected(),- }}- >- <div class="size-20 flex items-center justify-center mx-auto my-2">- <Show when={pixels().length > 0}>- <PixelIcon- pixels={pixels()}- iconSize={gridSize() * BASE_PX_SIZE}- pixelSize={props.pixelSize}- cornerRadius={props.cornerRadius}- gridSize={gridSize()}- title={glyph.name}- />- </Show>- </div>- <div class="text-xs text-ink-muted w-full border-t border-edge p-1">- <EditableLabel- value={glyph.name}- onSave={(newName) => props.onGlyphRename(glyph, newName)}- class="text-xs"- />- </div>-- <div class="absolute top-1 right-1 flex gap-0 opacity-0 bg-surface group-hover:opacity-100">- <Button- variant="outline"- size="icon-md"- label="Edit"- onClick={(e) => {- e.preventDefault();- props.onEditGlyph(glyph);- }}- >- <Pencil />- </Button>- <Button- variant="danger"- size="icon-md"- label="Delete"- onClick={(e) => {- e.preventDefault();- props.onDeleteGlyph(glyph);- }}- >- <Trash />- </Button>- </div>- </div>- );- }}- </For>- </div>- </Show>- </div>- );-}--interface GlyphEditorProps {- isOpen: boolean;- onClose: () => void;- onSave: (name: string, data: string) => void;- initialGlyph?: Glyph;-}--function GlyphEditor(props: GlyphEditorProps) {- const [gridSize, setGridSize] = createSignal(13);- const [pixelSize, _] = createSignal(BASE_PX_SIZE);- const [cornerRadius, __] = createSignal(0);- const [glyphName, setGlyphName] = createSignal('');- const [symmetryX, setSymmetryX] = createSignal(false);- const [symmetryY, setSymmetryY] = createSignal(false);- const [pixels, setPixels] = createSignal<boolean[][]>(- Array(gridSize())- .fill(null)- .map(() => Array(gridSize()).fill(false))- );-- const [isDragging, setIsDragging] = createSignal(false);- const [dragMode, setDragMode] = createSignal<'fill' | 'erase'>('fill');-- let inputRef: HTMLInputElement | undefined;- onMount(() => {- const handleKeyDown = (event: KeyboardEvent) => {- if (!props.isOpen) return;-- // If input is focused, only handle Enter and Escape- if (inputRef && document.activeElement === inputRef) {- if (event.key === 'Enter') {- event.preventDefault();- event.stopPropagation();- handleSave();- } else if (event.key === 'Escape') {- event.preventDefault();- event.stopPropagation();- props.onClose();- }- return;- }-- // Handle keys only when editor is open and no input is focused- if (event.key === 'Escape') {- event.preventDefault();- event.stopPropagation();- props.onClose();- } else if (event.key === 'x' || event.key === 'X') {- event.preventDefault();- event.stopPropagation();- setSymmetryX((prev) => !prev);- } else if (event.key === 'y' || event.key === 'Y') {- event.preventDefault();- event.stopPropagation();- setSymmetryY((prev) => !prev);- } else if (event.key === 'Delete') {- event.preventDefault();- event.stopPropagation();- clearAll();- } else if (event.key === 'f' || event.key === 'F') {- event.preventDefault();- event.stopPropagation();- fillAll();- } else if (event.key === 'Enter') {- event.preventDefault();- event.stopPropagation();- handleSave();- }- };- document.addEventListener('keydown', handleKeyDown);- onCleanup(() => {- document.removeEventListener('keydown', handleKeyDown);- });- });-- // Initialize with existing glyph if provided - use createEffect to react to prop changes- createEffect(() => {- if (props.isOpen) {- if (props.initialGlyph) {- try {- const decodedPixels = decodeGrid(props.initialGlyph.data);- setPixels(decodedPixels);- setGridSize(decodedPixels.length);- setGlyphName(props.initialGlyph.name);- setSymmetryX(false);- setSymmetryY(false);- } catch (error) {- console.warn('Failed to decode glyph:', error);- // Fallback to default state if decode fails- const defaultGridSize = 13;- setGridSize(defaultGridSize);- setGlyphName('');- setPixels(- Array(defaultGridSize)- .fill(null)- .map(() => Array(defaultGridSize).fill(false))- );- setSymmetryX(false);- setSymmetryY(false);- }- } else {- // Reset to default state for new glyph- const defaultGridSize = 13;- setGridSize(defaultGridSize);- setGlyphName('');- setPixels(- Array(defaultGridSize)- .fill(null)- .map(() => Array(defaultGridSize).fill(false))- );- setSymmetryX(false);- setSymmetryY(false);- }- }- });-- // Reactive effect to resize pixels array when grid size changes- createEffect(() => {- if (props.isOpen) {- const currentSize = gridSize();- setPixels((prev) => {- // Create new array with current grid size- const newPixels = Array(currentSize)- .fill(null)- .map(() => Array(currentSize).fill(false));-- // Copy existing pixels if they fit- for (let row = 0; row < Math.min(prev.length, currentSize); row++) {- for (- let col = 0;- col < Math.min(prev[row]?.length || 0, currentSize);- col++- ) {- if (prev[row] && prev[row][col] !== undefined) {- newPixels[row][col] = prev[row][col];- }- }- }-- return newPixels;- });- }- });-- const iconSize = () => gridSize() * BASE_PX_SIZE;- const cellSize = 280 / gridSize();-- const setPixel = (row: number, col: number, value: boolean) => {- setPixels((prev) => {- const newPixels = prev.map((r) => [...r]);- newPixels[row][col] = value;-- if (symmetryX()) {- const mirrorCol = gridSize() - 1 - col;- newPixels[row][mirrorCol] = value;- }-- if (symmetryY()) {- const mirrorRow = gridSize() - 1 - row;- newPixels[mirrorRow][col] = value;-- if (symmetryX()) {- const mirrorCol = gridSize() - 1 - col;- newPixels[mirrorRow][mirrorCol] = value;- }- }-- return newPixels;- });- };-- const handleMouseDown = (row: number, col: number) => {- setIsDragging(true);- const currentValue = pixels()[row][col];- setDragMode(currentValue ? 'erase' : 'fill');- setPixel(row, col, !currentValue);- };-- const handleMouseEnter = (row: number, col: number) => {- if (isDragging()) {- setPixel(row, col, dragMode() === 'fill');- }- };-- const handleMouseUp = () => {- setIsDragging(false);- };-- const handleSave = () => {- const name = glyphName().trim();- if (!name) {- alert('Please enter a glyph name');- return;- }-- try {- const data = encodeGrid(pixels());- props.onSave(name, data);- props.onClose();- } catch (error) {- console.error('Failed to encode glyph data:', error);- alert('Failed to save glyph. Please try again.');- }- };-- const clearAll = () => {- setPixels(- Array(gridSize())- .fill(null)- .map(() => Array(gridSize()).fill(false))- );- };-- const fillAll = () => {- setPixels(- Array(gridSize())- .fill(null)- .map(() => Array(gridSize()).fill(true))- );- };-- const handleMirrorX = () => {- setPixels((prev) => mirrorX(prev));- };-- const handleMirrorY = () => {- setPixels((prev) => mirrorY(prev));- };-- const handleRotate90CC = () => {- setPixels((prev) => {- const rotated = rotate90CC(prev);- const newSize = rotated.length;- if (newSize !== gridSize()) {- setGridSize(newSize);- }- return rotated;- });- };-- return (- <Show when={props.isOpen}>- <div class="absolute inset-0 bg-modal-overlay flex items-center justify-center z-action-menu">- <div- class="bg-surface border border-edge max-w-4xl w-full max-h-[90vh] overflow-hidden flex flex-col"- use:clickOutside={() => props.onClose()}- >- <div class="p-2 border-b border-edge flex items-center justify-between">- <h2 class="font-mono text-xs">Editor</h2>- <Button variant="ghost" size="icon-md" onClick={props.onClose}>- <X />- </Button>- </div>-- <div class="flex flex-1 overflow-hidden">- <div class="flex-1 p-1 overflow-y-auto">- <input- type="text"- placeholder="Icon name..."- value={glyphName()}- onInput={(e) => setGlyphName(e.currentTarget.value)}- class="p-2 w-full text-sm border-b border-edge mb-4"- ref={inputRef}- />- <div class="flex flex-col items-center gap-6">- <div- class="relative border border-edge"- style="width: 280px; height: 280px;"- >- <svg- viewBox={`0 0 280 280`}- class="absolute inset-0 size-full cursor-crosshair"- style="user-select: none;"- onMouseUp={handleMouseUp}- onMouseLeave={handleMouseUp}- >- {/* Grid lines */}- <defs>- <pattern- id="grid"- width={cellSize}- height={cellSize}- patternUnits="userSpaceOnUse"- >- <path- d={`M ${cellSize} 0 L 0 0 0 ${cellSize}`}- fill="none"- stroke="currentColor"- stroke-width="0.5"- opacity="0.2"- />- </pattern>- </defs>- <rect width="280" height="280" fill="url(#grid)" />-- <For each={Array(gridSize()).fill(null)}>- {(_, row) => (- <For each={Array(gridSize()).fill(null)}>- {(_, col) => (- <rect- x={col() * cellSize}- y={row() * cellSize}- width={cellSize}- height={cellSize}- fill={- pixels()[row()][col()]- ? 'currentColor'- : 'transparent'- }- stroke="transparent"- class="hover:stroke-current hover:stroke-1 hover:opacity-50"- onMouseDown={() => handleMouseDown(row(), col())}- onMouseEnter={() =>- handleMouseEnter(row(), col())- }- />- )}- </For>- )}- </For>- </svg>- </div>-- <div class="flex flex-col items-center gap-2 mb-4">- <h3 class="font-mono text-ink-extra-muted text-xs">- [ PREVIEW ]- </h3>- <div class="size-24 flex items-center justify-center border border-edge bg-surface">- <PixelIcon- pixels={pixels()}- iconSize={iconSize()}- pixelSize={pixelSize()}- cornerRadius={cornerRadius()}- gridSize={gridSize()}- title={glyphName()}- />- </div>- </div>- </div>- </div>-- <div class="w-80 border-l border-edge border-dashed p-2 flex flex-col">- <div class="flex-1 overflow-y-auto">- <div>- <div class="flex flex-row items-center w-full justify-start gap-6 mb-4">- <div class="flex gap-2 flex-col text-ink-muted">- <span class="flex items-center gap-2 text-xs">- Symmetry X- </span>- <ToggleSwitch- checked={symmetryX()}- onChange={() => setSymmetryX((prev) => !prev)}- />- </div>- <div class="flex gap-2 flex-col text-ink-muted">- <span class="flex items-center gap-2 text-xs">- Symmetry Y- </span>- <ToggleSwitch- checked={symmetryY()}- onChange={() => setSymmetryY((prev) => !prev)}- />- </div>- </div>- </div>-- <div class="grid grid-cols-2 gap-2 mb-4">- <Button variant="outline" onClick={clearAll}>- <Erase /> Clear Grid- </Button>- <Button variant="outline" onClick={fillAll}>- <Fill /> Fill Grid- </Button>- </div>-- <div class="space-y-2 mb-4">- <h4 class="font-mono text-xs text-ink-muted">Transforms</h4>- <div class="flex gap-2">- <Button- variant="outline"- size="icon-md"- label="Mirror X"- onClick={handleMirrorX}- >- <MirrorX />- </Button>- <Button- variant="outline"- size="icon-md"- label="Mirror Y"- onClick={handleMirrorY}- >- <MirrorY />- </Button>- <Button- variant="outline"- size="icon-md"- label="Rotate 90 CCW"- onClick={handleRotate90CC}- >- <Rotate />- </Button>- </div>- </div>- </div>-- <div class="pt-4 border-t border-edge">- <div class="grid grid-cols-2 gap-2">- <Button variant="outline" onClick={props.onClose}>- Cancel- </Button>- <Button variant="accent" onClick={handleSave}>- Save- </Button>- </div>- </div>- </div>- </div>- </div>- </div>- </Show>- );-}--interface GlyphSidebarProps {- selectedGlyph: Glyph | null;- pixelSize: number;- cornerRadius: number;- onPixelSizeChange: (value: number) => void;- onCornerRadiusChange: (value: number) => void;- onGlyphRename: (glyph: Glyph, newName: string) => void;- onExportAll: () => void;- onImportAll: () => void;- onCopyAllSVGs: () => void;- onDownloadAllSVGs: () => void;-}--function GlyphSidebar(props: GlyphSidebarProps) {- const selectedPixels = createMemo(() => {- if (!props.selectedGlyph) return null;- try {- if (!props.selectedGlyph.data) {- console.warn('Selected glyph has no data:', props.selectedGlyph.name);- return null;- }- return decodeGrid(props.selectedGlyph.data);- } catch (error) {- console.warn(- 'Failed to decode selected glyph data:',- props.selectedGlyph.name,- error- );- return null;- }- });-- const selectedGridSize = createMemo(() => {- const pixels = selectedPixels();- return pixels ? pixels.length : 0;- });-- const iconSize = createMemo(() => selectedGridSize() * BASE_PX_SIZE);-- const memoizedProps = createMemo(() => {- const pixels = selectedPixels();- if (!pixels || !props.selectedGlyph) return null;-- return {- pixels,- iconSize: iconSize(),- gridSize: selectedGridSize(),- cornerRadius: props.cornerRadius,- title: props.selectedGlyph.name,- pixelSize: props.pixelSize,- };- });-- const [svgString] = createResource(memoizedProps, async (props) => {- if (!props) return '';- return await svgToString<PixelIconProps>(PixelIcon, props);- });-- return (- <div class="w-100 bg-surface p-4 overflow-y-auto border-l border-edge border-dashed shrink-0">- <div class="space-y-4">- <h3 class="font-mono text-sm text-ink">[ Global Settings ]</h3>-- <DebugSlider- label="Pixel Size"- value={props.pixelSize}- onChange={props.onPixelSizeChange}- min={1}- max={15}- step={0.5}- decimals={1}- />-- <DebugSlider- label="Corner Radius"- value={props.cornerRadius}- onChange={props.onCornerRadiusChange}- min={0}- max={8}- step={0.5}- decimals={1}- />-- <div class="mt-6 space-y-2">- <h4 class="font-mono text-xs text-ink-muted">Batch Operations</h4>- <div class="grid grid-cols-1 gap-2">- <Button variant="outline" onClick={props.onExportAll}>- <Copy /> Export to Clipboard- </Button>- <Button variant="outline" onClick={props.onImportAll}>- <Upload /> Import from Clipboard- </Button>- <Button variant="outline" onClick={props.onCopyAllSVGs}>- <Copy /> Copy SVGs- </Button>- <Button variant="outline" onClick={props.onDownloadAllSVGs}>- <Download /> Download SVGs- </Button>- </div>- </div>- </div>-- <hr class="border-b border-dashed border-edge my-4" />-- <Show- when={props.selectedGlyph}- fallback={- <div class="text-ink-muted text-sm">- Select a glyph from the grid to view details- </div>- }- >- <h3 class="font-mono text-sm text-ink mb-2">[ Inspector ]</h3>- <div class="space-y-6">- <div class="flex flex-col items-start gap-4 justify-start">- <EditableLabel- value={props.selectedGlyph?.name || ''}- onSave={(newName) => {- if (props.selectedGlyph) {- props.onGlyphRename(props.selectedGlyph, newName);- }- }}- class="font-mono text-ink-muted text-sm text-left w-full border border-edge"- />- <div class="size-32 flex items-center justify-center border border-edge bg-surface">- <Show when={selectedPixels()}>- <PixelIcon- pixels={selectedPixels()!}- iconSize={iconSize()}- pixelSize={props.pixelSize}- cornerRadius={props.cornerRadius}- gridSize={selectedGridSize()}- title={props.selectedGlyph?.name || ''}- />- </Show>- </div>- </div>-- {/* Global Controls */}-- {/* SVG Output */}- <Show when={svgString()}>- <div class="space-y-2">- <h3 class="font-mono text-ink-muted text-sm">Generated SVG</h3>- <div class="p-4 rounded-xs bg-message overflow-x-auto max-h-96">- <pre class="text-xs font-mono whitespace-pre-wrap text-ink-muted">- {svgString()}- </pre>- </div>-- <div class="flex gap-2">- <Button- variant="ghost"- onClick={() =>- navigator.clipboard.writeText(svgString() || '')- }- >- <Copy /> Copy Svg- </Button>- <Button- variant="ghost"- onClick={() => {- const svg = svgString();- if (!svg) return;- const blob = new Blob([svg], { type: 'image/svg+xml' });- const url = URL.createObjectURL(blob);- const a = document.createElement('a');- a.href = url;- a.download = `${props.selectedGlyph?.name || 'glyph'}.svg`;- document.body.appendChild(a);- a.click();- document.body.removeChild(a);- URL.revokeObjectURL(url);- }}- >- <Download /> Download Svg- </Button>- </div>- </div>- </Show>-- {/* Base64 Data */}- <Show when={props.selectedGlyph}>- <div class="space-y-2">- <h3 class="font-mono text-ink-muted text-sm">Base64 Data</h3>- <div class="p-3 bg-message rounded-xs overflow-x-auto max-h-32">- <pre class="text-xs font-mono whitespace-pre-wrap text-ink-muted">- {props.selectedGlyph?.data}- </pre>- </div>-- <div class="flex gap-2">- <Button- variant="ghost"- onClick={() =>- navigator.clipboard.writeText(- props.selectedGlyph?.data || ''- )- }- >- <Copy /> Copy Base64- </Button>- </div>- </div>- </Show>-- {/* Info */}- <Show when={selectedPixels()}>- <div class="p-3 bg-message rounded-xs">- <p class="text-xs text-ink-muted">- <strong>Grid:</strong> {selectedGridSize()}×{selectedGridSize()}{' '}- pixels- <br />- <strong>Active Pixels:</strong>{' '}- {selectedPixels()!.flat().filter(Boolean).length}/- {selectedGridSize() ** 2}- <br />- <strong>Data Size:</strong> {props.selectedGlyph?.data.length}{' '}- characters- </p>- </div>- </Show>- </div>- </Show>- </div>- );-}--export default function PixelArtIconDemo() {- const [glyphs, setGlyphs] = createSignal<Glyph[]>([]);- const [selectedGlyph, setSelectedGlyph] = createSignal<Glyph | null>(null);- const [isEditorOpen, setIsEditorOpen] = createSignal(false);- const [editingGlyph, setEditingGlyph] = createSignal<Glyph | undefined>();-- // Global display settings- const [pixelSize, setPixelSize] = createSignal(BASE_PX_SIZE);- const [cornerRadius, setCornerRadius] = createSignal(0);-- // Load saved glyphs on mount- try {- const saved = localStorage.getItem('pixel-art-glyphs');- if (saved) {- const parsedGlyphs = JSON.parse(saved);- // Handle migration from old format if needed- const migratedGlyphs = parsedGlyphs.map((item: any) => {- if (item.pixels && item.name) {- // Old format: {name, pixels, timestamp}- return {- name: item.name,- data: encodeGrid(item.pixels),- };- }- // New format: {name, data}- return item;- });- setGlyphs(migratedGlyphs);- }- } catch (error) {- console.warn('Failed to load saved glyphs:', error);- }-- const saveGlyphs = (newGlyphs: Glyph[]) => {- setGlyphs(newGlyphs);- try {- localStorage.setItem('pixel-art-glyphs', JSON.stringify(newGlyphs));- } catch (error) {- console.error('Failed to save glyphs:', error);- }- };-- const handleGlyphSelect = (glyph: Glyph) => {- setSelectedGlyph(glyph);- };-- const handleEditGlyph = (glyph: Glyph) => {- console.log('handle edit', glyph);- setEditingGlyph(glyph);- setIsEditorOpen(true);- };-- const handleDeleteGlyph = (glyph: Glyph) => {- const updated = glyphs().filter((g) => g !== glyph);- saveGlyphs(updated);- if (selectedGlyph() === glyph) {- setSelectedGlyph(null);- }- };-- const handleNewGlyph = () => {- setEditingGlyph(undefined);- setIsEditorOpen(true);- };-- const handleSaveGlyph = (name: string, data: string) => {- const existingIndex = glyphs().findIndex((g) => g.name === name);-- if (existingIndex >= 0) {- const updated = [...glyphs()];- updated[existingIndex] = { name, data };- saveGlyphs(updated);- setSelectedGlyph(updated[existingIndex]);- } else {- const newGlyph = { name, data };- const updated = [...glyphs(), newGlyph];- saveGlyphs(updated);- setSelectedGlyph(newGlyph);- }-- setEditingGlyph(undefined);- };-- const handleExportAll = async () => {- const exportData: Record<string, string> = {};- glyphs().forEach((glyph) => {- exportData[glyph.name] = glyph.data;- });- await navigator.clipboard.writeText(JSON.stringify(exportData, null, 2));- };-- const sortAlphabetically = () => {- const sorted = [...glyphs()].sort((a, b) => a.name.localeCompare(b.name));- saveGlyphs(sorted);- setSelectedGlyph(sorted[0]);- };-- const handleImportAll = async () => {- try {- const clipboardText = await navigator.clipboard.readText();- const importData = JSON.parse(clipboardText);-- if (typeof importData === 'object' && importData !== null) {- const newGlyphs: Glyph[] = Object.entries(importData).map(- ([name, data]) => ({- name,- data: String(data),- })- );- saveGlyphs(newGlyphs);- setSelectedGlyph(null);- } else {- alert(- 'Invalid JSON format. Expected an object with icon names as keys and base64 data as values.'- );- }- } catch (_error) {- alert('Failed to parse clipboard content as JSON.');- }- };-- const handleCopyAllSVGs = async () => {- const svgPromises = glyphs().map(async (glyph) => {- try {- const pixels = decodeGrid(glyph.data);- const gridSize = pixels.length;- const iconSize = gridSize * BASE_PX_SIZE;-- return await svgToString<PixelIconProps>(PixelIcon, {- pixels,- iconSize,- pixelSize: pixelSize(),- cornerRadius: cornerRadius(),- gridSize,- title: glyph.name,- });- } catch (error) {- console.warn('Failed to generate SVG for:', glyph.name, error);- return `<!-- Error generating SVG for ${glyph.name} -->`;- }- });-- try {- const svgStrings = await Promise.all(svgPromises);- console.log(svgStrings);- const concatenatedSVGs = svgStrings.join('\n\n');- await navigator.clipboard.writeText(concatenatedSVGs);- } catch (_error) {- alert('Failed to generate or copy SVGs.');- }- };-- const handleDownloadAllSVGs = async () => {- for (const glyph of glyphs()) {- try {- const pixels = decodeGrid(glyph.data);- const gridSize = pixels.length;- const iconSize = gridSize * BASE_PX_SIZE;-- const svg = await svgToString<PixelIconProps>(PixelIcon, {- pixels,- iconSize,- pixelSize: pixelSize(),- cornerRadius: cornerRadius(),- gridSize,- title: glyph.name,- });-- const blob = new Blob([svg], { type: 'image/svg+xml' });- const url = URL.createObjectURL(blob);- const a = document.createElement('a');- a.href = url;- a.download = `${glyph.name}.svg`;- document.body.appendChild(a);- a.click();- document.body.removeChild(a);- URL.revokeObjectURL(url);-- // Small delay between downloads to avoid overwhelming the browser- await new Promise((resolve) => setTimeout(resolve, 100));- } catch (error) {- console.warn('Failed to download SVG for:', glyph.name, error);- }- }- };-- return (- <div class="flex flex-col size-full overflow-hidden">- <Bar- left={<div class="p-2 text-sm w-2xl truncate">Icon Editor</div>}- center={<div></div>}- />-- <div class="flex size-full">- <GlyphGrid- glyphs={glyphs()}- onGlyphSelect={handleGlyphSelect}- onNewGlyph={handleNewGlyph}- onEditGlyph={handleEditGlyph}- onDeleteGlyph={handleDeleteGlyph}- onGlyphRename={(glyph, newName) => {- const updated = glyphs().map((g) =>- g === glyph ? { ...g, name: newName } : g- );- saveGlyphs(updated);- if (selectedGlyph() === glyph) {- setSelectedGlyph({ ...glyph, name: newName });- }- }}- pixelSize={pixelSize()}- cornerRadius={cornerRadius()}- ignoreKeys={() => !!editingGlyph()}- sortAlphabetically={sortAlphabetically}- />-- <GlyphSidebar- selectedGlyph={selectedGlyph()}- pixelSize={pixelSize()}- cornerRadius={cornerRadius()}- onPixelSizeChange={setPixelSize}- onCornerRadiusChange={setCornerRadius}- onGlyphRename={(glyph, newName) => {- const updated = glyphs().map((g) =>- g === glyph ? { ...g, name: newName } : g- );- saveGlyphs(updated);- if (selectedGlyph() === glyph) {- setSelectedGlyph({ ...glyph, name: newName });- }- }}- onExportAll={handleExportAll}- onImportAll={handleImportAll}- onCopyAllSVGs={handleCopyAllSVGs}- onDownloadAllSVGs={handleDownloadAllSVGs}- />- </div>-- <GlyphEditor- isOpen={isEditorOpen()}- onClose={() => {- console.log('GlyphEditor closed');- setIsEditorOpen(false);- setEditingGlyph(undefined);- }}- onSave={handleSaveGlyph}- initialGlyph={editingGlyph()}- />- </div>- );-}diff --git a/apps/web/src/lib/core/internal/SvgNoiseGridDemo.tsx b/apps/web/src/lib/core/internal/SvgNoiseGridDemo.tsxdeleted file mode 100644index 3c85d51f4f..0000000000--- a/apps/web/src/lib/core/internal/SvgNoiseGridDemo.tsx+++ /dev/null@@ -1,283 +0,0 @@-import { DebugSlider } from '@core/component/Slider';-import { Bar } from '@core/component/TopBar/Bar';-import { createSignal } from 'solid-js';--/**- * Generates animated SVG noise grids with configurable parameters- */-interface SvgNoiseGridParams {- /** Number of pixels horizontally */- xCount?: number;- /** Number of pixels vertically */- yCount?: number;- /** Random seed for reproducible patterns */- seed?: number;- /** Total width of the SVG viewBox */- w?: number;- /** Total height of the SVG viewBox */- h?: number;- /** Size of each pixel (width and height) */- size?: number;- /** Corner radius for rounded pixels */- cornerRadius?: number;- /** Animation speed multiplier */- speed?: number;-}--/**- * Simple pseudo-random number generator using seed- */-class SeededRandom {- private seed: number;-- constructor(seed: number) {- this.seed = seed % 2147483647;- if (this.seed <= 0) this.seed += 2147483646;- }-- next(): number {- this.seed = (this.seed * 16807) % 2147483647;- return (this.seed - 1) / 2147483646;- }-- range(min: number, max: number): number {- return min + this.next() * (max - min);- }-}--/**- * Generates an animated SVG noise grid- */-function generateSvgNoiseGrid(params: SvgNoiseGridParams = {}): string {- const {- xCount = 4,- yCount = 4,- seed = 12345,- w = 32,- h = 32,- size = 6,- cornerRadius = 6,- speed = 1.0,- } = params;-- const rng = new SeededRandom(seed);-- // Calculate spacing between pixels- const spacingX = (w - size) / (xCount - 1);- const spacingY = (h - size) / (yCount - 1);-- // Generate pixels with random animation properties- const pixels: Array<{- x: number;- y: number;- duration: number;- delay: number;- }> = [];-- for (let row = 0; row < yCount; row++) {- for (let col = 0; col < xCount; col++) {- const x = col * spacingX;- const y = row * spacingY;-- // Generate random animation properties- const baseDuration = 0.35;- const duration = baseDuration + rng.range(-0.1, 0.1);- const delay = rng.range(0, 0.15);-- pixels.push({- x: Math.round(x),- y: Math.round(y),- duration: duration * (1 / speed),- delay: delay * (1 / speed),- });- }- }-- // Generate SVG- const svgContent = `<svg viewBox="0 0 ${w} ${h}" xmlns="http://www.w3.org/2000/svg" style="background: transparent">- <style>- .px { fill: currentColor; pointer-events: none; }- .a { animation-timing-function: steps(1, end); animation-iteration-count: infinite; }-- @keyframes flick {- 0%, 100% { opacity: 1; }- 71% { opacity: 0; }- }- </style>-- <defs>- <rect id="pixel" width="${size}" height="${size}" class="px a" rx="${cornerRadius}" ry="${cornerRadius}" />- </defs>--${pixels- .map((pixel, index) => {- const row = Math.floor(index / xCount);- const isFirstInRow = index % xCount === 0;- const rowComment = isFirstInRow ? `\n <!-- Row ${row} -->` : '';-- return `${rowComment}- <use href="#pixel" x="${pixel.x}" y="${pixel.y}" style="animation: flick ${pixel.duration.toFixed(2)}s infinite; animation-delay: ${pixel.delay.toFixed(2)}s"/>`;- })- .join('')}-</svg>`;-- return svgContent;-}--export default function SvgNoiseGridDemo() {- const [xCount, setXCount] = createSignal(4);- const [yCount, setYCount] = createSignal(4);- const [w, setW] = createSignal(32);- const [h, setH] = createSignal(32);- const [size, setSize] = createSignal(6);- const [cornerRadius, setCornerRadius] = createSignal(6);- const [speed, setSpeed] = createSignal(1.0);-- const generateSvg = () => {- return generateSvgNoiseGrid({- xCount: xCount(),- yCount: yCount(),- seed: 0,- w: w(),- h: h(),- size: size(),- cornerRadius: cornerRadius(),- speed: speed(),- });- };-- const downloadSvg = () => {- const svg = generateSvg();- const blob = new Blob([svg], { type: 'image/svg+xml' });- const url = URL.createObjectURL(blob);- const a = document.createElement('a');- a.href = url;- a.download = `noise-grid.svg`;- document.body.appendChild(a);- a.click();- document.body.removeChild(a);- URL.revokeObjectURL(url);- };-- return (- <div class="flex flex-col size-full">- <Bar- left={- <div class="p-2 text-sm w-2xl truncate">SVG Noise Grid Generator</div>- }- center={<div></div>}- ></Bar>- <div class="flex size-full">- <div class="flex-1 relative bg-surface flex items-center justify-center">- <div class="size-64 flex items-center justify-center border border-edge">- <div- id="svg-preview"- class="text-accent"- style="width: 64px; height: 64px;"- innerHTML={generateSvg()}- />- </div>- </div>-- <div class="w-[50%] max-w-lg bg-surface p-4 overflow-y-auto border-l border-edge border-dashed">- <h2 class="font-mono mb-6">SVG Noise Grid Generator</h2>-- <div class="space-y-6">- <DebugSlider- label="X Count"- value={xCount()}- onChange={setXCount}- min={1}- max={10}- step={1}- />-- <DebugSlider- label="Y Count"- value={yCount()}- onChange={setYCount}- min={1}- max={10}- step={1}- />-- <DebugSlider- label="Width"- value={w()}- onChange={setW}- min={16}- max={128}- step={1}- />-- <DebugSlider- label="Height"- value={h()}- onChange={setH}- min={16}- max={128}- step={1}- />-- <DebugSlider- label="Pixel Size"- value={size()}- onChange={setSize}- min={1}- max={20}- step={0.5}- decimals={1}- />-- <DebugSlider- label="Corner Radius"- value={cornerRadius()}- onChange={setCornerRadius}- min={0}- max={20}- step={0.5}- decimals={1}- />-- <DebugSlider- label="Speed"- value={speed()}- onChange={setSpeed}- min={0.1}- max={3.0}- step={0.1}- decimals={2}- />- </div>-- {/* Actions */}- <div class="mt-8 space-y-3">- <button- onClick={downloadSvg}- class="w-full px-4 py-2 bg-ink-extra-muted text-surface font-medium"- >- Download SVG- </button>-- <button- onClick={() => navigator.clipboard.writeText(generateSvg())}- class="w-full px-4 py-2 bg-ink-extra-muted text-surface font-medium"- >- Copy SVG Code- </button>- </div>-- {/* Generated SVG Code */}- <div class="mt-8">- <h3 class="font-mono text-ink-muted mb-3">Generated SVG</h3>- <div class="p-4 rounded-xs bg-message overflow-x-auto max-h-96">- <pre class="text-xs font-mono whitespace-pre-wrap text-ink-muted">- {generateSvg()}- </pre>- </div>- </div>- </div>- </div>- </div>- );-}diff --git a/apps/web/tsconfig.json b/apps/web/tsconfig.jsonindex 949968261d..b258f77517 100644--- a/apps/web/tsconfig.json+++ b/apps/web/tsconfig.json@@ -206,12 +206,6 @@"@service-contacts/*": ["./src/lib/service-clients/service-contacts/*"],- "@baby-gl": [- "./src/lib/baby-gl/"- ],- "@baby-gl/*": [- "./src/lib/baby-gl/*"- ],"@notifications": ["./src/features/notifications/"],