open-index/open-npm huggingface dataset:
npm package: @moqtap/codec
Description: MoQT wire-format codec and session state machine — multi-draft, zero dependencies
Author: moqtap
Latest version: 0.2.3

# @moqtap/codec

MoQT (Media over QUIC Transport) wire-format codec and session state machine for JavaScript/TypeScript.

- Multi-draft support (drafts 07 through 17)
- Stateless encode/decode of all MoQT control messages and data streams
- Protocol session state machine with FSM-based validation per draft
- Zero runtime dependencies
- Works in Node.js, Bun, and browsers
- Full TypeScript types with discriminated unions

## Install

```bash
npm install @moqtap/codec
```

## Quick Start

MoQT is pre-RFC, so a draft version must always be specified. Use draft-scoped imports for the best experience:

```typescript
import { createDraft07Codec } from '@moqtap/codec/draft7';

const codec = createDraft07Codec();

// Decode a message from bytes
const result = codec.decodeMessage(bytes);
if (result.ok) {
  console.log(result.value.type); // e.g. 'subscribe'
}

// Encode a message to bytes
const encoded = codec.encodeMessage({
  type: 'client_setup',
  supportedVersions: [0xff000007n],
  parameters: new Map(),
});
```

Or use the factory if your application supports multiple drafts:

```typescript
import { createCodec } from '@moqtap/codec';

const codec = createCodec({ draft: '17' }); // '07' through '17'
```

## Subpath Exports

Each draft is available as a subpath import with its own codec and session state machine:

| Import path | Description |
|---|---|
| `@moqtap/codec` | Factory + shared types (`createCodec({ draft })`) |
| `@moqtap/codec/draft7` | Draft-07 codec |
| `@moqtap/codec/draft8` | Draft-08 codec |
| `@moqtap/codec/draft9` | Draft-09 codec |
| `@moqtap/codec/draft10` | Draft-10 codec |
| `@moqtap/codec/draft11` | Draft-11 codec |
| `@moqtap/codec/draft12` | Draft-12 codec |
| `@moqtap/codec/draft13` | Draft-13 codec |
| `@moqtap/codec/draft14` | Draft-14 codec |
| `@moqtap/codec/draft15` | Draft-15 codec |
| `@moqtap/codec/draft16` | Draft-16 codec |
| `@moqtap/codec/draft17` | Draft-17 codec |
| `@moqtap/codec/draft{N}/session` | Session state machine for draft N |

> **Note:** A default (versionless) codec will be available once the MoQT specification reaches RFC status. Until then, always specify a draft version.

## Draft-Specific Imports

For applications targeting a single draft version:

```typescript
import { createDraft17Codec } from '@moqtap/codec/draft17';
import { createDraft17SessionState } from '@moqtap/codec/draft17/session';
```

## Session State Machine

Validate protocol message sequences without transport coupling:

```typescript
import { createDraft17SessionState } from '@moqtap/codec/draft17/session';
import { createDraft17Codec } from '@moqtap/codec/draft17';

const codec = createDraft17Codec();
const session = createDraft17SessionState({ codec, role: 'client' });

const result = session.receive(incomingMessage);
if (!result.ok) {
  console.error('Protocol violation:', result.violation);
}
```

## License

MIT
npm package: @moqtap/trace
Description: MoQT session trace format — record, serialize, and analyze .moqtrace files
Author: moqtap
Latest version: 0.1.1

# @moqtap/trace

Record, serialize, and analyze MoQT (Media over QUIC Transport) sessions using the `.moqtrace` binary format.

- Binary `.moqtrace` format with CBOR encoding (compact, streamable, cross-language)
- Configurable detail levels from control-only to full wire captures
- Session recorder that wraps `@moqtap/codec` session state machines
- Human-readable JSON export for debugging
- Zero-copy streaming writer for large traces

## Install

```bash
npm install @moqtap/trace @moqtap/codec
```

`@moqtap/codec` is a peer dependency — install it alongside `@moqtap/trace`.

## Quick Start

### Recording a session

