open-index/open-npm huggingface dataset:
npm package: @naikidev/commiq
Description: Command and event driven state management for JavaScript and TypeScript.
Latest version: 1.1.0

# @naikidev/commiq

Command and event driven state management for JavaScript and TypeScript.

## Install

```bash
pnpm add @naikidev/commiq
```

## Usage

```typescript
import { createStore, createCommand, sealStore } from "@naikidev/commiq";

const store = createStore({ count: 0 });

store.addCommandHandler("increment", (ctx) => {
  ctx.setState({ count: ctx.state.count + 1 });
});

const sealed = sealStore(store);
sealed.queue(createCommand("increment", undefined));
```

## Documentation

Full docs at [naikidev.github.io/commiq](https://naikidev.github.io/commiq).

## License

MIT
npm package: @naikidev/commiq-context
Description: Context extensions for commiq stores. Add custom properties to command and event handler contexts with full type safety.
Latest version: 1.1.0

# @naikidev/commiq-context

Context extensions for commiq stores. Add custom properties to command and event handler contexts with full type safety.

## Install

```bash
pnpm add @naikidev/commiq-context
```

## Usage

```ts
import { createStore, createCommand } from "@naikidev/commiq";
import { withPatch, withGuard, withInjector } from "@naikidev/commiq-context";

type State = { user: User | null; loading: boolean };

const store = createStore<State>({ user: null, loading: false })
  .useExtension(withPatch<State>())
  .useExtension(withGuard<State>())
  .useExtension(withInjector<State>()({ api: new ApiClient() }))
  .addCommandHandler("user:load", async (ctx, cmd) => {
    ctx.guard(cmd.data.id !== "", "user ID required");
    ctx.patch({ loading: true });
    const user = await ctx.deps.api.fetchUser(cmd.data.id);
    ctx.patch({ user, loading: false });
  });
```

## Pre-built Extensions

| Extension | Adds to `ctx` | Description |
| --- | --- | --- |
| `withPatch()` | `patch(partial)` | Shallow-merge partial state updates |
| `withGuard()` | `guard(condition, message)` | Precondition checks that stop the handler on failure |
| `withAssert(options?)` | `assert(condition, message)` | Dev-time invariant checks, can be disabled in production |
| `withDefer()` | `defer(fn)` | Cleanup callbacks that run after the handler completes |
| `withInjector()(deps)` | `deps` | Typed dependency injection via property access |
| `withLogger(options?)` | `log(level, message)` | Structured logging with configurable handler |
| `withMeta()` | `meta` | Command/event metadata (name, correlationId, causedBy, timestamp) |
| `withHistory(options?)` | `history` | Ring buffer of previous states |

## Custom Extensions

```ts
import { defineContextExtension } from "@naikidev/commiq-context";

const withTimestamp = defineContextExtension<State, {
  now: () => number;
}>({
  command: () => ({
    now: () => Date.now(),
  }),
});
```

## Documentation

Full docs at [naikidev.github.io/commiq](https://naikidev.github.io/commiq).

## License

MIT
npm package: @naikidev/commiq-devtools
Description: Embedded devtools panel for React applications. Inspect events, trace causality, view state, and monitor performance.
Latest version: 1.1.0

# @naikidev/commiq-devtools

Embedded devtools panel for React applications. Inspect events, trace causality, view state, and monitor performance.

## Install

```bash
pnpm add @naikidev/commiq-devtools
```

Peer dependencies: `@naikidev/commiq`, `react`, `react-dom`.

## Usage

No provider required. Use as a component or mount imperatively.

```tsx
import { CommiqDevtools } from "@naikidev/commiq-devtools";

function App() {
  return (
    <>
      <YourApp />
      <CommiqDevtools stores={{ counter: counterStore }} />
    </>
  );
}
```

Or without JSX:

```ts
import { mountDevtools } from "@naikidev/commiq-devtools";

const unmount = mountDevtools({ stores: { counter: counterStore } });
```

Auto-hides in production. Override with `enabled={true}` or `enabled={false}`.

## Documentation

Full docs at [naikidev.github.io/commiq](https://naikidev.github.io/commiq).

## License

MIT
npm package: @naikidev/commiq-devtools-core
Description: Instrumentation and debugging tools for Commiq stores. Tracks events, causality chains, state history, and supports pluggable transports.
Latest version: 1.1.0

# @naikidev/commiq-devtools-core

Instrumentation and debugging tools for Commiq stores. Tracks events, causality chains, state history, and supports pluggable transports.

## Install

```bash
pnpm add @naikidev/commiq-devtools-core
```

## Usage

```typescript
import { createDevtools } from "@naikidev/commiq-devtools-core";

const devtools = createDevtools();
devtools.connect(store, "counter");

// Query the timeline
const timeline = devtools.getTimeline();
const chain = devtools.getChain(correlationId);
const history = devtools.getStateHistory("counter");
```

## Documentation

Full docs at [naikidev.github.io/commiq](https://naikidev.github.io/commiq).

## License

MIT
npm package: @naikidev/commiq-effects
Description: Structured side effects for Commiq stores. Trigger effects from events with built-in cancellation, restart, and debounce.
Latest version: 1.1.0

# @naikidev/commiq-effects

Structured side effects for Commiq stores. Trigger effects from events with built-in cancellation, restart, and debounce.

## Install

```bash
pnpm add @naikidev/commiq-effects
```

## Usage

```typescript
import { createStore, createEvent, createCommand, sealStore } from "@naikidev/commiq";
import { createEffects } from "@naikidev/commiq-effects";

const store = createStore({ results: [] });
const searchRequested = createEvent<string>("searchRequested");

store.addCommandHandler("search", (ctx, cmd) => {
  ctx.emit(searchRequested, cmd.data);
});

store.addCommandHandler("setResults", (ctx, cmd) => {
  ctx.setState({ results: cmd.data });
});

const sealed = sealStore(store);
const effects = createEffects(sealed);

effects.on(searchRequested, async (query, ctx) => {
  const res = await fetch(`/api/search?q=${query}`, { signal: ctx.signal });
  const data = await res.json();
  ctx.queue(createCommand("setResults", data));
}, { restartOnNew: true });

// Clean up when done
effects.destroy();
```

## Options

| Option | Type | Default | Description |
|---|---|---|---|
| `restartOnNew` | `boolean` | `false` | Cancel previous run if same effect re-triggers |
| `cancelOn` | `EventDef` | — | Cancel running effect when this event fires |
| `debounce` | `number` | — | Debounce in ms before running (last-wins) |

## Documentation

Full docs at [naikidev.github.io/commiq](https://naikidev.github.io/commiq).

## License

MIT
npm package: @naikidev/commiq-otel
Description: OpenTelemetry tracing integration for Commiq stores. Creates spans for commands and records events as span events.
Latest version: 1.1.0

# @naikidev/commiq-otel

OpenTelemetry tracing integration for Commiq stores. Creates spans for commands and records events as span events.

## Install

```bash
pnpm add @naikidev/commiq-otel @opentelemetry/api
```

## Usage

```typescript
import { instrumentStore } from "@naikidev/commiq-otel";

const uninstrument = instrumentStore(store, { storeName: "counter" });

// Later...
uninstrument();
```

## Documentation

Full docs at [naikidev.github.io/commiq](https://naikidev.github.io/commiq).

## License

MIT
npm package: @naikidev/commiq-persist
Description: State persistence and rehydration for Commiq stores. Automatically saves state to localStorage (or any storage adapter) and restores it on load.
Latest version: 1.1.0

# @naikidev/commiq-persist

State persistence and rehydration for Commiq stores. Automatically saves state to localStorage (or any storage adapter) and restores it on load.

## Install

```bash
pnpm add @naikidev/commiq-persist
```

## Usage

```typescript
import { createStore } from "@naikidev/commiq";
import { persistStore } from "@naikidev/commiq-persist";

const store = createStore({ count: 0 });

store.addCommandHandler("increment", (ctx) => {
  ctx.setState({ count: ctx.state.count + 1 });
});

const { destroy, hydrated } = persistStore(store, { key: "my-counter" });

// Optional: wait for async storage adapters
await hydrated;

// Later, to stop persisting:
destroy();
```

## Options

| Option | Type | Default | Description |
|---|---|---|---|
| `key` | `string` | required | Storage key |
| `storage` | `StorageAdapter` | `localStorage` | Any object with `getItem`/`setItem` |
| `debounce` | `number` | `300` | Debounce writes (ms) |
| `serialize` | `(state) => string` | `JSON.stringify` | Custom serializer |
| `deserialize` | `(raw) => state` | `JSON.parse` | Custom deserializer |

## Documentation

Full docs at [naikidev.github.io/commiq](https://naikidev.github.io/commiq).

## License

MIT
npm package: @naikidev/commiq-react
Description: React bindings for Commiq.
Latest version: 1.1.0

# @naikidev/commiq-react

React bindings for Commiq.

## Install

```bash
pnpm add @naikidev/commiq @naikidev/commiq-react
```

## Usage

```tsx
import { useSelector, useQueue } from "@naikidev/commiq-react";
import { createCommand } from "@naikidev/commiq";

function Counter() {
  const count = useSelector(counterStore, (s) => s.count);
  const queue = useQueue(counterStore);

  return (
    <button onClick={() => queue(createCommand("increment", undefined))}>
      Count: {count}
    </button>
  );
}
```

Hooks: `useSelector`, `useQueue`, `useEvent`, `CommiqProvider`.

## Documentation

Full docs at [naikidev.github.io/commiq](https://naikidev.github.io/commiq).

## License

MIT