Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions web/src/app/pattern-lab/panels/director/useShowEditing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { useLabStore } from "@/lib/lab/store";
import { wireToY, yToWire } from "../directorGeometry";
import { CURVE_MAGNET_PX, FOCUS_PAD } from "./constants";

export type Selection =
type Selection =
| { kind: "key"; lane: number; id: string }
| { kind: "msg"; id: string }
| null;
Expand All @@ -29,7 +29,7 @@ export function interpOf(k: DirectorKeyframe): Interp {
return k.h === "auto" ? "auto" : "manual";
}

export function sortedLane(lane: DirectorKeyframe[]): DirectorKeyframe[] {
function sortedLane(lane: DirectorKeyframe[]): DirectorKeyframe[] {
return [...lane].sort((a, b) => a.t - b.t);
}

Expand Down
2 changes: 0 additions & 2 deletions web/src/app/pattern-lab/panels/director/useTimelineZoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,3 @@ export function useTimelineZoom({

return { pps, focusH, zoomBy };
}

export type TimelineZoom = ReturnType<typeof useTimelineZoom>;
2 changes: 1 addition & 1 deletion web/src/app/pattern-lab/panels/pixel/usePixelSelection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { cutRegion, scaleNearest, stampRegionOver, type PixelSurface } from "@/l
import { normRect, type Cell, type Floating, type SelRect } from "./tools";

/** The drag in progress: drawing the box, or moving the lifted cut. */
export type SelectAction = {
type SelectAction = {
mode: "select" | "move";
startX: number;
startY: number;
Expand Down
2 changes: 1 addition & 1 deletion web/src/app/pattern-lab/panels/pixel/usePixelViewport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { Cell } from "./tools";
import { WHEEL_NOTCH_PX, wheelPixels } from "./wheel";

export const ZOOM_MIN = 1;
export const ZOOM_MAX = 32;
const ZOOM_MAX = 32;

/**
* The largest whole zoom that shows the picture entire inside a viewport of
Expand Down
6 changes: 3 additions & 3 deletions web/src/app/pattern-lab/panels/registry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ export type PanelId =
| "capture"
| "director";

export type DockDirection = "right" | "below" | "within";
type DockDirection = "right" | "below" | "within";

export type PanelDef = {
type PanelDef = {
id: PanelId;
/** The tab title. Belongs here, not to a saved layout — a rename reaches everyone. */
title: string;
Expand Down Expand Up @@ -92,7 +92,7 @@ export function panelDef(id: string): PanelDef | undefined {
return PANELS.find((entry) => entry.id === id);
}

export type PanelPress = "opened" | "fronted" | "closed";
type PanelPress = "opened" | "fronted" | "closed";

/**
* A press on a panel's name in the Panels menu. A closed panel opens, a panel
Expand Down
2 changes: 0 additions & 2 deletions web/src/lib/lab/annotations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ import {
import type { KnobRange } from "./types";

export {
DEFAULT_KNOB_LABELS,
KNOBS_ANNOTATION_RE,
buildKnobsAnnotationLine,
matchKnobsAnnotation,
parseKnobsAnnotation,
stripKnobsAnnotation,
};
export type { KnobAnnotationEntry };

Expand Down
2 changes: 1 addition & 1 deletion web/src/lib/lab/capture/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export type ProjectSlice = {
ranges: Array<[number, number]>;
};

export type CaptureClientHandlers = {
type CaptureClientHandlers = {
onFrame: (frame: FrameMessage) => void;
onState: (state: { time: number; playing: boolean }) => void;
onProgress: (done: number, total: number) => void;
Expand Down
16 changes: 8 additions & 8 deletions web/src/lib/lab/capture/probe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,27 +69,27 @@ export const PROBE_LAYOUT_MAX = 27;
* fault of the code — in both cases the upscale is pixel-identical to the
* native render and costs a fraction of it, so the verdict is the same.
*/
export const PROBE_DETAIL_MIN = 0.02;
export const PROBE_DENSITY_MIN = 0.55;
export const PROBE_DENSITY_MAX = 1.5;
export const PROBE_LUMINANCE_MIN = 10;
const PROBE_DETAIL_MIN = 0.02;
const PROBE_DENSITY_MIN = 0.55;
const PROBE_DENSITY_MAX = 1.5;
const PROBE_LUMINANCE_MIN = 10;
/** Below this mean neighbour difference a frame is flat — no texture to compare. */
export const PROBE_VARIATION_MIN = 2;
export const PROBE_NOISE_MAX = 12;
const PROBE_VARIATION_MIN = 2;
const PROBE_NOISE_MAX = 12;
const PROBE_PIXEL_BUDGET = 600_000;
const PROBE_STEPS = 8;
const PROBE_DT = 0.4;
const PROBE_SAMPLES = [3, 5, 8];

/** Aspect-true multiple of the matrix the probe renders at, within budget. */
export function probeGrid(matrix: MatrixSize): MatrixSize {
function probeGrid(matrix: MatrixSize): MatrixSize {
const pixels = matrix.width * matrix.height;
const factor = Math.max(2, Math.min(4, Math.floor(Math.sqrt(PROBE_PIXEL_BUDGET / pixels))));
return { width: matrix.width * factor, height: matrix.height * factor };
}

/** Box-filter an RGBA buffer to a coarser RGB float grid. */
export function boxDown(
function boxDown(
data: Uint8ClampedArray,
width: number,
height: number,
Expand Down
2 changes: 1 addition & 1 deletion web/src/lib/lab/capture/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export type CaptureSessionState = {
output: { width: number; height: number } | null;
};

export type CaptureSessionEvents = {
type CaptureSessionEvents = {
/** Per-layer errors from the latest frame, named for people. */
errors?: (errors: Record<string, string>) => void;
auto?: (auto: AutoVerdict | null) => void;
Expand Down
4 changes: 2 additions & 2 deletions web/src/lib/lab/capture/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import {
type CaptureSettings,
} from "./types";

export const CAPTURE_SETTINGS_STORAGE = LAB_STORAGE.capture;
const CAPTURE_SETTINGS_STORAGE = LAB_STORAGE.capture;

export type SizePreset = { id: string; label: string; width: number; height: number };
type SizePreset = { id: string; label: string; width: number; height: number };

/**
* Sizes worth a one-click pick. The matrix multiples keep the pattern's own
Expand Down
7 changes: 2 additions & 5 deletions web/src/lib/lab/capture/shaderSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,10 @@ vec4 ramp(float v) {
#line 1
`;

/** How many lines the preamble adds before the user's line 1. */
export const SHADER_PREAMBLE_LINES = SHADER_PREAMBLE.split("\n").length - 1;

export type ShaderPass = "image" | "state";

/** The name of the entry point a pass calls. */
export const SHADER_ENTRY: Record<ShaderPass, string> = {
const SHADER_ENTRY: Record<ShaderPass, string> = {
image: "mainImage",
state: "mainState",
};
Expand Down Expand Up @@ -130,7 +127,7 @@ export function remapShaderLog(log: string): string {
.join("\n");
}

export type ShaderSourceCheck = { ok: true; hasState: boolean } | { ok: false; error: string };
type ShaderSourceCheck = { ok: true; hasState: boolean } | { ok: false; error: string };

/** What can be said about a source without a GPU. */
export function checkShaderSource(source: string): ShaderSourceCheck {
Expand Down
2 changes: 1 addition & 1 deletion web/src/lib/lab/capture/shaderStage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
type ShaderPass,
} from "./shaderSource";

export type ShaderFrame = {
type ShaderFrame = {
geometry: CaptureGeometry;
/** The picture at `geometry.render`, for the painter to place. */
canvas: OffscreenCanvas;
Expand Down
2 changes: 1 addition & 1 deletion web/src/lib/lab/cppPrompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function roundRangeValue(value: number) {
return Math.round(value * 1000) / 1000;
}

export type CppPromptArgs = {
type CppPromptArgs = {
code: string;
matrix: MatrixSize;
knobs: number[];
Expand Down
6 changes: 3 additions & 3 deletions web/src/lib/lab/director/bake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export function resolveLane(lane: DirectorKeyframe[]): DirectorKeyframe[] {
}

/** One lane's cue values by second: keyframes plus curve samples, dupes elided. */
export function bakeLane(lane: DirectorKeyframe[]): Map<number, number> {
function bakeLane(lane: DirectorKeyframe[]): Map<number, number> {
const keys = resolveLane(lane);
const raw = new Map<number, number>();
for (let i = 0; i < keys.length; i++) {
Expand Down Expand Up @@ -145,7 +145,7 @@ export function bakeLane(lane: DirectorKeyframe[]): Map<number, number> {
return out;
}

export type BakedShow = {
type BakedShow = {
perf: Performance;
cueCount: number;
/** Approximate string-pool bytes (messages; the real check is encodePfst). */
Expand Down Expand Up @@ -400,7 +400,7 @@ export function bakeLaneV2(lane: DirectorKeyframe[]): V2Point[] {
return [...seen.values()].sort((a, b) => a.t - b.t);
}

export type BakedShowV2 = {
type BakedShowV2 = {
perf: Performance;
cueCount: number;
overBudget: boolean;
Expand Down
2 changes: 1 addition & 1 deletion web/src/lib/lab/director/sample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { BUS_WIRE_MAX } from "@/lib/pattern/controls";
import { bakeShowV2, resolveLane, resolvedLaneValue } from "./bake";
import type { DirectorShow } from "./types";

export type SampledShow = {
type SampledShow = {
/** Samples per second. */
fps: number;
/** Number of samples per lane; sample i sits at t = i / fps. */
Expand Down
2 changes: 1 addition & 1 deletion web/src/lib/lab/director/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export function snapWireTime(t: number): number {
}

export const DIRECTOR_MAX_SECONDS = 3600;
export const DIRECTOR_DEFAULT_SECONDS = 30;
const DIRECTOR_DEFAULT_SECONDS = 30;

export function directorId(): string {
return `d${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}`;
Expand Down
4 changes: 2 additions & 2 deletions web/src/lib/lab/editorReveal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
// re-clicking the already-active layer — the exact "let me in" gesture — would
// change nothing and emit nothing.

export type EditorKind = "code" | "pixel" | "text";
type EditorKind = "code" | "pixel" | "text";

export type EditorRevealRequest = {
type EditorRevealRequest = {
kind: EditorKind;
/** Creating a layer may reopen a closed editor panel; selecting never does. */
open: boolean;
Expand Down
2 changes: 1 addition & 1 deletion web/src/lib/lab/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export type EngineProject = {
ranges: Array<[number, number]>;
};

export type EngineFrame = {
type EngineFrame = {
data: Uint8ClampedArray;
width: number;
height: number;
Expand Down
2 changes: 1 addition & 1 deletion web/src/lib/lab/flatten.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function pixelBufferLiteral(data: Uint8ClampedArray, length = "__W * __H * 4"):
}
import { isRasterLayer, type CodeLayer, type KnobRange, type Layer, type RampLayer, type TextLayer } from "./types";

export type FlattenKnobs = { labels: string[]; ranges: KnobRange[] };
type FlattenKnobs = { labels: string[]; ranges: KnobRange[] };

function stripForEmbedding(code: string): string {
return (
Expand Down
6 changes: 3 additions & 3 deletions web/src/lib/lab/hExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ const blendCode = (blend: Layer["blend"]) =>
blend === "add" ? 1 : blend === "multiply" ? 2 : blend === "screen" ? 3 : 0;

export const SLOT_BEGIN = (i: number) => `// >>> LAYER ${i} TRANSLATION BEGIN <<<`;
export const SLOT_END = (i: number) => `// >>> LAYER ${i} TRANSLATION END <<<`;
const SLOT_END = (i: number) => `// >>> LAYER ${i} TRANSLATION END <<<`;

// ── export bundle ──

export type HExportLayerUnit = {
type HExportLayerUnit = {
/** Stack index (bottom → top) — also the L<i> namespace number. */
index: number;
name: string;
Expand All @@ -155,7 +155,7 @@ export type HExportArgs = {
knobLabels: string[];
};

export type HExport = {
type HExport = {
scaffold: string;
units: HExportLayerUnit[];
namespaceName: string;
Expand Down
6 changes: 3 additions & 3 deletions web/src/lib/lab/legacyDraft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ import { isValidMatrix, type MatrixSize } from "@/lib/pattern/matrix";

import { LAB_STORAGE, readJson, removeStorage as remove } from "./persist";

export const DRAFT_STORAGE = LAB_STORAGE.legacyDraft;
const DRAFT_STORAGE = LAB_STORAGE.legacyDraft;

// Guard rail so one runaway value can't blow the whole quota.
const MAX_CODE_CHARS = 200_000;

/** The July draft also kept the gallery's count, thinking and refs; only this outlived it. */
export type DraftGenSettings = {
type DraftGenSettings = {
colorMode: ColorMode;
};

export type LabDraft = {
type LabDraft = {
savedAt: number;
code: string;
knobs: number[];
Expand Down
2 changes: 1 addition & 1 deletion web/src/lib/lab/pixelTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ export function clearSurface(surface: PixelSurface) {
export type ImportFit = "contain" | "cover" | "stretch" | "center";

/** User placement on top of the base fit: a scale factor and a pixel offset. */
export type ImportTransform = { scale: number; offsetX: number; offsetY: number };
type ImportTransform = { scale: number; offsetX: number; offsetY: number };

/**
* Rasterize an image into a layer-sized RGBA buffer. `smooth: false` keeps
Expand Down
2 changes: 1 addition & 1 deletion web/src/lib/lab/serialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export function bytesToBase64(bytes: Uint8ClampedArray): string {
return btoa(binary);
}

export function base64ToBytes(base64: string, expectedLength: number): Uint8ClampedArray | null {
function base64ToBytes(base64: string, expectedLength: number): Uint8ClampedArray | null {
try {
const binary = atob(base64);
if (binary.length !== expectedLength) return null;
Expand Down
2 changes: 1 addition & 1 deletion web/src/lib/lab/sessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { LAB_STORAGE, readJson, writeJson } from "./persist";

const KEY = LAB_STORAGE.sessions;

export const MAX_SESSIONS = 3;
const MAX_SESSIONS = 3;

export type SessionMeta = {
id: string;
Expand Down
2 changes: 1 addition & 1 deletion web/src/lib/lab/store/director.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import type { LabStore } from "../store";
import type { SliceSet } from "./kinds";

export type DirectorSlice = Pick<LabStore, "updateDirector">;
type DirectorSlice = Pick<LabStore, "updateDirector">;

export function createDirectorSlice(set: SliceSet): DirectorSlice {
return {
Expand Down
2 changes: 1 addition & 1 deletion web/src/lib/lab/store/knobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { LabStore } from "../store";
import type { SliceSet } from "./kinds";
import { MIN_RANGE_SPAN } from "./shared";

export type KnobsSlice = Pick<LabStore, "setKnob" | "setRange">;
type KnobsSlice = Pick<LabStore, "setKnob" | "setRange">;

export function createKnobsSlice(set: SliceSet): KnobsSlice {
return {
Expand Down
2 changes: 1 addition & 1 deletion web/src/lib/lab/store/layers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { LabStore } from "../store";
import type { SliceSet, SliceGet } from "./kinds";
import { codeLayerFromSource, resizePixelLayers, updateLayer, updateCodeLayer, STARTER_CODE } from "./shared";

export type LayersSlice = Pick<LabStore, "selectLayer" | "addCodeLayer" | "addPixelLayer" | "addCodeLayerFromCode" | "duplicateLayer" | "removeLayer" | "reorderLayer" | "renameLayer" | "setLayerVisible" | "setLayerOpacity" | "setLayerBlend" | "setLayerRole" | "setLayerMaskInvert" | "updateLayerCode" | "applyMatrixLine" | "applyCodeToActive" | "bumpPixelLayer" | "replacePixelData" | "setLayerErrors">;
type LayersSlice = Pick<LabStore, "selectLayer" | "addCodeLayer" | "addPixelLayer" | "addCodeLayerFromCode" | "duplicateLayer" | "removeLayer" | "reorderLayer" | "renameLayer" | "setLayerVisible" | "setLayerOpacity" | "setLayerBlend" | "setLayerRole" | "setLayerMaskInvert" | "updateLayerCode" | "applyMatrixLine" | "applyCodeToActive" | "bumpPixelLayer" | "replacePixelData" | "setLayerErrors">;

export function createLayersSlice(set: SliceSet, get: SliceGet): LayersSlice {
return {
Expand Down
2 changes: 1 addition & 1 deletion web/src/lib/lab/store/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { LabStore } from "../store";
import type { SliceSet, SliceGet } from "./kinds";
import { defaultProject, resizePixelLayers } from "./shared";

export type ProjectSlice = Pick<LabStore, "hydrate" | "discardProject" | "stashCurrent" | "parkSnapshot" | "restoreSession" | "setMatrix" | "setGen" | "setForkOf" | "setEditOf" | "setName" | "importStackLayers">;
type ProjectSlice = Pick<LabStore, "hydrate" | "discardProject" | "stashCurrent" | "parkSnapshot" | "restoreSession" | "setMatrix" | "setGen" | "setForkOf" | "setEditOf" | "setName" | "importStackLayers">;

export function createProjectSlice(set: SliceSet, get: SliceGet): ProjectSlice {
return {
Expand Down
2 changes: 1 addition & 1 deletion web/src/lib/lab/store/ramp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { LabStore } from "../store";
import type { SliceSet } from "./kinds";
import { updateCodeLayer, updateRampLayer } from "./shared";

export type RampSlice = Pick<LabStore, "setRampSelection" | "setLayerRecolor" | "setLayerRampMode" | "setLayerRampWrap" | "updateLayerRampStop" | "addLayerRampStop" | "deleteLayerRampStop" | "setLayerRampStops">;
type RampSlice = Pick<LabStore, "setRampSelection" | "setLayerRecolor" | "setLayerRampMode" | "setLayerRampWrap" | "updateLayerRampStop" | "addLayerRampStop" | "deleteLayerRampStop" | "setLayerRampStops">;

export function createRampSlice(set: SliceSet): RampSlice {
return {
Expand Down
2 changes: 1 addition & 1 deletion web/src/lib/lab/store/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { createTextLayer, nextLayerName, normalizeTextSpec } from "../types";
import type { LabStore } from "../store";
import type { SliceSet, SliceGet } from "./kinds";

export type TextSlice = Pick<LabStore, "addTextLayer" | "setTextSpec" | "redrawTextLayers">;
type TextSlice = Pick<LabStore, "addTextLayer" | "setTextSpec" | "redrawTextLayers">;

export function createTextSlice(set: SliceSet, get: SliceGet): TextSlice {
return {
Expand Down
Loading
Loading