```typescript
import { createRecorder, writeMoqtrace } from '@moqtap/trace';
import { createDraft14SessionState } from '@moqtap/codec/draft14/session';

const recorder = createRecorder({
  protocol: 'moq-transport-14',
  perspective: 'client',
  detail: 'control',
});

// Wrap a session to auto-capture control messages and state transitions
const session = createDraft14SessionState({ codec: { draft: 'draft-ietf-moq-transport-14' }, role: 'client' });
const traced = recorder.wrapSession(session);

// Use `traced` instead of `session` — all send/receive calls are recorded
traced.send(clientSetupMessage);
traced.receive(serverSetupMessage);

// Manually record events the session layer doesn't see
recorder.recordStreamOpened(4n, 0, 0); // outgoing subgroup stream
recorder.annotate('connected', { relay: 'cdn.example.com' });

// Finalize and serialize
const trace = recorder.finalize();
const bytes = writeMoqtrace(trace); // → Uint8Array (.moqtrace binary)
```

### Reading a trace file

```typescript
import { readMoqtrace, readMoqtraceHeader } from '@moqtap/trace';

// Quick metadata peek (no event parsing)
const header = readMoqtraceHeader(bytes);
console.log(header.protocol);   // "moq-transport-14"
console.log(header.perspective); // "client"
console.log(header.detail);     // "control"

// Full parse
const trace = readMoqtrace(bytes);
for (const event of trace.events) {
  console.log(event.type, event.timestamp);
}
```

### Streaming writer (for large traces)

```typescript
import { createMoqtraceWriter } from '@moqtap/trace';

const writer = createMoqtraceWriter(header);
outputStream.write(writer.preamble());

for (const event of events) {
  outputStream.write(writer.writeEvent(event));
}
```

## Detail Levels

| Level | What's recorded |
|---|---|
| `control` | Control messages only (setup, subscribe, publish, goaway) |
| `headers` | + data stream headers (subgroup/fetch, object metadata) |
| `headers+sizes` | + payload byte lengths |
| `headers+data` | + full payload bytes |
| `full` | + raw wire bytes (pre-decode) |

## JSON Export

For human-readable debugging (not lossless — bigint/Uint8Array become strings):

```typescript
import { traceToJSON } from '@moqtap/trace';

const json = traceToJSON(trace);
console.log(json);
```

## File Format

See [SPEC.md](./SPEC.md) for the complete `.moqtrace` binary format specification.

## License

MIT
npm package: @moquality/utility-hooks
Description: Utility Hooks
Author: moquality
Latest version: 0.0.4

# utility-hooks

> Utility Hooks

[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

## Install

```bash
npm install --save @moquality/utility-hooks
```

## Example

See example on [moquality.github.io/utility-hooks](https://moquality.github.io/utility-hooks/)

## Usage

```jsx
import {
	GlobalStateProvider,
	ConfirmProvider,
	ToastProvider,
} from '@moquality/utility-hooks'

import { useLocalStorageState, useToast, useGlobalState } from 'utility-hooks'

const App = () => {
	const [global, setGlobal] = useGlobalState()
	const [data, setData] = useLocalStorageState('example', 'data')
  const [showToast, hideToast] = useToast()

  return (
    <p>Local Storage: {data}</p>
    <p>Mode: {global.mode}</p>
    <Button
      compact
      onClick={() => {
        showToast('Hi', { id: 1 })
      }}
    >
      Say Hi in a Toast
    </Button>
    <Button
      compact
      onClick={() => {
        hideToast(1)
      }}
    >
      Hide Toast
    </Button>
  )
}

ReactDOM.render(
	<GlobalStateProvider
    initial={{
      mode: 'RECORD',
    }}
  >
    <ConfirmProvider>
      <ToastProvider>
        <App />
      </ToastProvider>
    </ConfirmProvider>
  </GlobalStateProvider>,
  document.getElementById('root'),
)
```

## License

Private © [moquality](https://github.com/moquality)

---

This hook is created using [create-react-hook](https://github.com/hermanya/create-react-hook).