Move docs/ package mirror into document-navigator plugin
Relocate the ~6k-file docs tree from the repo root into plugins/document-navigator/docs/ so the plugin is self-contained and portable. docs/superpowers/ (specs and plans) stays at the repo root. Moved via cp+rm rather than git mv because directory rename() fails with EPERM on this WSL /mnt DrvFs mount; git rename-detection pairs the identical-content files at commit time. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
# `microphone/schemas`
|
||||
|
||||
<!-- begin:auto-docs -->
|
||||
_(no submodules)_
|
||||
<!-- end:auto-docs -->
|
||||
|
||||
## Purpose
|
||||
|
||||
Zod schemas validating the construction-time options, the eight control groups, the full configuration tree, and the preset payload of `MicrophoneSimulationPlugin`. These run on the public boundary so any malformed object is rejected with `AUDIO_FX.INVALID_OPTIONS` / `AUDIO_FX.INVALID_PRESET` before it can corrupt runtime state.
|
||||
|
||||
Separating schemas from the plugin module lets `index.ts` re-export them so callers can introspect the option surface (for forms, RPC validation, or storybook controls) without importing the audio implementation.
|
||||
|
||||
## Features
|
||||
|
||||
- Eight per-section schemas: `FrequencyControlsSchema`, `ResonanceControlsSchema`, `DistortionControlsSchema`, `NoiseControlsSchema`, `DynamicsControlsSchema`, `GainControlsSchema`, `CharacterControlsSchema`, `WowAndFlutterControlsSchema`. Each enforces its documented range with `z.number().finite()` to block `NaN`/`Infinity`.
|
||||
- `MicrophoneConfigSchema` composes the eight sections into one object.
|
||||
- `MicrophoneSimulationPluginOptionsSchema` wraps `MicrophoneConfigSchema.partial()` so callers can pass any subset of fields.
|
||||
- `MicrophonePresetDataSchema` is `.strict()` and demands the full `MicrophoneConfig` payload.
|
||||
|
||||
## Usage: Basic Example
|
||||
|
||||
```ts
|
||||
import { MicrophoneConfigSchema } from "@suaveplan/audio-fx-plugin-microphone";
|
||||
|
||||
const parsed = MicrophoneConfigSchema.partial().parse({
|
||||
noise: { level: 0.05, color: "white" },
|
||||
});
|
||||
```
|
||||
|
||||
## Usage: Advanced Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
MicrophoneConfigSchema,
|
||||
NoiseControlsSchema,
|
||||
} from "@suaveplan/audio-fx-plugin-microphone";
|
||||
|
||||
// Validate a section in isolation (useful for an RPC that updates only one
|
||||
// part of the mic state).
|
||||
function setNoise(plugin: MicrophoneSimulationPlugin, raw: unknown) {
|
||||
const noise = NoiseControlsSchema.parse(raw);
|
||||
plugin.setMicrophoneConfig({ noise });
|
||||
}
|
||||
|
||||
const partial = MicrophoneConfigSchema.partial().parse({
|
||||
frequency: { cutoffHz: 4_000, tiltDb: 0 },
|
||||
});
|
||||
```
|
||||
|
||||
## API Reference
|
||||
|
||||
- `FrequencyControlsSchema: z.ZodObject<{ cutoffHz, tiltDb }>`
|
||||
- `ResonanceControlsSchema: z.ZodObject<{ q }>`
|
||||
- `DistortionControlsSchema: z.ZodObject<{ drive, mix }>`
|
||||
- `NoiseControlsSchema: z.ZodObject<{ level, color }>`
|
||||
- `DynamicsControlsSchema: z.ZodObject<{ thresholdDb, ratio }>`
|
||||
- `GainControlsSchema: z.ZodObject<{ inputDb, outputDb }>`
|
||||
- `CharacterControlsSchema: z.ZodObject<{ warmth, presence }>`
|
||||
- `WowAndFlutterControlsSchema: z.ZodObject<{ wowRateHz, wowDepth, flutterRateHz, flutterDepth }>`
|
||||
- `MicrophoneConfigSchema: z.ZodObject<…>`
|
||||
- `MicrophoneSimulationPluginOptionsSchema: z.ZodObject<{ config? }>`
|
||||
- `MicrophonePresetDataSchema: z.ZodObject<{ config }, "strict">`
|
||||
|
||||
## Implementation Notes
|
||||
|
||||
The per-section schemas are exported as named values rather than inlined into `MicrophoneConfigSchema` so they can be reused by callers that want to validate a single section at a time — for example, an RPC endpoint that updates only the noise floor. The combined `MicrophoneConfigSchema` is built by composing the section schemas, so adding a field to a section is a single-place change.
|
||||
|
||||
`MicrophonePresetDataSchema` demands the full `MicrophoneConfig` (not a partial). Presets restore the entire microphone state in one shot; allowing a partial would leave the restored plugin in an indeterminate state where some sections came from the preset and others from whatever happened to be loaded. The `.strict()` modifier additionally rejects unknown fields so a forwards-incompatible preset payload is caught at the boundary rather than silently dropping unknown keys.
|
||||
Reference in New Issue
Block a user